views:

147

answers:

2

What's the meaning of the -O4 optimization flag in gcc (3.2.3)? What's the difference to O3? When would you use one vs. the other?

The man pages only mention O, O0-3, Os, no word of the mysterious O4. Thanks!

+6  A: 

There is no -O4 in 3.2.3. Everything above -O3 results in -O3 being chosen.

tstenner
Ok that would explain it. Would you happen to know if I can tell what O flag was used when something was compiled if I have the binary?
Some build systems insert the compiler settings into the binary, but there's no easy, generic way.
tstenner
+3  A: 

You can check what optimization are enabled for each level

gcc -c -Q -O3 --help=optimizers | grep enabled

It works at least for gcc 4.4.

Lukasz Stelmach
Doesn't work with 4.1.2, but that's handy to know!
bstpierre
Works with 4.3.2, thanks for the tip.
Matthieu M.