Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/compiler-rt/
Date: Wed, 03 Aug 2022 23:33:23
Message-Id: 1659569588.dc072af65039e77a4ecc35ffee42b0a29523d122.sam@gentoo
1 commit: dc072af65039e77a4ecc35ffee42b0a29523d122
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Wed Aug 3 23:32:44 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 3 23:33:08 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dc072af6
7
8 sys-libs/compiler-rt: try better workaround for -nostartfiles
9
10 Fix no installed files on !amd64.
11
12 Bug: https://bugs.gentoo.org/862540
13 Signed-off-by: Sam James <sam <AT> gentoo.org>
14
15 sys-libs/compiler-rt/compiler-rt-14.0.6-r1.ebuild | 150 ++++++++++++++++++++++
16 1 file changed, 150 insertions(+)
17
18 diff --git a/sys-libs/compiler-rt/compiler-rt-14.0.6-r1.ebuild b/sys-libs/compiler-rt/compiler-rt-14.0.6-r1.ebuild
19 new file mode 100644
20 index 000000000000..10bb65dc8a01
21 --- /dev/null
22 +++ b/sys-libs/compiler-rt/compiler-rt-14.0.6-r1.ebuild
23 @@ -0,0 +1,150 @@
24 +# Copyright 1999-2022 Gentoo Authors
25 +# Distributed under the terms of the GNU General Public License v2
26 +
27 +EAPI=8
28 +
29 +PYTHON_COMPAT=( python3_{8..10} )
30 +inherit cmake flag-o-matic llvm llvm.org python-any-r1 toolchain-funcs
31 +
32 +DESCRIPTION="Compiler runtime library for clang (built-in part)"
33 +HOMEPAGE="https://llvm.org/"
34 +
35 +LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
36 +SLOT="$(ver_cut 1-3)"
37 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86 ~amd64-linux ~ppc-macos ~x64-macos"
38 +IUSE="+abi_x86_32 abi_x86_64 +clang debug test"
39 +RESTRICT="!test? ( test ) !clang? ( test )"
40 +
41 +CLANG_SLOT=${SLOT%%.*}
42 +# llvm-6 for new lit options
43 +DEPEND="
44 + >=sys-devel/llvm-6
45 +"
46 +BDEPEND="
47 + >=dev-util/cmake-3.16
48 + clang? ( sys-devel/clang )
49 + test? (
50 + $(python_gen_any_dep ">=dev-python/lit-9.0.1[\${PYTHON_USEDEP}]")
51 + =sys-devel/clang-${PV%_*}*:${CLANG_SLOT}
52 + )
53 + !test? (
54 + ${PYTHON_DEPS}
55 + )
56 +"
57 +
58 +LLVM_COMPONENTS=( compiler-rt cmake )
59 +LLVM_PATCHSET=${PV}-r2
60 +llvm.org_set_globals
61 +
62 +python_check_deps() {
63 + use test || return 0
64 + has_version "dev-python/lit[${PYTHON_USEDEP}]"
65 +}
66 +
67 +pkg_pretend() {
68 + if ! use clang && ! tc-is-clang; then
69 + ewarn "Building using a compiler other than clang may result in broken atomics"
70 + ewarn "library. Enable USE=clang unless you have a very good reason not to."
71 + fi
72 +}
73 +
74 +pkg_setup() {
75 + # Darwin Prefix builds do not have llvm installed yet, so rely on
76 + # bootstrap-prefix to set the appropriate path vars to LLVM instead
77 + # of using llvm_pkg_setup.
78 + if [[ ${CHOST} != *-darwin* ]] || has_version dev-lang/llvm; then
79 + llvm_pkg_setup
80 + fi
81 + python-any-r1_pkg_setup
82 +}
83 +
84 +test_compiler() {
85 + $(tc-getCC) ${CFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c - \
86 + <<<'int main() { return 0; }' &>/dev/null
87 +}
88 +
89 +src_configure() {
90 + # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
91 + use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
92 +
93 + # pre-set since we need to pass it to cmake
94 + BUILD_DIR=${WORKDIR}/${P}_build
95 +
96 + if use clang; then
97 + # Only do this conditionally to allow overriding with
98 + # e.g. CC=clang-13 in case of breakage
99 + if ! tc-is-clang ; then
100 + local -x CC=${CHOST}-clang
101 + local -x CXX=${CHOST}-clang++
102 + fi
103 +
104 + strip-unsupported-flags
105 + fi
106 +
107 + if ! test_compiler; then
108 + local nolib_flags=( -nodefaultlibs -lc )
109 +
110 + if test_compiler "${nolib_flags[@]}"; then
111 + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
112 + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}"
113 + elif test_compiler "${nolib_flags[@]}" -nostartfiles; then
114 + # Avoiding -nostartfiles earlier on for bug #862540
115 + nolib_flags+=( -nostartfiles )
116 + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
117 + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}"
118 + fi
119 + fi
120 +
121 + local mycmakeargs=(
122 + -DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${SLOT}"
123 +
124 + -DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
125 + -DCOMPILER_RT_BUILD_LIBFUZZER=OFF
126 + -DCOMPILER_RT_BUILD_MEMPROF=OFF
127 + -DCOMPILER_RT_BUILD_ORC=OFF
128 + -DCOMPILER_RT_BUILD_PROFILE=OFF
129 + -DCOMPILER_RT_BUILD_SANITIZERS=OFF
130 + -DCOMPILER_RT_BUILD_XRAY=OFF
131 +
132 + -DPython3_EXECUTABLE="${PYTHON}"
133 + )
134 +
135 + if use amd64; then
136 + mycmakeargs+=(
137 + -DCAN_TARGET_i386=$(usex abi_x86_32)
138 + -DCAN_TARGET_x86_64=$(usex abi_x86_64)
139 + )
140 + fi
141 +
142 + if use prefix && [[ "${CHOST}" == *-darwin* ]] ; then
143 + mycmakeargs+=(
144 + # setting -isysroot is disabled with compiler-rt-prefix-paths.patch
145 + # this allows adding arm64 support using SDK in EPREFIX
146 + -DDARWIN_macosx_CACHED_SYSROOT="${EPREFIX}/MacOSX.sdk"
147 + # Set version based on the SDK in EPREFIX.
148 + # This disables i386 for SDK >= 10.15
149 + -DDARWIN_macosx_OVERRIDE_SDK_VERSION="$(realpath ${EPREFIX}/MacOSX.sdk | sed -e 's/.*MacOSX\(.*\)\.sdk/\1/')"
150 + # Use our libtool instead of looking it up with xcrun
151 + -DCMAKE_LIBTOOL="${EPREFIX}/usr/bin/${CHOST}-libtool"
152 + )
153 + fi
154 +
155 + if use test; then
156 + mycmakeargs+=(
157 + -DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
158 + -DLLVM_LIT_ARGS="$(get_lit_flags)"
159 +
160 + -DCOMPILER_RT_TEST_COMPILER="${EPREFIX}/usr/lib/llvm/${CLANG_SLOT}/bin/clang"
161 + -DCOMPILER_RT_TEST_CXX_COMPILER="${EPREFIX}/usr/lib/llvm/${CLANG_SLOT}/bin/clang++"
162 + )
163 + fi
164 +
165 + cmake_src_configure
166 +}
167 +
168 +src_test() {
169 + # respect TMPDIR!
170 + local -x LIT_PRESERVES_TMP=1
171 +
172 + cmake_build check-builtins
173 +}