Reputation: 570
I'm building some large project using GCC 4.4.2. Since I want to build it for release, I use -O1
GCC optimization flag, but unluckily it messes somehow with my code, and the final binaries do not work as expected, when building with -O0
flag (or no optimization) everything works fine.
I had a similar problem with my project before, in that time it was the -fstrict-aliasing
flag that caused troubles on -O2
optimization level, I managed to find that it was caused by that specific flag by making a search on all flags that are mentioned in this documentation, regarding the -O2
optimization level:
http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Optimize-Options.html
Now I tried to do the same with the list they mention regarding the -O1
flag, but unfortunately it seems that not all the flags mentioned, or there are some hidden flags being enabled, because when I compile with just -O1
flag or with just a list of the provided flags (without putting -O1
itself) I get different compilation results, and my binaries refuse to work only with the specific -O1
flag, so I can't find the exact troublemaking option.
Is it possible to know what hidden options the -O1
option includes, and how can I disable some of them?
Upvotes: 1
Views: 1822
Reputation: 36402
You can run gcc -Q -v
on a small C file to have GCC dump the options being used.
Run it with and without the -O1
option to get the difference between the enabled options.
Upvotes: 1