Reputation: 979
Anyone has any ideas which will take preference if -O2 and -O0 is specified in the command line for gcc? I have some legacy code that gets configuration from multiple places....
Upvotes: 2
Views: 434
Reputation: 80031
λ > g++ outer.cxx -O2 -Os -o outer
λ > sha1sum outer
c3f62ab60393266388a8a7fb2d204d4b1f9dc145 outer
λ > g++ outer.cxx -Os -O2 -o outer
λ > sha1sum outer
355052e82d0146a185c8a1b845c7ed6db18087f1 outer
λ > g++ outer.cxx -O2 -o outer
λ > sha1sum outer
355052e82d0146a185c8a1b845c7ed6db18087f1 outer
λ > g++ outer.cxx -Os -o outer
λ > sha1sum outer
c3f62ab60393266388a8a7fb2d204d4b1f9dc145 outer
The last specified optimization flag wins.
Upvotes: 3
Reputation: 112414
Last flag wins. That lets them be overridden in a makefile.
Upvotes: 4