Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 702344 - >sys-devel/clang-9 - add support for default libunwind library (none|libgcc|libunwind)
Summary: >sys-devel/clang-9 - add support for default libunwind library (none|libgcc|l...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords: EBUILD, PullRequest
Depends on:
Blocks:
 
Reported: 2019-12-09 14:42 UTC by David Carlos Manuelda
Modified: 2021-06-10 20:19 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
clang ebuild (clang-9.0.1_rc2.ebuild,8.41 KB, text/plain)
2019-12-09 14:43 UTC, David Carlos Manuelda
Details
Current ebuild diff (ebuild-diff.diff,1.00 KB, patch)
2019-12-09 15:32 UTC, David Carlos Manuelda
Details | Diff
11.0.0/clang-libunwind-as-needed.patch (clang-libunwind-as-needed.patch,498 bytes, patch)
2021-03-07 03:24 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Carlos Manuelda 2019-12-09 14:42:34 UTC
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
Comment 1 David Carlos Manuelda 2019-12-09 14:43:28 UTC
Created attachment 598940 [details]
clang ebuild

Modified ebuild to handle libunwind default
Comment 2 David Carlos Manuelda 2019-12-09 15:32:05 UTC
Created attachment 598950 [details, diff]
Current ebuild diff

Current ebuild diff
Comment 3 David Carlos Manuelda 2019-12-09 17:58:00 UTC
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.
Comment 4 James Beddek 2021-03-03 02:43:00 UTC
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
Comment 5 tt_1 2021-03-06 13:19:12 UTC
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?
Comment 6 James Beddek 2021-03-06 20:35:03 UTC
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.
Comment 7 Arfrever Frehtes Taifersar Arahesis 2021-03-07 03:20:09 UTC
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)
Comment 8 Arfrever Frehtes Taifersar Arahesis 2021-03-07 03:24:01 UTC
Created attachment 689727 [details, diff]
11.0.0/clang-libunwind-as-needed.patch
Comment 9 Arfrever Frehtes Taifersar Arahesis 2021-03-07 03:27:41 UTC
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.
Comment 10 James Beddek 2021-03-08 19:34:59 UTC
Latest version of PR depends on either sys-libs/llvm-libunwind (first preference) or sys-libs/libunwind
Comment 11 Larry the Git Cow gentoo-dev 2021-06-10 20:19:55 UTC
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(-)