static-libgcc in multiple shared libraries

Cosmin Apreutesei cosmin.apreutesei@gmail.com
Mon Mar 30 23:08:00 GMT 2015


Hi,

My story happens on Linux (Ubuntu 10, glibc 2.11, gcc 4.9.2).

My main exe (LuaJIT) is build with -static-libgcc. It's not a C++
program but it knows how to catch C++ exceptions so it uses that part
of libgcc at least.

Multiple C (not C++) shared libraries are then loaded via dlopen().
They are all built with -static-libgcc too.

So far, good or no good? I mean is it ok to have multiple static
copies of libgcc in _multiple shared libraries_, and also in the main
exe?

Or is it better to link them all dynamically to libgcc (including the
main exe) and ship libgcc too with the app? My concern is, is there
global state in libgcc that needs to be _shared globally_ and does it
cause problems if it's duplicated like that?

----

Now for part 2 of the story. More shared libraries come in via
dlopen(). But this time they are C++ libraries linked _dynamically_ to
libstdc++ which itself is linked _dynamically_ to libgcc.

Good or no good? If no good, then would linking libstdc++ and libgcc
statically into these C++ libraries solve the no-goodness, or do I
have to go back to square one and link _everything_ dynamically to
libgcc?

----

Sorry for the many question marks, bit confused over here. Any help appreciated.



More information about the Gcc-help mailing list