Since Clang9, a new option has been introduced: the usage of a default libunwind library (being those values: none, libgcc and libunwind) being the default none. The problem is that when enabling default-compiler-rt, in C{,XX}FLAGS it is needed to be added "--unwindlib=libunwind" (or libgcc) and this flag is often filtered out by some ebuilds, causing linkage failures (undefined symbol Unwind_Resume, for example) Furthermore, in order to get rid of gcc_s if compiler-rt is selected as default, llvm-libunwind must be used instead of libunwind (tested, and currently libunwind gives undefined references to __register_frame and friends, which llvm-libunwind exports but libunwind seems not) I tested in a local repository modifying the ebuild so when default-compiler-rt is selected, llvm-libunwind is brought as a dep, and also a default CMake variable is set (adding the modifying ebuild as attachment). Whether I am not sure that this is the best way to aproach this missing option in current ebuild, I think it is fair to be considered for some action in this direction. Reproducible: Always
Created attachment 598940 [details] clang ebuild Modified ebuild to handle libunwind default
Created attachment 598950 [details, diff] Current ebuild diff Current ebuild diff
Also, further test seems needed, as it reaches out of my knowledge, because in my test on a stage3 chrooted, when emerging -e world I am getting extraneous SIGSEGV, leading to even a broken gcc.
Unwind linking issues are fixed for me too when applying the diff attached to the latest Clang ebuilds. Perhaps compiler-rt SIGSEGV issues should be a different bug, but I experience the same with at least media-gfx/qview::guru https://github.com/jurplel/qView/issues/395
can you maybe not force abi_x86_32 on amd64 multilib? I only need multilib llvm for media-libs/mesa[llvm] and wine-vanilla subsequently. Or are there any clang related libs (libclang.so?) which will be forced to be build in abi_x86_32 on amd64 multilib with these changes commited?
Only sys-devel/clang-runtime and the deps: - sys-libs/libcxxabi - sys-libs/libcxx - sys-libs/libomp - sys-libs/llvm-libunwind are forced abi_x86_32, not sys-devel/llvm or sys-devel/clang, so no big compile times.
I think that __register_frame and __deregister_frame are used so rarely that, instead of forcing sys-libs/llvm-libunwind for default-compiler-rt, it is possible to support both libunwind implementations and add package-specific workarounds where __register_frame and __deregister_frame are actually used. For some months, I have been using similar patch but with llvm-libunwind USE flag to select between sys-libs/llvm-libunwind and sys-libs/libunwind: > --- sys-devel/clang/clang-11.1.0.ebuild > +++ sys-devel/clang/clang-11.1.0.ebuild > @@ -24,7 +24,7 @@ > SLOT="$(ver_cut 1)/$(ver_cut 1-2)" > KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86 ~amd64-linux ~x64-macos" > IUSE="debug default-compiler-rt default-libcxx default-lld > - doc +static-analyzer test xml kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}" > + doc llvm-libunwind +static-analyzer test xml kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}" > REQUIRED_USE="${PYTHON_REQUIRED_USE} > || ( ${ALL_LLVM_TARGETS[*]} )" > RESTRICT="!test? ( test )" > @@ -52,7 +52,11 @@ > PDEPEND=" > sys-devel/clang-common > ~sys-devel/clang-runtime-${PV} > - default-compiler-rt? ( =sys-libs/compiler-rt-${PV%_*}* ) > + default-compiler-rt? ( > + =sys-libs/compiler-rt-${PV%_*}* > + llvm-libunwind? ( =sys-libs/llvm-libunwind-${PV%_*}* ) > + !llvm-libunwind? ( sys-libs/libunwind ) > + ) > default-libcxx? ( >=sys-libs/libcxx-${PV} ) > default-lld? ( sys-devel/lld )" > > @@ -77,6 +81,7 @@ > # multilib clang* libraries (not runtime, not wrappers). > > PATCHES=( > + "${FILESDIR}"/11.0.0/clang-libunwind-as-needed.patch > "${FILESDIR}"/9999/prefix-dirs.patch > ) > > @@ -263,6 +268,7 @@ > # override default stdlib and rtlib > -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "") > -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "") > + -DCLANG_DEFAULT_UNWINDLIB=$(usex default-compiler-rt libunwind "") > -DCLANG_DEFAULT_LINKER=$(usex default-lld lld "") > > -DCLANG_ENABLE_ARCMT=$(usex static-analyzer)
Created attachment 689727 [details, diff] 11.0.0/clang-libunwind-as-needed.patch
Regarding forcing of abi_x86_32, it may be possible to create llvm subprofiles and force abi_x86_32 for these packagess only in these subprofiles.
Latest version of PR depends on either sys-libs/llvm-libunwind (first preference) or sys-libs/libunwind
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=297becbde98426212589bfff287eb05ae8bbf40f commit 297becbde98426212589bfff287eb05ae8bbf40f Author: Theo Anderson <telans@posteo.de> AuthorDate: 2021-04-10 23:37:57 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2021-06-10 20:19:52 +0000 sys-devel/clang: support default unwindlib Closes: https://bugs.gentoo.org/702344 Closes: https://bugs.gentoo.org/722978 Signed-off-by: Theo Anderson <telans@posteo.de> Closes: https://github.com/gentoo/gentoo/pull/19793 Signed-off-by: Michał Górny <mgorny@gentoo.org> sys-devel/clang/clang-12.0.0-r1.ebuild | 9 +++++++-- sys-devel/clang/clang-12.0.1.9999.ebuild | 9 +++++++-- sys-devel/clang/clang-12.0.1_rc1.ebuild | 9 +++++++-- sys-devel/clang/clang-13.0.0.9999.ebuild | 9 +++++++-- 4 files changed, 28 insertions(+), 8 deletions(-)