xmllmx xmllmx - 23 days ago 10
C Question

Is it viable to mix two static libraries with different optimization levels?

I have two static libraries named

libx.a
and
liby.a
.

libx.a
is compiled with
gcc -g
; while
liby.a
is compiled with
gcc -O3
.

I want to link them two into a single executable.

Is it viable?

Is it harmful?

Answer

Yes, it is viable, it isn't harmful as long as the optimizations don't change the ABI (of function calls, or of floating point arithmetic/representation, etc.). Although even in those cases, I believe all necessary information is already compiled in or the linker resolves the issues.