0

It is widely documented, mostly for Windows, that one should never mix a debug and release mode with static library or non ABI libraries in general. Among the reason cited, there is a couple of macro definitions, various optimizations, that could trigger weird compilation behaviour and unmatching symbols.

Now, in Linux with Gcc or Clang, what are the options that may break the compatibility? I guess it is not "-g" as it is used in release mode with debug informations.

And is there some "-O1" with "-O2" mixes that are allowed?

Emile D.
  • 602
  • 2
  • 11
  • 20
  • You can specify in gcc on function/method level which optimization level to use: https://stackoverflow.com/questions/2219829/how-to-prevent-gcc-optimizing-some-statements-in-c – RoQuOTriX Feb 13 '20 at 08:45
  • That is a very good information to know. So it is possible to mix the optimization level inside a library then! There is more flexibility than I thought! However, my question was more on a broader sense. Is it possible to use lib with -O2 optimization while compiling in -O0? If not, when does it break? Is -O0 and -O1 ok? Etc. – Emile D. Feb 13 '20 at 08:56
  • I think it doesn't matter on which optimization level a lib is build. Try it out. Compile a lib with -O2 and link it to a executable with -O0. It should work. But you cannot really debug any call into the library – RoQuOTriX Feb 13 '20 at 09:09

0 Answers0