I am trying to compile a opensource component from source code. I am compiling all C files in that component using gcc
command.
When I pass options in order -O2 -Os
, binary is in few KB's. But when I pass options in order -Os -O2
binary size is large.
I do know that order matter in case of including sub-directories or Linking libraries in gcc
command.
Why order matters for optimization arguments of gcc
command ?
I am using gcc version 4.9.1.
Because it's just using the last1 option it sees.
1. From the man page: If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.