commit:     25cb8d050c81a4afc69c10bdd5049eecfe6b8524
Author:     Alex R <lyssdod <AT> gmail <DOT> com>
AuthorDate: Sun Jul  4 22:57:31 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul  5 05:40:07 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=25cb8d05

sys-libs/llvm-libunwind: use compiler-rt if possible

Signed-off-by: Alex Revin <lyssdod <AT> gmail.com>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 sys-libs/llvm-libunwind/llvm-libunwind-12.0.0.ebuild     | 16 +++++++++++++++-
 .../llvm-libunwind/llvm-libunwind-12.0.1.9999.ebuild     | 16 +++++++++++++++-
 sys-libs/llvm-libunwind/llvm-libunwind-12.0.1_rc2.ebuild | 16 +++++++++++++++-
 .../llvm-libunwind/llvm-libunwind-13.0.0.9999.ebuild     | 16 +++++++++++++++-
 4 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/sys-libs/llvm-libunwind/llvm-libunwind-12.0.0.ebuild 
b/sys-libs/llvm-libunwind/llvm-libunwind-12.0.0.ebuild
index 0f82c1251fa..7d7b9833902 100644
--- a/sys-libs/llvm-libunwind/llvm-libunwind-12.0.0.ebuild
+++ b/sys-libs/llvm-libunwind/llvm-libunwind-12.0.0.ebuild
@@ -5,7 +5,7 @@ EAPI=7
 
 CMAKE_ECLASS=cmake
 PYTHON_COMPAT=( python3_{7..9} )
-inherit cmake-multilib llvm llvm.org python-any-r1
+inherit cmake-multilib llvm llvm.org python-any-r1 toolchain-funcs
 
 DESCRIPTION="C++ runtime stack unwinder from LLVM"
 HOMEPAGE="https://github.com/llvm-mirror/libunwind";
@@ -38,8 +38,19 @@ pkg_setup() {
 }
 
 multilib_src_configure() {
+       local use_compiler_rt=OFF
        local libdir=$(get_libdir)
 
+       # link to compiler-rt
+       # https://github.com/gentoo/gentoo/pull/21516
+       if tc-is-clang; then
+               local compiler-rt=$($(tc-getCC) ${CFLAGS} ${CPPFLAGS} \
+                  ${LD_FLAGS} -print-libgcc-file-name)
+               if [[ ${compiler_rt} == *libclang_rt* ]]; then
+                       use_compiler_rt=ON
+               fi
+       fi
+
        local mycmakeargs=(
                -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
                -DLIBUNWIND_ENABLE_ASSERTIONS=$(usex debug)
@@ -49,6 +60,9 @@ multilib_src_configure() {
                # support non-native unwinding; given it's small enough,
                # enable it unconditionally
                -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON
+
+               # avoid dependency on libgcc_s if compiler-rt is used
+               -DLIBUNWIND_USE_COMPILER_RT=${use_compiler_rt}
        )
        if use test; then
                local clang_path=$(type -P "${CHOST:+${CHOST}-}clang" 
2>/dev/null)

diff --git a/sys-libs/llvm-libunwind/llvm-libunwind-12.0.1.9999.ebuild 
b/sys-libs/llvm-libunwind/llvm-libunwind-12.0.1.9999.ebuild
index bf538b66689..4f13111b557 100644
--- a/sys-libs/llvm-libunwind/llvm-libunwind-12.0.1.9999.ebuild
+++ b/sys-libs/llvm-libunwind/llvm-libunwind-12.0.1.9999.ebuild
@@ -5,7 +5,7 @@ EAPI=7
 
 CMAKE_ECLASS=cmake
 PYTHON_COMPAT=( python3_{7..9} )
-inherit cmake-multilib llvm llvm.org python-any-r1
+inherit cmake-multilib llvm llvm.org python-any-r1 toolchain-funcs
 
 DESCRIPTION="C++ runtime stack unwinder from LLVM"
 HOMEPAGE="https://github.com/llvm-mirror/libunwind";
@@ -38,8 +38,19 @@ pkg_setup() {
 }
 
 multilib_src_configure() {
+       local use_compiler_rt=OFF
        local libdir=$(get_libdir)
 
+       # link to compiler-rt
+       # https://github.com/gentoo/gentoo/pull/21516
+       if tc-is-clang; then
+               local compiler-rt=$($(tc-getCC) ${CFLAGS} ${CPPFLAGS} \
+                  ${LD_FLAGS} -print-libgcc-file-name)
+               if [[ ${compiler_rt} == *libclang_rt* ]]; then
+                       use_compiler_rt=ON
+               fi
+       fi
+
        local mycmakeargs=(
                -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
                -DLIBUNWIND_ENABLE_ASSERTIONS=$(usex debug)
@@ -49,6 +60,9 @@ multilib_src_configure() {
                # support non-native unwinding; given it's small enough,
                # enable it unconditionally
                -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON
+
+               # avoid dependency on libgcc_s if compiler-rt is used
+               -DLIBUNWIND_USE_COMPILER_RT=${use_compiler_rt}
        )
        if use test; then
                local clang_path=$(type -P "${CHOST:+${CHOST}-}clang" 
2>/dev/null)

diff --git a/sys-libs/llvm-libunwind/llvm-libunwind-12.0.1_rc2.ebuild 
b/sys-libs/llvm-libunwind/llvm-libunwind-12.0.1_rc2.ebuild
index bf538b66689..4f13111b557 100644
--- a/sys-libs/llvm-libunwind/llvm-libunwind-12.0.1_rc2.ebuild
+++ b/sys-libs/llvm-libunwind/llvm-libunwind-12.0.1_rc2.ebuild
@@ -5,7 +5,7 @@ EAPI=7
 
 CMAKE_ECLASS=cmake
 PYTHON_COMPAT=( python3_{7..9} )
-inherit cmake-multilib llvm llvm.org python-any-r1
+inherit cmake-multilib llvm llvm.org python-any-r1 toolchain-funcs
 
 DESCRIPTION="C++ runtime stack unwinder from LLVM"
 HOMEPAGE="https://github.com/llvm-mirror/libunwind";
@@ -38,8 +38,19 @@ pkg_setup() {
 }
 
 multilib_src_configure() {
+       local use_compiler_rt=OFF
        local libdir=$(get_libdir)
 
+       # link to compiler-rt
+       # https://github.com/gentoo/gentoo/pull/21516
+       if tc-is-clang; then
+               local compiler-rt=$($(tc-getCC) ${CFLAGS} ${CPPFLAGS} \
+                  ${LD_FLAGS} -print-libgcc-file-name)
+               if [[ ${compiler_rt} == *libclang_rt* ]]; then
+                       use_compiler_rt=ON
+               fi
+       fi
+
        local mycmakeargs=(
                -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
                -DLIBUNWIND_ENABLE_ASSERTIONS=$(usex debug)
@@ -49,6 +60,9 @@ multilib_src_configure() {
                # support non-native unwinding; given it's small enough,
                # enable it unconditionally
                -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON
+
+               # avoid dependency on libgcc_s if compiler-rt is used
+               -DLIBUNWIND_USE_COMPILER_RT=${use_compiler_rt}
        )
        if use test; then
                local clang_path=$(type -P "${CHOST:+${CHOST}-}clang" 
2>/dev/null)

diff --git a/sys-libs/llvm-libunwind/llvm-libunwind-13.0.0.9999.ebuild 
b/sys-libs/llvm-libunwind/llvm-libunwind-13.0.0.9999.ebuild
index bf538b66689..4f13111b557 100644
--- a/sys-libs/llvm-libunwind/llvm-libunwind-13.0.0.9999.ebuild
+++ b/sys-libs/llvm-libunwind/llvm-libunwind-13.0.0.9999.ebuild
@@ -5,7 +5,7 @@ EAPI=7
 
 CMAKE_ECLASS=cmake
 PYTHON_COMPAT=( python3_{7..9} )
-inherit cmake-multilib llvm llvm.org python-any-r1
+inherit cmake-multilib llvm llvm.org python-any-r1 toolchain-funcs
 
 DESCRIPTION="C++ runtime stack unwinder from LLVM"
 HOMEPAGE="https://github.com/llvm-mirror/libunwind";
@@ -38,8 +38,19 @@ pkg_setup() {
 }
 
 multilib_src_configure() {
+       local use_compiler_rt=OFF
        local libdir=$(get_libdir)
 
+       # link to compiler-rt
+       # https://github.com/gentoo/gentoo/pull/21516
+       if tc-is-clang; then
+               local compiler-rt=$($(tc-getCC) ${CFLAGS} ${CPPFLAGS} \
+                  ${LD_FLAGS} -print-libgcc-file-name)
+               if [[ ${compiler_rt} == *libclang_rt* ]]; then
+                       use_compiler_rt=ON
+               fi
+       fi
+
        local mycmakeargs=(
                -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
                -DLIBUNWIND_ENABLE_ASSERTIONS=$(usex debug)
@@ -49,6 +60,9 @@ multilib_src_configure() {
                # support non-native unwinding; given it's small enough,
                # enable it unconditionally
                -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON
+
+               # avoid dependency on libgcc_s if compiler-rt is used
+               -DLIBUNWIND_USE_COMPILER_RT=${use_compiler_rt}
        )
        if use test; then
                local clang_path=$(type -P "${CHOST:+${CHOST}-}clang" 
2>/dev/null)

Reply via email to