Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
GCC optimization flags
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
daos
n00b
n00b


Joined: 18 Apr 2002
Posts: 50
Location: Virginia, USA

PostPosted: Sun Jun 02, 2002 2:21 pm    Post subject: GCC optimization flags Reply with quote

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
View user's profile Send private message
Malakin
Veteran
Veteran


Joined: 14 Apr 2002
Posts: 1692
Location: Victoria BC Canada

PostPosted: Sun Jun 02, 2002 6:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
kerframil
l33t
l33t


Joined: 19 Apr 2002
Posts: 710
Location: London, UK

PostPosted: Sun Jun 02, 2002 8:07 pm    Post subject: My experience: Reply with quote

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
View user's profile Send private message
lx
Veteran
Veteran


Joined: 28 May 2002
Posts: 1012
Location: Netherlands

PostPosted: Sun Jun 02, 2002 8:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum