Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
make.conf says -O3 but kernel compiles with -O2
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Biker
Apprentice
Apprentice


Joined: 11 Jun 2003
Posts: 170
Location: A very dark, cold and moisty place...

PostPosted: Thu Jun 19, 2003 6:34 pm    Post subject: make.conf says -O3 but kernel compiles with -O2 Reply with quote

My CFLAGS in make.conf contains "-O3". The full bootstrap process compiled with "-O3".

Still, the kernel compile insists on using "-O2".

'tis "working as designed"?

If so, why?

If not, how do I correct this?

Gus
Back to top
View user's profile Send private message
dberkholz
Retired Dev
Retired Dev


Joined: 18 Mar 2003
Posts: 1008
Location: Minneapolis, MN, USA

PostPosted: Thu Jun 19, 2003 8:00 pm    Post subject: Reply with quote

The kernel has its own set of CFLAGS.
/usr/src/linux/Makefile wrote:
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
Back to top
View user's profile Send private message
DrkPlague
Tux's lil' helper
Tux's lil' helper


Joined: 04 Jun 2003
Posts: 107

PostPosted: Thu Jun 19, 2003 9:16 pm    Post subject: Reply with quote

this is done for a reason. certain things such as the kernal and heavily used libs like glibc specify their own cflags to achieve what they consider to be optimal performance.

Also, i am pretty sure that specifying -O3 on kernel would prevent ANY debugging of programs, which is probably a bad idea. my advice is that the flags were put there for a reason and unless you are a kernel dev, don't touch them.
_________________
DKP

There are 10 kinds of people in the world:
Those who understand binary and those who don't...
Back to top
View user's profile Send private message
qubex
Tux's lil' helper
Tux's lil' helper


Joined: 06 Mar 2003
Posts: 133
Location: Portland

PostPosted: Fri Jun 20, 2003 11:16 am    Post subject: Reply with quote

Yeah, messing with kernel optimizations is bad, m'kay? If you try and optimize your kernel with -O3, you're bad, m'kay? :roll:

Seriously though, your kernel is the foundation of your system - why mess with it's stability? How's that stupid christian children's song go - the wise man built his house upon the mid optimized but quick and rock solid kernel, the foolish man built his house upon a highly optimized but memory-leaky and flaky kernel. Wait - maybe it doesn't go like that.. But then again, I'm not a christian (and I think you get the point.)

And -O3 *shouldn't* stop you from debugging, that's generally in the hands of -fomit-frame-pointer, but I could be wrong in this case.

M
Back to top
View user's profile Send private message
DigitalP1mp
Tux's lil' helper
Tux's lil' helper


Joined: 13 Jun 2003
Posts: 97
Location: USA

PostPosted: Fri Jun 20, 2003 1:16 pm    Post subject: What's it all mean Bazil? Reply with quote

What's the -02 and the -03 all about. I'm at the point where I need to set my flags now and want to set them correctly. I have an AMD k-6-2 with a 400 mhZ processor.
_________________
Where's the any key?
Back to top
View user's profile Send private message
bsolar
Bodhisattva
Bodhisattva


Joined: 12 Jan 2003
Posts: 2764

PostPosted: Fri Jun 20, 2003 1:24 pm    Post subject: Re: What's it all mean Bazil? Reply with quote

DigitalP1mp wrote:
What's the -02 and the -03 all about. I'm at the point where I need to set my flags now and want to set them correctly. I have an AMD k-6-2 with a 400 mhZ processor.

First of all, is -O[n], big, fat, "o", NOT a "zero".

Basically they specify the optimization level, more infos in various threads in these forums, man gcc or google.

About your system, I suggest to here. There is also a script that attemps to identify the adeguate CFLAGS for your system if you want to try. :wink:

BTW since this is unrelated with the topic, start a new thread and even better search before, there are a lot of threads about CFLAGS. :wink:
_________________
I may not agree with what you say, but I'll defend to the death your right to say it.
Back to top
View user's profile Send private message
darket
n00b
n00b


Joined: 19 Mar 2003
Posts: 43

PostPosted: Fri Jun 20, 2003 1:25 pm    Post subject: Reply with quote

the kernel might be using O2 instead of O3 because O3 increases the size of the binary, AFAIK. Or I'm completely off ;-)

For the K6-2: I would use -Os, because that uses all optimizations from O2 without a few to get a small binary - which appears to be better, because of the small on-die cache (L1 only) and the rather slow onboard-L2-Cache. Apart from that, look there:
http://www.freehackers.org/gentoo/gccflags/flag_gcc3.html
Back to top
View user's profile Send private message
DrkPlague
Tux's lil' helper
Tux's lil' helper


Joined: 04 Jun 2003
Posts: 107

PostPosted: Fri Jun 20, 2003 7:08 pm    Post subject: Reply with quote

yes -fomit-frame-pointer completely kills debugging, but -finline-functions (added by -O3) on the kernel and glibc REALLY reak havok on debugging since most function calls made to the kernel or glibc are near impossible to trace.

For those who don't understand what -O does, here it is strait from the horses mouth:
man gcc wrote:
-O1
Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function.

Without `-O ', the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code.
Without `-O ', only variables declared register are allocated in registers. The resulting compiled code is a little worse than produced by PCC without `-O '.
With `-O ', the compiler tries to reduce code size and execution time.
When you specify `-O ', the two options `-fthread-jumps ' and `-fdefer-pop ' are turned on. On machines that have delay slots, the `-fdelayed-branch ' option is turned on. For those machines that can support debugging even without a frame pointer, the `-fomit-frame-pointer ' option is turned on. On some machines other flags may also be turned on.

-O2
Optimize even more. Nearly all supported optimizations that do not involve a space-speed tradeoff are performed. Loop unrolling and function inlining are not done, for example. As compared to -O , this option increases both compilation time and the performance of the generated code.
-O3
Optimize yet more. This turns on everything -O2 does, along with also turning on -finline-functions.

_________________
DKP

There are 10 kinds of people in the world:
Those who understand binary and those who don't...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo 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