[cfe-dev] [RFC][libcxx] Fixing "-stdlib=libc++ -lc++abi" on Linux -- Exporting libc++abi through libc++.so.

David Chisnall via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 12 04:19:32 PDT 2015


On 12 Oct 2015, at 00:58, Eric Fiselier via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> This approach is how FreeBSD ships their systems libc++. OS X take a
> slightly different approach which uses also uses a shared ABI library.
> It works by re-exporting libc++abi's symbols into libc++.dylib at
> build time using the "-reexported_symbols_list" linker flag.

This is how FreeBSD ships libc++ (except that we use libcxxrt, not libc++abi), but it will cause problems on Linux unless you *also* change the way that libstdc++ is shipped.

Libstdc++ statically links libsupc++ (the GNU equivalent of libcxxrt / libc++abi) and this has an impact on symbol versioning.  If something links to both libstdc++ with libsupc++ and libc++ with libc++abi then the ABI symbols will be distinct.  Throwing an exception in code using one and catching it in the other will break in difficult-to-diagnose ways.

We addressed this by linking libstdc++ as a filter library against libsupc++ then against libcxxrt.  Libraries linking libstdc++ see the ABI symbols as having come from libstdc++, when in reality they are provided by libcxxrt.  This allows interoperability.

If you can not modify the linkage of libstdc++ on your target platform, then the best solution is to use libstdc++ itself as the ABI library.

David




More information about the cfe-dev mailing list