Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/llvm-libunwind/
Date: Sun, 06 Feb 2022 15:35:13
Message-Id: 1644161666.d0abfd1184e8185f96050845550edf1fdfcd5472.mgorny@gentoo
1 commit: d0abfd1184e8185f96050845550edf1fdfcd5472
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Feb 6 15:16:48 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Feb 6 15:34:26 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d0abfd11
7
8 sys-libs/llvm-libunwind: Add 15.x live ebuild
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 .../llvm-libunwind-15.0.0.9999.ebuild | 141 +++++++++++++++++++++
13 1 file changed, 141 insertions(+)
14
15 diff --git a/sys-libs/llvm-libunwind/llvm-libunwind-15.0.0.9999.ebuild b/sys-libs/llvm-libunwind/llvm-libunwind-15.0.0.9999.ebuild
16 new file mode 100644
17 index 000000000000..b56cae043ae1
18 --- /dev/null
19 +++ b/sys-libs/llvm-libunwind/llvm-libunwind-15.0.0.9999.ebuild
20 @@ -0,0 +1,141 @@
21 +# Copyright 1999-2022 Gentoo Authors
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +EAPI=7
25 +
26 +CMAKE_ECLASS=cmake
27 +PYTHON_COMPAT=( python3_{8..10} )
28 +inherit cmake-multilib llvm llvm.org python-any-r1 toolchain-funcs
29 +
30 +DESCRIPTION="C++ runtime stack unwinder from LLVM"
31 +HOMEPAGE="https://github.com/llvm-mirror/libunwind"
32 +
33 +LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
34 +SLOT="0"
35 +KEYWORDS=""
36 +IUSE="debug static-libs test"
37 +RESTRICT="!test? ( test )"
38 +
39 +RDEPEND="!sys-libs/libunwind"
40 +# llvm-6 for new lit options
41 +DEPEND="
42 + >=sys-devel/llvm-6"
43 +BDEPEND="
44 + test? ( >=sys-devel/clang-3.9.0
45 + $(python_gen_any_dep 'dev-python/lit[${PYTHON_USEDEP}]')
46 + )"
47 +
48 +LLVM_COMPONENTS=( libunwind libcxx llvm/cmake cmake )
49 +LLVM_TEST_COMPONENTS=( libcxxabi )
50 +llvm.org_set_globals
51 +
52 +python_check_deps() {
53 + has_version "dev-python/lit[${PYTHON_USEDEP}]"
54 +}
55 +
56 +pkg_setup() {
57 + use test && python-any-r1_pkg_setup
58 +}
59 +
60 +multilib_src_configure() {
61 + local use_compiler_rt=OFF
62 + local libdir=$(get_libdir)
63 +
64 + # link to compiler-rt
65 + # https://github.com/gentoo/gentoo/pull/21516
66 + if tc-is-clang; then
67 + local compiler_rt=$($(tc-getCC) ${CFLAGS} ${CPPFLAGS} \
68 + ${LD_FLAGS} -print-libgcc-file-name)
69 + if [[ ${compiler_rt} == *libclang_rt* ]]; then
70 + use_compiler_rt=ON
71 + fi
72 + fi
73 +
74 + local mycmakeargs=(
75 + -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
76 + -DLIBUNWIND_ENABLE_ASSERTIONS=$(usex debug)
77 + -DLIBUNWIND_ENABLE_STATIC=$(usex static-libs)
78 + -DLIBUNWIND_INSTALL_HEADERS=ON
79 + -DLIBUNWIND_TARGET_TRIPLE="${CHOST}"
80 + -DLLVM_INCLUDE_TESTS=$(usex test)
81 +
82 + # support non-native unwinding; given it's small enough,
83 + # enable it unconditionally
84 + -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON
85 +
86 + # avoid dependency on libgcc_s if compiler-rt is used
87 + -DLIBUNWIND_USE_COMPILER_RT=${use_compiler_rt}
88 + )
89 + if use test; then
90 + mycmakeargs+=(
91 + -DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
92 + -DLLVM_LIT_ARGS="$(get_lit_flags)"
93 + -DLIBUNWIND_LIBCXX_PATH="${WORKDIR}/libcxx"
94 + )
95 + fi
96 +
97 + cmake_src_configure
98 +
99 + if use test; then
100 + local clang_path=$(type -P "${CHOST:+${CHOST}-}clang" 2>/dev/null)
101 + [[ -n ${clang_path} ]] || die "Unable to find ${CHOST}-clang for tests"
102 +
103 + # meh, we need to override the compiler explicitly
104 + sed -e "/%{cxx}/s@, '.*'@, '${clang_path}'@" \
105 + -i "${BUILD_DIR}"/test/lit.site.cfg || die
106 + fi
107 +}
108 +
109 +wrap_libcxxabi() {
110 + local mycmakeargs=(
111 + -DLIBCXXABI_LIBDIR_SUFFIX=
112 + -DLIBCXXABI_ENABLE_SHARED=OFF
113 + -DLIBCXXABI_ENABLE_STATIC=ON
114 + -DLIBCXXABI_USE_LLVM_UNWINDER=ON
115 + -DLIBCXXABI_INCLUDE_TESTS=OFF
116 +
117 + -DLIBCXXABI_LIBCXX_INCLUDES="${BUILD_DIR}"/libcxx/include/c++/v1
118 + -DLIBCXXABI_LIBUNWIND_INCLUDES="${S}"/include
119 + )
120 +
121 + local -x LDFLAGS="${LDFLAGS} -L${BUILD_DIR}/$(get_libdir)"
122 + local CMAKE_USE_DIR=${WORKDIR}/libcxxabi
123 + local BUILD_DIR=${BUILD_DIR}/libcxxabi
124 +
125 + "${@}"
126 +}
127 +
128 +wrap_libcxx() {
129 + local mycmakeargs=(
130 + -DLIBCXX_LIBDIR_SUFFIX=
131 + -DLIBCXX_ENABLE_SHARED=OFF
132 + -DLIBCXX_ENABLE_STATIC=ON
133 + -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
134 + -DLIBCXX_CXX_ABI=libcxxabi
135 + -DLIBCXX_CXX_ABI_INCLUDE_PATHS="${WORKDIR}"/libcxxabi/include
136 + -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF
137 + -DLIBCXX_HAS_MUSL_LIBC=$(usex elibc_musl)
138 + -DLIBCXX_HAS_GCC_S_LIB=OFF
139 + -DLIBCXX_INCLUDE_TESTS=OFF
140 + -DLIBCXX_INCLUDE_BENCHMARKS=OFF
141 + )
142 +
143 + local CMAKE_USE_DIR=${WORKDIR}/libcxx
144 + local BUILD_DIR=${BUILD_DIR}/libcxx
145 +
146 + "${@}"
147 +}
148 +
149 +multilib_src_test() {
150 + # build local copies of libc++ & libc++abi for testing to avoid
151 + # circular deps
152 + wrap_libcxx cmake_src_configure
153 + wrap_libcxx cmake_build generate-cxx-headers
154 + wrap_libcxxabi cmake_src_configure
155 + wrap_libcxxabi cmake_src_compile
156 + wrap_libcxx cmake_src_compile
157 + mv "${BUILD_DIR}"/libcxx*/lib/libc++* "${BUILD_DIR}/lib/" || die
158 +
159 + local -x LIT_PRESERVES_TMP=1
160 + cmake_build check-unwind
161 +}