I am using the following commands to build runtimes.
$ cmake \ -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=<install-path> \ -DLLVM_ENABLE_ASSERTIONS=OFF \ -DCOMPILER_RT_USE_LIBCXX=ON \ -DLLVM_TARGETS_TO_BUILD=X86 \ '-DLLVM_RUNTIME_TARGETS=x86_64-unknown-linux-gnu;i386-unknown-linux-gnu' \ '-DLLVM_ENABLE_PROJECTS=clang;lld' \ '-DLLVM_ENABLE_RUNTIMES=compiler-rt;libcxx;libcxxabi;libunwind' \ '-DCMAKE_CXX_FLAGS=-stdlib=libc++' \ '-DCMAKE_EXE_LINKER_FLAGS=-rtlib=compiler-rt' \ '-DCMAKE_SHARED_LINKER_FLAGS=-rtlib=compiler-rt' \ '-DCMAKE_MODULE_LINKER_FLAGS=-rtlib=compiler-rt' \ -DCMAKE_CXX_COMPILER=<path-to-clang++> \ -DCMAKE_C_COMPILER=<path-to-clang> \ -S <source-dir> \ -B build $ ninja -C build runtimes
But the build fails with errors in various C++ files under compiler-rt (e.g.
clang++ (which happens to be the clang++ that was just built) uses the system
libstdc++ which is very old and does not support C++14.
You may notice that I have added
CMAKE_CXX_FLAGS and also tried
-DCOMPILER_RT_USE_LIBCXX but they don’t help. But when I manually add
build.ninja, the files failing to compile go through.
What cmake configuration option can I use to make clang use libc++? The clang installation that I used to build LLVM and the new clang also contains libc++ but that is not what ends up getting used when building runtimes.
Or here is a more general question. What are the proper steps for creating a self-contained
I used to be able to do this before (e.g. version 11.0.0) but the recent changes to building
libunwind have broken my build scripts. I have tried to follow these instructions but they don’t work because the system
libstdc++ is old and the newly built clang picks it up instead of
libc++ (that was just built) when building the C++ sources under compiler-rt.
Previously, it used to work because the clang that I provide with
-DCMAKE_CXX_COMPILER was used to build everything the first time around.