libc++ fails to link

Hi all,

I have LLVM + clang + clang extra tools + compiler-rt + libc++ checked
out as suggested by Clang - Getting Started

After configuring with

cmake -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_C_COMPILER=gcc \
  -DCMAKE_CXX_COMPILER=g++ \
  -DLLVM_INCLUDE_GO_TESTS=OFF \
  -DLLVM_TARGETS_TO_BUILD=X86 \
  ../llvm

and running "ninja all check-all" , I get a bunch of errors like:

projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o: In
function `std::__1::(anonymous
namespace)::__throw_runtime_error(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&)':
locale.cpp:(.text.unlikely._ZNSt3__112_GLOBAL__N_1L21__throw_runtime_errorERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+0xf):
undefined reference to `__cxa_allocate_exception'
locale.cpp:(.text.unlikely._ZNSt3__112_GLOBAL__N_1L21__throw_runtime_errorERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+0x33):
undefined reference to `__cxa_throw'
locale.cpp:(.text.unlikely._ZNSt3__112_GLOBAL__N_1L21__throw_runtime_errorERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE+0x3e):
undefined reference to `__cxa_free_exception'
projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o: In
function `std::__1::ctype_byname<wchar_t>::do_widen(char) const':
locale.cpp:(.text._ZNKSt3__112ctype_bynameIwE8do_widenEc+0x43):
undefined reference to `__cxa_call_unexpected'

(see the attachment)

This used to work 2-3 months ago ; the build would finish with the
unittests (of which five used to fail ; one got fixed since then).

Platform: Ubuntu 17.10
gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2)

Csaba

111v (159 KB)

The easiest way to fix this would be to also check out libc++abi. An alternative would be to configure libc++ to use an alternative ABI library (either -DLIBCXX_CXX_ABI=libstdc++ or -DLIBCXX_CXX_ABI=libsupc++ ought to work), but I think libc++abi is the simplest route to go.

Are you trying to compile libc++abi as well?