Issues when building LLVM/clang from trunk

I have built LLVM/clang from trunk for many years. Since a few weeks back that is no longer possible. I end up with this error:

-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Using libunwind testing configuration: /big/llvm/libunwind/test/configs/
CMake Error at /big/llvm/libunwind/src/CMakeLists.txt:104 (message):
  Compiler doesn't support generation of unwind tables if exception support
  is disabled.  Building libunwind DSO with runtime dependency on C++ ABI
  library is not supported.

I have tried to start from scratch with a clean build directory but I end up with the same error.

I have tried to compile with both gcc and clang with the same result.

The cmake line I used (in my last attempt was):


Any hints on how to solve this?

-DLLVM_ENABLE_RUNTIMES=all is probably more than you want. Do you need to build libunwind and llvm-libc?

I have not included libc in the list passed to LLVM_ENABLE_PROJECTS.

Is building libunwind know to be broken in current trunk?

That’s true. But you enabled all runtimes including libunwind and llvm-libc.

Replaces all runtimes with only compiler-rt but this seems to be a non-working combination as well:

/usr/bin/ld: compiler-rt/lib/hwasan/CMakeFiles/RTHwasanAliases_dynamic.x86_64.dir/hwasan_linux.cpp.o: relocation R_X86_64_TPOFF32 against symbol `__hwasan_tls' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

The last time I tried to build I saw the following warning flash by:

[9/13] Performing configure step for 'runtimes'
Not searching for unused variables given on the command line.
CMake Warning at /big/llvm/llvm/cmake/modules/HandleLLVMOptions.cmake:281 (message):
  -fPIC is not supported.
Call Stack (most recent call first):
  /big/llvm/llvm/cmake/modules/HandleLLVMOptions.cmake:338 (add_flag_or_print_warning)
  CMakeLists.txt:159 (include)

I got it working by explicitly adding -DBUILD_SHARED_LIBS=OFF to the cmake command line.