This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: GCC compatibility of shared libraries with STL objects in their interface
- From: Robert Fanner <robert dot fanner at gmail dot com>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Mon, 30 Nov 2015 09:23:46 +0200
- Subject: Re: GCC compatibility of shared libraries with STL objects in their interface
- Authentication-results: sourceware.org; auth=none
- References: <CAHiLU9sktv761ETt2BirL_9iuDVyX+36QXowtWKu0E1B0eMEYQ at mail dot gmail dot com> <CAH6eHdRY2n4QXqMp4jDr2gCxiVECi4Cpsk=Dx78+wRnLu-3N0w at mail dot gmail dot com>
Thanks - that's great to know!
Is there more documentation somewhere with respect to how you've gone
about achieving the high degree of ABI stability (e.g. making sure
things are inlined/not inlined, data members don't change, memory
layout stays the same, inheritance doesn't change, etc)? I'd really
like to learn more.
Kind Regards,
Rob
On Mon, Nov 30, 2015 at 2:23 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 29 November 2015 at 21:19, Robert Fanner wrote:
>> So, I'm curious about what the case will be with respect to the STL
>> classes used as part of the plug-in interface. Can I safely pass STL
>> objects between shared objects that weren't compiled with the same
>> compiler version (e.g. 4.1 and 4.8)? And is there anything I need to
>> be mindful of with regards to how templates are compiled and resolved
>> if people use different compiler options?
>
> In general no, but it depends which options you're talking about.
>
> If you use -fshort-wchar then you change the ABI, but if you do that
> then libstdc++.so won't work properly unless you recompile it anyway.
> Barring ABI-changing options, the library ABI is stable. It doesn't
> matter whether you use it internally to a DSO or in the interface, the
> library ABI is stable.
>
>
>> I suspect it'll be problematic. However, there's a chance the symbol
>> versioning magic done by the GCC folks might somehow make this work.
>
> The library ABI is stable and so everything should be fully backwards
> compatible.
>
> The only real caveat is that GCC 5.1 introduced a new ABI for some
> types (std::list and std::string and anything that depends on
> std::string), but the old ABI is still fully supported and present in
> the DSO, so objects compiled with GCC 4.x still work with the
> libstdc++.so from GCC 5.x, see
> https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
> for more details.
>
>> For this question, I am only interested in pre-C++11 compilation and
>> linking. I am also only interested in Linux and Mac OS X, using GCC.
>
> In general C++11 doesn't change anything, the library ABI doesn't
> depend on the -std option.