This should be possible (at least you could try) since recent GCC provides a parameter specific function . You can try adding something like
#pragma GCC optimize ("-fstrict-aliasing")
in front of your overlay functions and put
#pragma GCC reset_options
after them.
Maybe you need to wrap them
#if __GNUC__ >= 4
and of course some #endif
Alternatively, use constructor tricks (e.g. autoconf , cmake or the complex GNU make 4.0 rule, etc.) to define your own HAVE_GENUINE_GCC as 1 for genuine GCC only , and your own HAVE_GENUINE_CLANG as 1 for genuine Clang / LLVM compiler etc. Or, perhaps find that the pragmas above are understood in some sample code, and then define HAVE_WORKING_PRAGMA_GCC_OPTIMIZE as 1.
BTW, at least according to GCC, -flto does not store the program source representation in object files, but only a generalized form of some GCC internal representations (such as Gimple, etc.) obtained when compiling your source code. This is completely different!
PS. I have not tried, so perhaps this is not so simple.
Basile starynkevitch
source share