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