15

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!

3
  • 4
    gcc 3.2.3 is positively archaic. Since then, the developers have released gcc 3.3, 3.4, 4.0, 4.1, 4.2, 4.3, 4.4, and 4.5. You should really use a more current release. Aug 3, 2010 at 20:35
  • 3
    But the answer is the same for everything at least up to 4.4
    – tstenner
    Aug 3, 2010 at 20:47
  • Might be a leftover from the PGCC days which supported everything up to -O9. Aug 5, 2010 at 8:10

2 Answers 2

25

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

3
  • 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?
    – naumcho
    Aug 4, 2010 at 19:36
  • Some build systems insert the compiler settings into the binary, but there's no easy, generic way.
    – tstenner
    Aug 4, 2010 at 19:48
  • Is this still relevant as of gcc 5.3.0?
    – ZN13
    Mar 11, 2016 at 13:38
21

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.