| Summary: | sys-libs/llvm-libunwind: Add new USE flags "default-compiler-rt" to use compiler-rt instead of libgcc & libgcc_s | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | 12101111 <w12101111> |
| Component: | Current packages | Assignee: | LLVM support project <llvm> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | 2046411367, ionen |
| Priority: | Normal | Keywords: | PullRequest |
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | Linux | ||
| See Also: | https://github.com/gentoo/gentoo/pull/22466 | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
|
Description
12101111
2021-02-16 05:38:31 UTC
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 |