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-sanitizers/
Date: Mon, 26 Sep 2022 07:36:23
Message-Id: 1664177755.141a1f11060fa557b7cdb6345d62021782ba350a.mgorny@gentoo
1 commit: 141a1f11060fa557b7cdb6345d62021782ba350a
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Mon Sep 26 06:48:50 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Mon Sep 26 07:35:55 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=141a1f11
7
8 sys-libs/compiler-rt-sanitizers: Bump to 16.0.0_pre20220926
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 sys-libs/compiler-rt-sanitizers/Manifest | 1 +
13 ...ompiler-rt-sanitizers-16.0.0_pre20220926.ebuild | 220 +++++++++++++++++++++
14 2 files changed, 221 insertions(+)
15
16 diff --git a/sys-libs/compiler-rt-sanitizers/Manifest b/sys-libs/compiler-rt-sanitizers/Manifest
17 index aaf1da153153..e9e1b9fa02f8 100644
18 --- a/sys-libs/compiler-rt-sanitizers/Manifest
19 +++ b/sys-libs/compiler-rt-sanitizers/Manifest
20 @@ -7,4 +7,5 @@ DIST llvm-project-14.0.6.src.tar.xz.sig 566 BLAKE2B cb658ad43d8ab6c43a5773aedadf
21 DIST llvm-project-15.0.1.src.tar.xz 112068688 BLAKE2B 8fd6690445f7cbc8b47a7c1dd1f2c4fbc39f9a97f9d4a0015d466726454b090b0d1ff9b0d926eba7065e84782901687f74e6540a36dc6656a93f3c92c7bc7e06 SHA512 cef84bc173118a30db3ece5e5c6f874bf689c77afc40a4792fdcb7556555ac14a8e6de1dc811755405e5d162d63bc69abaecba30d220a42765160d69f0073fda
22 DIST llvm-project-15.0.1.src.tar.xz.sig 438 BLAKE2B d8f634adab531bb19178fb27bc83b3a90c856e9402dd5af700f9af43813f68d20c21b9112dd95e9f6f10609ee51ed5aaf77edb96ca16fb93136b8aea432affd3 SHA512 cbf2570840d8dc12f6436c495a23cf9d439ee195755c01a6d1d5bcc20133599dc956dc43a0f5016698e3c9a960826f5f3c2840a73f993467e275856a67999fda
23 DIST llvm-project-303526ef3aa211c1930be2885deae15eeeda3b18.tar.gz 167503164 BLAKE2B 143c72c58517b3e40ee74c1a0df47bfd0d0f9e71926bc8c39a007e674a08df95d0ffe05f523f97e4409b248349e13719cabbc7ac6938feebe702959e84a07243 SHA512 9aa5c86de6c6be1d26c085eb29ea283429e41330e937e5fdbd545bb3f5b996ac82cd6268701fcbbd202e89ee35f2b67e595fc595bb7383778e9ad5fd52ca10a0
24 +DIST llvm-project-4f188ef89ce5a3bee21fd0b4e8fcdf7f030f64b2.tar.gz 168720595 BLAKE2B 10bd3ac4eea674fc171f17414f6892a681529b020a5d513e075920f7792fb31d6d4a3584679ebea24bc839c2a233459b935d368c7ea57c94ad27c7c81da05cff SHA512 77ae7eb57c8c50affb516581dabe3b31e342f7ed899440521b6738aeec3b6e795c50c078bbe0f483a070961c9b5b73a7bbe28e2f109e2ce69d238ddbda8e134f
25 DIST llvmorg-13.0.1.tar.gz 147290251 BLAKE2B 2a44b012a672501761d0c27c6b3a315b69bfef0cd13b078a7e7d2fccc4a9c8c0f2bee0f164c4271c9106b0a99cb06e8b64986f66253b613336719fb86b82541b SHA512 9a8cb5d11964ba88b7624f19ec861fb28701f23956ea3c92f6ac644332d5f41fde97bd8933dd3ee70ed378058c252fa3a3887c8d1af90d219970c2b27691166f
26
27 diff --git a/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-16.0.0_pre20220926.ebuild b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-16.0.0_pre20220926.ebuild
28 new file mode 100644
29 index 000000000000..f716dc74b423
30 --- /dev/null
31 +++ b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-16.0.0_pre20220926.ebuild
32 @@ -0,0 +1,220 @@
33 +# Copyright 1999-2022 Gentoo Authors
34 +# Distributed under the terms of the GNU General Public License v2
35 +
36 +EAPI=8
37 +
38 +PYTHON_COMPAT=( python3_{8..11} )
39 +inherit check-reqs cmake flag-o-matic llvm llvm.org python-any-r1
40 +
41 +DESCRIPTION="Compiler runtime libraries for clang (sanitizers & xray)"
42 +HOMEPAGE="https://llvm.org/"
43 +
44 +LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
45 +SLOT="$(ver_cut 1-3)"
46 +KEYWORDS=""
47 +IUSE="+abi_x86_32 abi_x86_64 +clang debug test"
48 +# base targets
49 +IUSE+=" +libfuzzer +memprof +orc +profile +xray"
50 +# sanitizer targets, keep in sync with config-ix.cmake
51 +# NB: ubsan, scudo deliberately match two entries
52 +SANITIZER_FLAGS=(
53 + asan dfsan lsan msan hwasan tsan ubsan safestack cfi scudo
54 + shadowcallstack gwp-asan
55 +)
56 +IUSE+=" ${SANITIZER_FLAGS[@]/#/+}"
57 +REQUIRED_USE="
58 + || ( ${SANITIZER_FLAGS[*]} libfuzzer orc profile xray )
59 + test? (
60 + cfi? ( ubsan )
61 + gwp-asan? ( scudo )
62 + )
63 +"
64 +RESTRICT="
65 + !clang? ( test )
66 + !test? ( test )
67 +"
68 +
69 +LLVM_MAX_SLOT=${SLOT%%.*}
70 +DEPEND="
71 + sys-devel/llvm:${LLVM_MAX_SLOT}
72 + virtual/libcrypt[abi_x86_32(-)?,abi_x86_64(-)?]
73 +"
74 +BDEPEND="
75 + >=dev-util/cmake-3.16
76 + clang? ( sys-devel/clang )
77 + elibc_glibc? ( net-libs/libtirpc )
78 + test? (
79 + !!<sys-apps/sandbox-2.13
80 + $(python_gen_any_dep ">=dev-python/lit-15[\${PYTHON_USEDEP}]")
81 + =sys-devel/clang-${PV%_*}*:${LLVM_MAX_SLOT}
82 + sys-libs/compiler-rt:${SLOT}
83 + )
84 + !test? (
85 + ${PYTHON_DEPS}
86 + )
87 +"
88 +
89 +LLVM_COMPONENTS=( compiler-rt cmake llvm/cmake )
90 +LLVM_TEST_COMPONENTS=( llvm/lib/Testing/Support llvm/utils/unittest )
91 +LLVM_PATCHSET=9999-1
92 +llvm.org_set_globals
93 +
94 +python_check_deps() {
95 + use test || return 0
96 + python_has_version ">=dev-python/lit-15[${PYTHON_USEDEP}]"
97 +}
98 +
99 +check_space() {
100 + if use test; then
101 + local CHECKREQS_DISK_BUILD=11G
102 + check-reqs_pkg_pretend
103 + fi
104 +}
105 +
106 +pkg_pretend() {
107 + check_space
108 +}
109 +
110 +pkg_setup() {
111 + check_space
112 + llvm_pkg_setup
113 + python-any-r1_pkg_setup
114 +}
115 +
116 +src_prepare() {
117 + sed -i -e 's:-Werror::' lib/tsan/go/buildgo.sh || die
118 +
119 + local flag
120 + for flag in "${SANITIZER_FLAGS[@]}"; do
121 + if ! use "${flag}"; then
122 + local cmake_flag=${flag/-/_}
123 + sed -i -e "/COMPILER_RT_HAS_${cmake_flag^^}/s:TRUE:FALSE:" \
124 + cmake/config-ix.cmake || die
125 + fi
126 + done
127 +
128 + # TODO: fix these tests to be skipped upstream
129 + if use asan && ! use profile; then
130 + rm test/asan/TestCases/asan_and_llvm_coverage_test.cpp || die
131 + fi
132 + if use ubsan && ! use cfi; then
133 + > test/cfi/CMakeLists.txt || die
134 + fi
135 +
136 + llvm.org_src_prepare
137 +}
138 +
139 +src_configure() {
140 + # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
141 + use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
142 +
143 + # pre-set since we need to pass it to cmake
144 + BUILD_DIR=${WORKDIR}/compiler-rt_build
145 +
146 + if use clang; then
147 + local -x CC=${CHOST}-clang
148 + local -x CXX=${CHOST}-clang++
149 + strip-unsupported-flags
150 + fi
151 +
152 + local flag want_sanitizer=OFF
153 + for flag in "${SANITIZER_FLAGS[@]}"; do
154 + if use "${flag}"; then
155 + want_sanitizer=ON
156 + break
157 + fi
158 + done
159 +
160 + local mycmakeargs=(
161 + -DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${SLOT}"
162 + # use a build dir structure consistent with install
163 + # this makes it possible to easily deploy test-friendly clang
164 + -DCOMPILER_RT_OUTPUT_DIR="${BUILD_DIR}/lib/clang/${SLOT}"
165 +
166 + -DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
167 + # builtins & crt installed by sys-libs/compiler-rt
168 + -DCOMPILER_RT_BUILD_BUILTINS=OFF
169 + -DCOMPILER_RT_BUILD_CRT=OFF
170 + -DCOMPILER_RT_BUILD_LIBFUZZER=$(usex libfuzzer)
171 + -DCOMPILER_RT_BUILD_MEMPROF=$(usex memprof)
172 + -DCOMPILER_RT_BUILD_ORC=$(usex orc)
173 + -DCOMPILER_RT_BUILD_PROFILE=$(usex profile)
174 + -DCOMPILER_RT_BUILD_SANITIZERS="${want_sanitizer}"
175 + -DCOMPILER_RT_BUILD_XRAY=$(usex xray)
176 +
177 + -DPython3_EXECUTABLE="${PYTHON}"
178 + )
179 +
180 + if use amd64; then
181 + mycmakeargs+=(
182 + -DCAN_TARGET_i386=$(usex abi_x86_32)
183 + -DCAN_TARGET_x86_64=$(usex abi_x86_64)
184 + )
185 + fi
186 +
187 + if use test; then
188 + mycmakeargs+=(
189 + -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm"
190 + -DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
191 + -DLLVM_LIT_ARGS="$(get_lit_flags)"
192 +
193 + # they are created during src_test()
194 + -DCOMPILER_RT_TEST_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_MAX_SLOT}/bin/clang"
195 + -DCOMPILER_RT_TEST_CXX_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_MAX_SLOT}/bin/clang++"
196 + )
197 +
198 + # same flags are passed for build & tests, so we need to strip
199 + # them down to a subset supported by clang
200 + CC=${EPREFIX}/usr/lib/llvm/${LLVM_MAX_SLOT}/bin/clang \
201 + CXX=${EPREFIX}/usr/lib/llvm/${LLVM_MAX_SLOT}/bin/clang++ \
202 + strip-unsupported-flags
203 + fi
204 +
205 + if use prefix && [[ "${CHOST}" == *-darwin* ]] ; then
206 + mycmakeargs+=(
207 + # setting -isysroot is disabled with compiler-rt-prefix-paths.patch
208 + # this allows adding arm64 support using SDK in EPREFIX
209 + -DDARWIN_macosx_CACHED_SYSROOT="${EPREFIX}/MacOSX.sdk"
210 + # Set version based on the SDK in EPREFIX
211 + # This disables i386 for SDK >= 10.15
212 + # Will error if has_use tsan and SDK < 10.12
213 + -DDARWIN_macosx_OVERRIDE_SDK_VERSION="$(realpath ${EPREFIX}/MacOSX.sdk | sed -e 's/.*MacOSX\(.*\)\.sdk/\1/')"
214 + # Use our libtool instead of looking it up with xcrun
215 + -DCMAKE_LIBTOOL="${EPREFIX}/usr/bin/${CHOST}-libtool"
216 + )
217 + fi
218 +
219 + cmake_src_configure
220 +
221 + if use test; then
222 + local sys_dir=( "${EPREFIX}"/usr/lib/clang/${SLOT}/lib/* )
223 + [[ -e ${sys_dir} ]] || die "Unable to find ${sys_dir}"
224 + [[ ${#sys_dir[@]} -eq 1 ]] || die "Non-deterministic compiler-rt install: ${sys_dir[*]}"
225 +
226 + # copy clang over since resource_dir is located relatively to binary
227 + # therefore, we can put our new libraries in it
228 + mkdir -p "${BUILD_DIR}"/lib/{llvm/${LLVM_MAX_SLOT}/{bin,$(get_libdir)},clang/${SLOT}/include} || die
229 + cp "${EPREFIX}"/usr/lib/llvm/${LLVM_MAX_SLOT}/bin/clang{,++} \
230 + "${BUILD_DIR}"/lib/llvm/${LLVM_MAX_SLOT}/bin/ || die
231 + cp "${EPREFIX}"/usr/lib/clang/${SLOT}/include/*.h \
232 + "${BUILD_DIR}"/lib/clang/${SLOT}/include/ || die
233 + cp "${sys_dir}"/*builtins*.a \
234 + "${BUILD_DIR}/lib/clang/${SLOT}/lib/${sys_dir##*/}/" || die
235 + # we also need LLVMgold.so for gold-based tests
236 + if [[ -f ${EPREFIX}/usr/lib/llvm/${LLVM_MAX_SLOT}/$(get_libdir)/LLVMgold.so ]]; then
237 + ln -s "${EPREFIX}"/usr/lib/llvm/${LLVM_MAX_SLOT}/$(get_libdir)/LLVMgold.so \
238 + "${BUILD_DIR}"/lib/llvm/${LLVM_MAX_SLOT}/$(get_libdir)/ || die
239 + fi
240 + fi
241 +}
242 +
243 +src_test() {
244 + # respect TMPDIR!
245 + local -x LIT_PRESERVES_TMP=1
246 + # disable sandbox to have it stop clobbering LD_PRELOAD
247 + local -x SANDBOX_ON=0
248 + # wipe LD_PRELOAD to make ASAN happy
249 + local -x LD_PRELOAD=
250 +
251 + cmake_build check-all
252 +}