[llvm-dev] libc++ failed to link against musl

Dmitry Golovin via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 6 13:41:30 PDT 2017

Hi David,

Neither is the case. The system that I want to build with this toolchain is Linux-based, but not GNUish. I would like to use musl instead of glibc and libc++ instead of libstdc++, only use binutils provided by LLVM. I think that in that case I will link libc++abi and libunwind to libc++ statically, so I will not have to add -lunwind and -lc++abi to my LDFLAGS. Is it okay to do that? There is an experimental LIBCXX_ENABLE_STATIC_ABI_LIBRARY option, I will try to enable it.

The host system that I'm compiling on is Alpine Linux (musl-based distro), if it matters.


06.06.2017, 20:40, "David Chisnall" <david.chisnall at cl.cam.ac.uk>:
> On 5 Jun 2017, at 15:17, Jonathan Roelofs via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>  On 6/5/17 5:17 AM, Dmitry Golovin via llvm-dev wrote:
>>>  I'm trying to build LLVM, Clang, LLD, compiler-rt, libc++, libc++abi and libunwind with musl-based toolchain.
>>>  The configuration is the following:
>>>      CLANG_DEFAULT_RTLIB=compiler-rt
>>>      LLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl
>>>      LLVM_TARGET_ARCH=x86_64
>>>  When linking libc++.so there are a lot of undefined references to __cxa_allocate_exception, __cxa_begin_catch, __cxa_end_catch, __cxa_free_exception, __cxa_guard_abort, __cxa_guard_acquire, __cxa_guard_release, __cxa_pure_virtual, __cxa_rethrow, __cxa_throw, __gxx_personality_v0, _Unwind_Resume, vtable for __cxxabiv1::__class_type_info, vtable for __cxxabiv1::__si_class_type_info, vtable for __cxxabiv1::__vmi_class_type_info. The full output of the linking command is too long and is attached gzipped. The linking command is the following:
>>  Those symbols are from libc++abi, and it isn't on your link line.
> It depends on how you want to package libc++ whether you actually want to link to libc++abi. If you’re on a GNUish system, you almost certainly don’t, because you then won’t be able to combine libc++ and libstdc++ in the same binary. You want to add -lstdc++ to the link line (or, ideally, -lsupc++, if your distribution ships a separate libsupc++.so).
> On FreeBSD, we don’t link libc++ to any ABI library. Instead, both libc++.so and libstdc++.so are linker scripts that instruct anything that tries to link libc++ to link libc++.so.{version} and libcxxrt.so.{version}.
> David

More information about the llvm-dev mailing list