Hello,
I am attempting to create a bootstrapping build of LLVM with clang, compiler-rt, libcxx, libcxxabi, and libunwind. I am performing this build in an unorthodox sandbox environment, and intend to use the resulting toolchain in the same environment, so need to create as self-contained and relocatable a toolchain as possible.
I have succeeded in producing a toolchain using the 17.0.6 source using these compiler flags:
cmake \
-S /path/to/llvm \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCLANG_ENABLE_BOOTSTRAP=ON \
-DCLANG_DEFAULT_CXX_STDLIB=libc++ \
-DCLANG_DEFAULT_RTLIB=compiler-rt \
-DLIBCXX_USE_COMPILER_RT=YES \
-DLIBCXXABI_USE_COMPILER_RT=YES \
-DLIBCXXABI_USE_LLVM_UNWINDER=YES \
-DBOOTSTRAP_CMAKE_BUILD_TYPE=Release \
-DBOOTSTRAP_CLANG_DEFAULT_CXX_STDLIB=libc++ \
-DBOOTSTRAP_CLANG_DEFAULT_RTLIB=compiler-rt \
-DBOOTSTRAP_LIBCXX_USE_COMPILER_RT=YES \
-DBOOTSTRAP_LIBCXXABI_USE_COMPILER_RT=YES \
-DBOOTSTRAP_LIBCXXABI_USE_LLVM_UNWINDER=YES \
-DBOOTSTRAP_LLVM_USE_LINKER=lld \
-DLIBUNWIND_USE_COMPILER_RT=YES \
-DBOOTSTRAP_LIBUNWIND_USE_COMPILER_RT=YES \
-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lld;lldb' \
-DLLVM_ENABLE_RUNTIMES='compiler-rt;libcxx;libcxxabi;libunwind' \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_EH=ON \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
-DDEFAULT_SYSROOT=/path/to/glibc/sysroot
I can successfully compile some basic programs with the resulting clang
and clang++
with -fuse-ld=lld
. However, with clang++
, I must explicitly include -lunwind
to compile a “hello world” program. Am I missing some configuration that would make this additional linker flag unnecessary?