[cfe-dev] -static-libstdc++ & libc++abi

Eric Fiselier via cfe-dev cfe-dev at lists.llvm.org
Fri Nov 18 02:21:55 PST 2016


> I initially started from configuration using "-DLIBCXX_ENABLE_SHARED=OFF
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON". Clang built with this configuration
can not produce binaries at all (see below). Clang with just "-
DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON" fails the same way when I use "
-static-libstdc++"

Ah my mistake. LIBCXX_ENABLE_STATIC_ABI_LIBRARY only works when building a
shared libc++ with a static libc++abi. It doesn't actually combine libc++
and libc++abi archives if they are both static. I guess I need to fix that,
or at least document it. It is possible to merge two static archives into
one
<http://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one>,
but

/Eric

On Thu, Nov 17, 2016 at 10:03 PM, Michał Górny <mgorny at gentoo.org> wrote:

> On Thu, 17 Nov 2016 21:00:27 -0700
> Eric Fiselier via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> > On Thu, Nov 17, 2016 at 5:20 PM, Mike Aizatsky via cfe-dev <
> > cfe-dev at lists.llvm.org> wrote:
> >
> > > Hello!
> > >
> > > I've recently encountered a bug (https://llvm.org/bugs/show_
> > > bug.cgi?id=30919) and I would like an advice on how to approach it.
> > >
> > > It seems that right now libc++abi is not handled by Tools.cpp. Normal
> > > linking works  because:
> > >
> > > $ cat ~/out/llvm/default/lib/libc++.so
> > > INPUT(libc++.so.1 -lc++abi)
> > >
> > > And if I use -static-libstdc++ then c++abi is not automatically linked
> in
> > > at all.
> > >
> > > Is there a similar magic for .a files like for .so? Should Tools.cpp
> know
> > > about lc++abi? Are there any alternatives?
> > >
> >
> > First, Tools.cpp shouldn't know about libc++abi/libsupc++/libcxxrt or w/e
> > C++ ABI library your STL is using.
> >
> > There are two alternatives to your problem.  If you want to use a static
> > libc++abi you can build libc++ with LIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
> > <http://libcxx.llvm.org/docs/BuildingLibcxx.html#cmdoption-
> arg-LIBCXX_ENABLE_STATIC_ABI_LIBRARY>
> > .
> > Alternatively you can define libc++.a as a linker script just like
> > libc++.so. (Ex INPUT(libc++static.a -lc++abi))
>
> I had adding support for static linker scripts somewhere in my TODO.
> However, I'm not sure if I will proceed with it anytime soon since
> touching anything linking-related turns out being a huge can of worms,
> and Eric ends up having to fix my mistakes ;-).
>
> --
> Best regards,
> Michał Górny
> <http://dev.gentoo.org/~mgorny/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161118/05282dea/attachment.html>


More information about the cfe-dev mailing list