abi compat

Jonathan Wakely jwakely.gcc@gmail.com
Wed Sep 17 23:15:00 GMT 2008


2008/9/17 Brendan Miller:
> What kind of ABI compatibility does libstdc++ guarantee? And over what
> versions and time frame?

See http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html

> If I have a shared c++ library its interface accepts stl objects like
> std::string as paramters what kind of problems should I be aware of?

As well as ensuring compatible versions of libstdc++.so and
libgcc_s.so are used at runtime, you should ensure that any compiler
switches that change the ABI are used consistently.

> Are common stl instantiations made in the stdlibc++ lib, and then the
> lib gives gcc hints not to instantiate again in executable code, or
> does every library that links against stdlibc++ usually end up with
> its own instantiations of all the common template types like
> std::string stdd::wstring, etc? Are there ever wierd situations where

For some types (std::string and some streams IIRC) libstdc++ use the
"extern template" extension described at
http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Template-Instantiation.html#Template-Instantiation

This means std:string is not instantiated in every file and is found
by the linker in libstdc++.so

> some code will be inlined into the client binary and some stored in
> the lib, and then version skew between the code inlined into the
> binary, and the code that's part of the library breaks things?

If you follow the ABI guidelines, that shouldn't happen.

Jonathan



More information about the Libstdc++ mailing list