Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
-O2 or -Os
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Duplicate Threads
View previous topic :: View next topic  
Author Message
JustGags
n00b
n00b


Joined: 29 Apr 2005
Posts: 32

PostPosted: Sun Sep 03, 2006 2:45 am    Post subject: -O2 or -Os Reply with quote

-O2 or -Os

Which is "better"? Why?
Back to top
View user's profile Send private message
yabbadabbadont
Advocate
Advocate


Joined: 14 Mar 2003
Posts: 4791
Location: 2 exits past crazy

PostPosted: Sun Sep 03, 2006 2:48 am    Post subject: Reply with quote

If you are worried about the final size of the compiled binaries, then use -Os, otherwise -O2.
Back to top
View user's profile Send private message
JustGags
n00b
n00b


Joined: 29 Apr 2005
Posts: 32

PostPosted: Sun Sep 03, 2006 4:10 am    Post subject: Reply with quote

Any speed difference either in compiling or binary performance?
Back to top
View user's profile Send private message
Phenax
l33t
l33t


Joined: 10 Mar 2006
Posts: 972

PostPosted: Sun Sep 03, 2006 4:12 am    Post subject: Reply with quote

Well, I'd say that -Os is better for machines with a limited amount of RAM or harddrive space, while more powerful machines would like -O2.

-O2 is more raw performance and -Os is performance with all of the flags that increase size filtered out. It makes your system use less RAM and less harddrive space.
Although -O2 would probably give you better 'raw performance.'

They both should compile at generally the same time.
Back to top
View user's profile Send private message
Headrush
Watchman
Watchman


Joined: 06 Nov 2003
Posts: 5597
Location: Bizarro World

PostPosted: Sun Sep 03, 2006 4:32 am    Post subject: Reply with quote

Depends on your arch too.
If you've got a Via CPU, -Os. (Though I'm guessing you don't have this.)

JustGags wrote:
Any speed difference either in compiling or binary performance?

What kind of hardware to you have?
Anything modern you probably won't notice enough of a difference either way.
Some software probably can benefit from optimizations from both, but it depends on the package.
Back to top
View user's profile Send private message
BRPXQZME
Apprentice
Apprentice


Joined: 23 Mar 2006
Posts: 163
Location: Centreville, VA

PostPosted: Sun Sep 03, 2006 5:31 am    Post subject: Reply with quote

IMHO, -Os is better than -O2 for most things, but there were a few things that broke for me with -Os and GCC4, so I run -O2 for just about everything (mmm laziness).

-Os I think might compile slightly slower (this is entirely in my imagination, not a hard fact :) )

Since my computer has some kinda slow buses between HD, RAM, and the P4, I'd really like to go with -Os, because I'd notice the difference... even though it's just a little and mostly psychological.

The choice really depends on you and your system.
_________________
Firefox is spelled F-i-r-e-f-o-x - only the first letter capitalized (i.e. not FireFox, not Foxfire, FoxFire or whatever else a number of folk seem to think it to be called.) The preferred abbreviation is "Fx" or "fx".

FF = Final Fantasy.
Back to top
View user's profile Send private message
H-Dragon
Guru
Guru


Joined: 22 Oct 2002
Posts: 547

PostPosted: Sun Sep 03, 2006 9:47 am    Post subject: Reply with quote

-Os = -O2 + small_size_where_appropriate
_________________
WEBSITE
Do not meddle with the affairs of Dragons, for you are crunchy and tasty with ketchup!
Back to top
View user's profile Send private message
Earthwings
Administrator
Administrator


Joined: 14 Apr 2003
Posts: 7750
Location: Karlsruhe, Germany

PostPosted: Sun Sep 03, 2006 9:54 am    Post subject: Reply with quote

Moved from Portage & Programming to Duplicate Threads. Too many topics like CFLAGS Central (Part 2) about this.
_________________
KDE 4.12 - Get It While It's Hot!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Duplicate Threads 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