Setjmp
Setjmp

Reputation: 28392

How do I figure out what -O<num> options do in gcc?

I seem to remember being able to print out (or locate) the specific switches that each -O<num> option turns on. Can you remind?

Thanks!

Upvotes: 2

Views: 261

Answers (3)

Jonathan Leffler
Jonathan Leffler

Reputation: 755094

On many machines, 'info gcc' will produce a wealth of information. Using 'gcc -v --help' produced a very long listing of options from sub-processes (actually, 1001 lines on stdout, and 14 on stderr) on my Mac (PPC G4 and MacOS X 10.4.11).

Upvotes: 0

CesarB
CesarB

Reputation: 45595

The list of new features on gcc 4.3 shows a way to do it, via an extension to the --help command line option:

gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
diff /tmp/O2-opts /tmp/O3-opts | grep enabled

Note, however that I never tried that, only read about it. The documentation about this command line option is at http://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options

If you ever read the list of new features on gcc 4.3, perhaps this was what you were recalling.

Upvotes: 4

Federico A. Ramponi
Federico A. Ramponi

Reputation: 47105

You may also try the good ol' manual

$ man gcc

at the subsection "Options That Control Optimization".

Upvotes: 2

Related Questions