Set optimize level using FBide and FBC 1.07.1

New to FreeBASIC? Post your questions here.
Post Reply
Flyzone
Posts: 109
Joined: Nov 17, 2017 17:39

Set optimize level using FBide and FBC 1.07.1

Post by Flyzone »

How do I do this in FBide? I did "Settings" "Compiler command" appending " -O 3" but that doesn't work.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Set optimize level using FBide and FBC 1.07.1

Post by D.J.Peters »

FBIDE change all program arguments in lower case so "-O 3" becomes "-o 3" and isn't what you need
but you can use "#cmdline" to give the compiler/linker/assembler arguments directly in your *.bi or *.bas file!

Joshy

Code: Select all

#cmdline "-O 3"
print "bla bla bla" : sleep
or something like this:

Code: Select all

#ifndef __FB_64BIT__
 #cmdline "-gen gcc -arch pentium4-sse3 -Wc -O3 -fpmode fast -fpu sse -O 3 -asm intel"
#else
 #cmdline "-arch x86-64 -Wc -O3 -fpmode fast -fpu sse -O 3 -asm intel"
#endif
' bla bla bla
Flyzone
Posts: 109
Joined: Nov 17, 2017 17:39

Re: Set optimize level using FBide and FBC 1.07.1

Post by Flyzone »

Pretty dumb changing the case ...

I don't think #cmdline works for versions lower than 8 or 9 (I have 7). In any event I thought that would send parms to your program rather than the compiler.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Set optimize level using FBide and FBC 1.07.1

Post by D.J.Peters »

"excuse me wir haben 2022" It's a viral german TikTok meme :-)

time to upgrade your FreeBASIC compiler.

Joshy
Flyzone
Posts: 109
Joined: Nov 17, 2017 17:39

Re: Set optimize level using FBide and FBC 1.07.1

Post by Flyzone »

Upgraded to 9.
Compiled program with #cmdline " -O 3"
Program compiles, no errors
Run program. Program begins, get thru 10% of process or so, then freezes
Remove #cmdline option
Program compiles, no errors. Run program. Program completes normally.

Still no optimization.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Set optimize level using FBide and FBC 1.07.1

Post by D.J.Peters »

first try -O 2 (may be you have something strange that are optimized in a bad way with -O 3)
or show me your code.

With my settings (I posted) I get maximal performes for example ray tracing an image 20 seconds with my settings 5 secods !!!

Joshy
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: Set optimize level using FBide and FBC 1.07.1

Post by srvaldez »

also, for debugging purposes add -exx, e.g. #cmdline "-exx -O 2"
-exx will slowdown performance, so after your program is debugged you probably should remove it.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Set optimize level using FBide and FBC 1.07.1

Post by dodicat »

Remember to use #cmdline "-gen gcc -O 2"
or #cmdline "-gen gcc -Wc -O2"

The -gen gcc bit is relevant, the default -gen gas in 32 bits is unaffected by optimisations, and SARG's compiler -gen gas64 is unaffected by optimisations, (although it is not the default compiler for 64 bits).
So you might be disappointed with optimisations due to a typo.
Flyzone
Posts: 109
Joined: Nov 17, 2017 17:39

Re: Set optimize level using FBide and FBC 1.07.1

Post by Flyzone »

The program has been completely debugged and has run for some time under version 7.
For ver 9 I used the FBC64 compiler. I'm not sure under what circumstances I should use one or the other. I have a 64 bit machine.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: Set optimize level using FBide and FBC 1.07.1

Post by srvaldez »

FBC64 produces a 64-bit executable whereas FBC32 produces a 32-bit exe
one thing to watch out for if you are accustomed to writing programs for 32-bit and then decide you want to compile that program for 64-bit is for long and integer variables, in 32-bit a long is the same size as integer but in 64-bit an integer is 64-bit, sometimes that makes a big difference
Flyzone
Posts: 109
Joined: Nov 17, 2017 17:39

Re: Set optimize level using FBide and FBC 1.07.1

Post by Flyzone »

Compiles with #CMDLINE "-O 2"
Same result at -O 3 (compiles no errors, runs 10% and freezes)

"-gen gcc -O 2" doesn't work since it creates errors in my code using GOSUBs then compile quits early ... too much to change for that option.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: Set optimize level using FBide and FBC 1.07.1

Post by srvaldez »

Flyzone
to use Gosub you need to either use:
#lang "QB"

or

#lang "fblite"
option gosub

keep in mind that if you use #lang "QB" then the integer types will be that of QB and not FB, consult the FB manual
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Set optimize level using FBide and FBC 1.07.1

Post by D.J.Peters »

D.J.Peters wrote: Nov 04, 2022 7:48... show me your code ...
Flyzone
Posts: 109
Joined: Nov 17, 2017 17:39

Re: Set optimize level using FBide and FBC 1.07.1

Post by Flyzone »

I had both of those specs for GOSUB but The "gen gcc" option overrides them and causes a reversion to the primary dialect which outlaws GOSUB.

The code is intended as pseudocode for a 1960s computer (1401) for sorting (which it didn't do very well) and would be funny looking stuff for this group so I'll just go without optimizing. I'd have more suggestions for change than I could count :shock: Thanks for the help.
Post Reply