Heinrich Heine
Heinrich Heine

Reputation: 303

Which flags are enabled by -O?

My application has some portability issues when compiled with the -O flag. I would like to find out which flag exactly triggers the problem, yet I am still unsuccessful.. I used all flags found in

gcc -c -Q -O --help=optimizers

but I still cannot reproduce the problem. Is it possible that the -O enables also additional flags?

Btw, the error I am getting is the following:

[Hein@Heinrich]$ ./parscons
./parscons: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ./parscons)
./parscons: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by ./parscons)

Upvotes: 0

Views: 305

Answers (1)

bentank
bentank

Reputation: 616

The list of flags enabled by gcc for -O can be found here - Optimize-Options

From the doc:

-O -O1 Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function. With -O, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time.

-O turns on the following optimization flags:

      -fauto-inc-dec 
      -fbranch-count-reg 
      -fcombine-stack-adjustments 
      -fcompare-elim 
      -fcprop-registers 
      -fdce 
      -fdefer-pop 
      -fdelayed-branch 
      -fdse 
      -fforward-propagate 
      -fguess-branch-probability 
      -fif-conversion2 
      -fif-conversion 
      -finline-functions-called-once 
      -fipa-pure-const 
      -fipa-profile 
      -fipa-reference 
      -fmerge-constants 
      -fmove-loop-invariants 
      -fshrink-wrap 
      -fsplit-wide-types 
      -ftree-bit-ccp 
      -ftree-ccp 
      -fssa-phiopt 
      -ftree-ch 
      -ftree-copy-prop 
      -ftree-copyrename 
      -ftree-dce 
      -ftree-dominator-opts 
      -ftree-dse 
      -ftree-forwprop 
      -ftree-fre 
      -ftree-phiprop 
      -ftree-sink 
      -ftree-slsr 
      -ftree-sra 
      -ftree-pta 
      -ftree-ter 
      -funit-at-a-time

-O also turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging.

Upvotes: 2

Related Questions