[BusyBox] Why is it so bad...?
Erik Andersen
andersen at lineo.com
Mon Jan 22 19:51:12 UTC 2001
On Mon Jan 22, 2001 at 02:21:16PM -0500, Tom Cameron wrote:
> Hello all,
> I was reading through the GCC man page, wondering what horrible
> things '-O3' did to code, so as to make most people shy away from it. I
> have compiled kernels and programs with this option (instead of -Os or -O2),
> and have had no problems. What is the difference between these options?
> What does -Os do? Has anyone run any performance/size/stability tests on
> each? anyone have comments? Let me know please, as this is quite
> interesting to me (performance is everything with the project I'm currently
> working on). Thanks in advance!
I use -Os by default for busybox, since that means "Optimize for size", which is
the whole point of busybox. Since you asked, I here quote from the gcc Manual.
Options That Control Optimization
These options control various sorts of optimizations:
-O
-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', the compiler only
allocates variables declared register 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
compiler turns on `-fthread-jumps' and `-fdefer-pop' on all machines. The
compiler turns on `-fdelayed-branch' on machines that have delay slots, and
`-fomit-frame-pointer' on machines that can support debugging even without a
frame pointer. On some machines the compiler also turns on other flags.
-O2
Optimize even more. GCC performs nearly all supported optimizations that do not
involve a space-speed tradeoff. The compiler does not perform loop unrolling or
function inlining when you specify `-O2'. As compared to `-O', this option
increases both compilation time and the performance of the generated code.
`-O2' turns on all optional optimizations except for loop unrolling, function
inlining, and register renaming. It also turns on the `-fforce-mem' option on
all machines and frame pointer elimination on machines where doing so does not
interfere with debugging.
-O3
Optimize yet more. `-O3' turns on all optimizations specified by `-O2' and also
turns on the `-finline-functions' and `-frename-registers' options.
-O0
Do not optimize.
-Os
Optimize for size. `-Os' enables all `-O2' optimizations that do not typically
increase code size. It also performs further optimizations designed to reduce
code size.
-Erik
--
Erik B. Andersen email: andersen at lineo.com
--This message was written using 73% post-consumer electrons--
More information about the busybox
mailing list