16

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.

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. Commented Aug 3, 2010 at 20:35
  • 3
    But the answer is the same for everything at least up to 4.4 Commented Aug 3, 2010 at 20:47
  • Might be a leftover from the PGCC days which supported everything up to -O9. Commented Aug 5, 2010 at 8:10

2 Answers 2

27

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

Sign up to request clarification or add additional context in comments.

3 Comments

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.
Is this still relevant as of gcc 5.3.0?
22

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.