View previous topic :: View next topic |
Author |
Message |
daos n00b

Joined: 18 Apr 2002 Posts: 50 Location: Virginia, USA
|
Posted: Sun Jun 02, 2002 2:21 pm Post subject: GCC optimization flags |
|
|
I came to this part of GCC site:
http://www.tldp.org/HOWTO/Assembly-HOWTO/gcc.html
It reccommends optimization flags for the x86 platform:
gcc -02 -fomit-frame-pointer -W -Wall
My issue here is -O2 vs -O3. There are some sites I read (I don't recall the address) saying that -O3 may produce some odd bugs. Besides, -O3 produces larger binary sizes than -O2.
When I first came to Gentoo, I compiled KDE with -O3 flags. When KDE 3.01 is available in Gentoo, I recompiled entire KDE 3.01 and qt 3.04 with -O2 flag.
Really, I don't feel any difference in performance. If -O2 produce smaller binary sizes, I think -O2 may be better choice.
Steve D. |
|
Back to top |
|
 |
Malakin Veteran


Joined: 14 Apr 2002 Posts: 1692 Location: Victoria BC Canada
|
Posted: Sun Jun 02, 2002 6:15 pm Post subject: |
|
|
In most programs these flags aren't going to make so much of a difference that you'll be able to "feel" it. You would have to benchmark it somehow.
According to the gcc manual the only thing -O3 does over -O2 is it turns on inline functions. It would depend on the program whether or not this would be beneficial or not. |
|
Back to top |
|
 |
474 l33t

Joined: 19 Apr 2002 Posts: 714
|
Posted: Sun Jun 02, 2002 8:07 pm Post subject: My experience: |
|
|
I only use -fomit-frame-pointer as well as optimising for my CPU arch. I believe this makes quite a difference in speed, but it busts the ability to debug the binary fully, so I tend to avoid using -fomit-frame-pointer for system packages. -W and -Wall aren't optimisations, just directives to tell the compiler which warnings to display. Most builds will be fine with -O3 but some (particularly core system builds such as gcc, libc) will not. Fortunately, the ebuild script for any such build will usually EXPORT different flags to override -O3 anyway. But yes, if you wanted to be absolutely safe just use -O2 and a conservative setting for -march! |
|
Back to top |
|
 |
lx Veteran


Joined: 28 May 2002 Posts: 1012 Location: Netherlands
|
Posted: Sun Jun 02, 2002 8:56 pm Post subject: |
|
|
Depends on the package your compiling, some flags do wonders with bzip but do nothing or sometimes slowdown other programs. Some flags can also introduce unpredictable errors, so I will trust the developer of the package to come up with the extra compile flags and just use march=.... -O3 (or O2).
Cya lX _________________ "Remember there's a big difference between kneeling down and bending over.", Frank Zappa |
|
Back to top |
|
 |
|