There is a CMake option LIBUNWIND_USE_COMPILER_RT in llvm libunwind: option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) The default value is OFF, and the library will depend on libgcc_s.so from gcc (if gcc is installed): > lddtree /usr/lib/libunwind.so.1.0 libunwind.so.1.0 => /usr/lib/libunwind.so.1.0 (interpreter => none) libc.so => /usr/lib/libc.so libgcc_s.so.1 => /usr/lib/gcc/x86_64-gentoo-linux-musl/10.2.0/libgcc_s.so.1 Turning on this option will get a library don't need libgcc_s.so: > lddtree /usr/lib/libunwind.so.1.0 libunwind.so.1.0 => /usr/lib/libunwind.so.1.0 (interpreter => none) libc.so => /usr/lib/libc.so Reproducible: Always
Clang is a dependency of llvm-libunwind, so if you're already using default-compiler-rt with Clang, it will build llvm-libunwind with compiler-rt. First Clang gets pulled in, then builds compiler-rt, then Clang builds llvm-libunwind with compiler-rt. After, you'll need to rebuild Clang (and LLVM) which will link the rest of the toolchain to compiler-rt, llvm-libunwind, libcxxabi, and libcxx. It's not really necessary to flip the CMAKE option, as default-compiler-rt via Clang will already build it that way.
I have upgraded LLVM to 13.0, and it's still trying to link libgcc_s.so In line 64 of CMakeLists.txt: option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) LIBUNWIND_USE_COMPILER_RT is default to OFF In line 10 of cmake/config-ix.cmake if (NOT LIBUNWIND_USE_COMPILER_RT) if (ANDROID) check_library_exists(gcc __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_LIB) else () check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB) check_library_exists(gcc __absvdi2 "" LIBUNWIND_HAS_GCC_LIB) endif () endif() So if libgcc_s is indeed exist, LIBUNWIND_HAS_GCC_S_LIB is TRUE, and it will show in log: -- Looking for __gcc_personality_v0 in gcc_s -- Looking for __gcc_personality_v0 in gcc_s - found -- Looking for __absvdi2 in gcc -- Looking for __absvdi2 in gcc - not found Then in line 42 of cmake/config-ix.cmake if (LIBUNWIND_USE_COMPILER_RT) find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY) list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBUNWIND_BUILTINS_LIBRARY}") else () if (LIBUNWIND_HAS_GCC_S_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s) endif () if (LIBUNWIND_HAS_GCC_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES gcc) endif () endif () gcc_s will be added to CMAKE_REQUIRED_LIBRARIES In the generated build.ninja file: build lib/libunwind.so.1.0: C_SHARED_LIBRARY_LINKER__unwind_shared_ src/CMakeFiles/unwind_shared.dir/libunwind.cpp.o src/CMakeFiles/unwind_shared.dir/Unwind-EHABI.cpp.o src/CMakeFiles/unwind_shared.dir/Unwind-seh.cpp.o src/CMakeFiles/unwind_shared.dir/UnwindLevel1.c.o src/CMakeFiles/unwind_shared.dir/UnwindLevel1-gcc-ext.c.o src/CMakeFiles/unwind_shared.dir/Unwind-sjlj.c.o src/CMakeFiles/unwind_shared.dir/UnwindRegistersRestore.S.o src/CMakeFiles/unwind_shared.dir/UnwindRegistersSave.S.o LANGUAGE_COMPILE_FLAGS = --target=x86_64-unknown-linux-gnu LINK_FLAGS = --target=x86_64-unknown-linux-gnu -nostdlib++ LINK_LIBRARIES = -lc -lgcc_s -ldl -lpthread OBJECT_DIR = src/CMakeFiles/unwind_shared.dir POST_BUILD = : PRE_LINK = : SONAME = libunwind.so.1 SONAME_FLAG = -Wl,-soname, TARGET_COMPILE_PDB = src/CMakeFiles/unwind_shared.dir/ TARGET_FILE = lib/libunwind.so.1.0 TARGET_PDB = lib/libunwind.pdb My clang is build with default-compiler-rt, but the check don't even run clang. It's implemented by check_library_exists. > eix -e sys-devel/clang [I] sys-devel/clang Available versions: (10) 10.0.1^t (11) 11.1.0(11/11.1)^t (12) 12.0.1^t (13) [m]**13.0.0_rc1^t[1] (~)13.0.0^t **13.0.0.9999*l^t (14) **14.0.0.9999*l^t {debug default-compiler-rt default-libcxx default-lld doc llvm-libunwind +static-analyzer test xml ABI_MIPS="n32 n64 o32" ABI_S390="32 64" ABI_X86="32 64 x32" KERNEL="FreeBSD" LLVM_TARGETS="AArch64 AMDGPU ARC ARM AVR BPF CSKY Hexagon Lanai M68k MSP430 Mips NVPTX PowerPC RISCV Sparc SystemZ VE WebAssembly X86 XCore" PYTHON_SINGLE_TARGET="python3_8 python3_9 python3_10"} Installed versions: 12.0.1(12)^t(02:26:40 07/10/21)(default-compiler-rt default-libcxx default-lld llvm-libunwind static-analyzer xml -debug -doc -test ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="64 -32 -x32" KERNEL="-FreeBSD" LLVM_TARGETS="AArch64 AMDGPU ARM AVR BPF Hexagon Lanai MSP430 Mips NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore -ARC -CSKY -VE" PYTHON_SINGLE_TARGET="python3_9 -python3_8 -python3_10") 13.0.0(13)^t(21:05:06 10/02/21)(default-compiler-rt default-libcxx default-lld llvm-libunwind static-analyzer xml -debug -doc -test ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="64 -32 -x32" KERNEL="-FreeBSD" LLVM_TARGETS="AArch64 AMDGPU ARM AVR BPF Hexagon Lanai MSP430 Mips NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore -ARC -CSKY -M68k -VE" PYTHON_SINGLE_TARGET="python3_9 -python3_8 -python3_10") Homepage: https://llvm.org/ Description: C language family frontend for LLVM
It seems the bug I mention here isn't fixed: https://github.com/gentoo/gentoo/pull/21516#issuecomment-877667471 I will file a fix for this.
(In reply to 12101111 from comment #2) > I have upgraded LLVM to 13.0, and it's still trying to link libgcc_s.so I have no problems here and built the libraries exactly as I stated above. No modifications to the ebuilds, either. libgcc_s.so is not linked at all, not to any of my LLVM binaries or libraries. lddtree /usr/lib64/libunwind.so libunwind.so => /usr/lib64/libunwind.so (interpreter => none) libc.so.6 => /lib64/libc.so.6 ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 libdl.so.2 => /lib64/libdl.so.2 libpthread.so.0 => /lib64/libpthread.so.0 This is exactly how it shows up in my system. As you can see, if it was linked against libgcc_s it would show here.
fixed in 9f18b96e61c62b489b27a46edce06df038d719d3