1 |
commit: 2741567d6f7fb139c8ad37137fb581987a779e97 |
2 |
Author: Guilherme Amadio <amadio <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Dec 19 14:07:38 2020 +0000 |
4 |
Commit: Guilherme Amadio <amadio <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 7 13:59:40 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2741567d |
7 |
|
8 |
sys-libs/compiler-rt-sanitizers: fix for glibc 2.31+, bug #708430 |
9 |
|
10 |
Closes: https://bugs.gentoo.org/708430 |
11 |
Package-Manager: Portage-3.0.12, Repoman-3.0.2 |
12 |
Signed-off-by: Guilherme Amadio <amadio <AT> gentoo.org> |
13 |
|
14 |
.../compiler-rt-sanitizers-9.0.1-r1.ebuild | 160 +++++++++++++++++++++ |
15 |
.../files/9.0.1/glibc-2.31.patch | 35 +++++ |
16 |
2 files changed, 195 insertions(+) |
17 |
|
18 |
diff --git a/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-9.0.1-r1.ebuild b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-9.0.1-r1.ebuild |
19 |
new file mode 100644 |
20 |
index 00000000000..3092590d47e |
21 |
--- /dev/null |
22 |
+++ b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-9.0.1-r1.ebuild |
23 |
@@ -0,0 +1,160 @@ |
24 |
+# Copyright 1999-2021 Gentoo Authors |
25 |
+# Distributed under the terms of the GNU General Public License v2 |
26 |
+ |
27 |
+EAPI=7 |
28 |
+ |
29 |
+PYTHON_COMPAT=( python3_{6,7} ) |
30 |
+inherit check-reqs cmake-utils flag-o-matic llvm llvm.org \ |
31 |
+ multiprocessing python-any-r1 |
32 |
+ |
33 |
+DESCRIPTION="Compiler runtime libraries for clang (sanitizers & xray)" |
34 |
+HOMEPAGE="https://llvm.org/" |
35 |
+LLVM_COMPONENTS=( compiler-rt ) |
36 |
+LLVM_TEST_COMPONENTS=( llvm/lib/Testing/Support llvm/utils/unittest ) |
37 |
+llvm.org_set_globals |
38 |
+ |
39 |
+LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )" |
40 |
+SLOT="$(ver_cut 1-3)" |
41 |
+KEYWORDS="amd64 arm arm64 ppc64 x86 ~amd64-linux ~ppc-macos ~x64-macos" |
42 |
+IUSE="+clang +libfuzzer +profile +sanitize test +xray elibc_glibc" |
43 |
+# FIXME: libfuzzer does not enable all its necessary dependencies |
44 |
+REQUIRED_USE="libfuzzer? ( || ( sanitize xray ) )" |
45 |
+RESTRICT="!test? ( test ) !clang? ( test )" |
46 |
+ |
47 |
+CLANG_SLOT=${SLOT%%.*} |
48 |
+# llvm-6 for new lit options |
49 |
+DEPEND=" |
50 |
+ >=sys-devel/llvm-6" |
51 |
+BDEPEND=" |
52 |
+ clang? ( sys-devel/clang ) |
53 |
+ elibc_glibc? ( net-libs/libtirpc ) |
54 |
+ test? ( |
55 |
+ !<sys-apps/sandbox-2.13 |
56 |
+ $(python_gen_any_dep ">=dev-python/lit-5[\${PYTHON_USEDEP}]") |
57 |
+ =sys-devel/clang-${PV%_*}*:${CLANG_SLOT} |
58 |
+ sys-libs/compiler-rt:${SLOT} ) |
59 |
+ ${PYTHON_DEPS}" |
60 |
+ |
61 |
+# least intrusive of all |
62 |
+CMAKE_BUILD_TYPE=RelWithDebInfo |
63 |
+ |
64 |
+PATCHES=( "${FILESDIR}"/9.0.1/glibc-2.31.patch ) |
65 |
+ |
66 |
+python_check_deps() { |
67 |
+ use test || return 0 |
68 |
+ has_version "dev-python/lit[${PYTHON_USEDEP}]" |
69 |
+} |
70 |
+ |
71 |
+check_space() { |
72 |
+ if use test; then |
73 |
+ local CHECKREQS_DISK_BUILD=11G |
74 |
+ check-reqs_pkg_pretend |
75 |
+ fi |
76 |
+} |
77 |
+ |
78 |
+pkg_pretend() { |
79 |
+ check_space |
80 |
+} |
81 |
+ |
82 |
+pkg_setup() { |
83 |
+ check_space |
84 |
+ llvm_pkg_setup |
85 |
+ python-any-r1_pkg_setup |
86 |
+} |
87 |
+ |
88 |
+src_prepare() { |
89 |
+ cmake-utils_src_prepare |
90 |
+ |
91 |
+ if use test; then |
92 |
+ # remove tests that are (still) broken by new glibc |
93 |
+ # https://bugs.llvm.org/show_bug.cgi?id=36065 |
94 |
+ if use elibc_glibc && has_version '>=sys-libs/glibc-2.25'; then |
95 |
+ rm test/lsan/TestCases/Linux/fork_and_leak.cc || die |
96 |
+ fi |
97 |
+ fi |
98 |
+} |
99 |
+ |
100 |
+src_configure() { |
101 |
+ # pre-set since we need to pass it to cmake |
102 |
+ BUILD_DIR=${WORKDIR}/compiler-rt_build |
103 |
+ |
104 |
+ if use clang; then |
105 |
+ local -x CC=${CHOST}-clang |
106 |
+ local -x CXX=${CHOST}-clang++ |
107 |
+ strip-unsupported-flags |
108 |
+ fi |
109 |
+ |
110 |
+ local mycmakeargs=( |
111 |
+ -DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${SLOT}" |
112 |
+ # use a build dir structure consistent with install |
113 |
+ # this makes it possible to easily deploy test-friendly clang |
114 |
+ -DCOMPILER_RT_OUTPUT_DIR="${BUILD_DIR}/lib/clang/${SLOT}" |
115 |
+ |
116 |
+ -DCOMPILER_RT_INCLUDE_TESTS=$(usex test) |
117 |
+ # builtins & crt installed by sys-libs/compiler-rt |
118 |
+ -DCOMPILER_RT_BUILD_BUILTINS=OFF |
119 |
+ -DCOMPILER_RT_BUILD_CRT=OFF |
120 |
+ -DCOMPILER_RT_BUILD_LIBFUZZER=$(usex libfuzzer) |
121 |
+ -DCOMPILER_RT_BUILD_PROFILE=$(usex profile) |
122 |
+ -DCOMPILER_RT_BUILD_SANITIZERS=$(usex sanitize) |
123 |
+ -DCOMPILER_RT_BUILD_XRAY=$(usex xray) |
124 |
+ ) |
125 |
+ if use test; then |
126 |
+ mycmakeargs+=( |
127 |
+ -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm" |
128 |
+ -DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit" |
129 |
+ -DLLVM_LIT_ARGS="-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}" |
130 |
+ |
131 |
+ # they are created during src_test() |
132 |
+ -DCOMPILER_RT_TEST_COMPILER="${BUILD_DIR}/lib/llvm/${CLANG_SLOT}/bin/clang" |
133 |
+ -DCOMPILER_RT_TEST_CXX_COMPILER="${BUILD_DIR}/lib/llvm/${CLANG_SLOT}/bin/clang++" |
134 |
+ ) |
135 |
+ |
136 |
+ # same flags are passed for build & tests, so we need to strip |
137 |
+ # them down to a subset supported by clang |
138 |
+ CC=${EPREFIX}/usr/lib/llvm/${CLANG_SLOT}/bin/clang \ |
139 |
+ CXX=${EPREFIX}/usr/lib/llvm/${CLANG_SLOT}/bin/clang++ \ |
140 |
+ strip-unsupported-flags |
141 |
+ fi |
142 |
+ |
143 |
+ if use prefix && [[ "${CHOST}" == *-darwin* ]] ; then |
144 |
+ mycmakeargs+=( |
145 |
+ # disable use of SDK for the system itself |
146 |
+ -DDARWIN_macosx_CACHED_SYSROOT=/ |
147 |
+ ) |
148 |
+ fi |
149 |
+ |
150 |
+ cmake-utils_src_configure |
151 |
+ |
152 |
+ if use test; then |
153 |
+ local sys_dir=( "${EPREFIX}"/usr/lib/clang/${SLOT}/lib/* ) |
154 |
+ [[ -e ${sys_dir} ]] || die "Unable to find ${sys_dir}" |
155 |
+ [[ ${#sys_dir[@]} -eq 1 ]] || die "Non-deterministic compiler-rt install: ${sys_dir[*]}" |
156 |
+ |
157 |
+ # copy clang over since resource_dir is located relatively to binary |
158 |
+ # therefore, we can put our new libraries in it |
159 |
+ mkdir -p "${BUILD_DIR}"/lib/{llvm/${CLANG_SLOT}/{bin,$(get_libdir)},clang/${SLOT}/include} || die |
160 |
+ cp "${EPREFIX}"/usr/lib/llvm/${CLANG_SLOT}/bin/clang{,++} \ |
161 |
+ "${BUILD_DIR}"/lib/llvm/${CLANG_SLOT}/bin/ || die |
162 |
+ cp "${EPREFIX}"/usr/lib/clang/${SLOT}/include/*.h \ |
163 |
+ "${BUILD_DIR}"/lib/clang/${SLOT}/include/ || die |
164 |
+ cp "${sys_dir}"/*builtins*.a \ |
165 |
+ "${BUILD_DIR}/lib/clang/${SLOT}/lib/${sys_dir##*/}/" || die |
166 |
+ # we also need LLVMgold.so for gold-based tests |
167 |
+ if [[ -f ${EPREFIX}/usr/lib/llvm/${CLANG_SLOT}/$(get_libdir)/LLVMgold.so ]]; then |
168 |
+ ln -s "${EPREFIX}"/usr/lib/llvm/${CLANG_SLOT}/$(get_libdir)/LLVMgold.so \ |
169 |
+ "${BUILD_DIR}"/lib/llvm/${CLANG_SLOT}/$(get_libdir)/ || die |
170 |
+ fi |
171 |
+ fi |
172 |
+} |
173 |
+ |
174 |
+src_test() { |
175 |
+ # respect TMPDIR! |
176 |
+ local -x LIT_PRESERVES_TMP=1 |
177 |
+ # disable sandbox to have it stop clobbering LD_PRELOAD |
178 |
+ local -x SANDBOX_ON=0 |
179 |
+ # wipe LD_PRELOAD to make ASAN happy |
180 |
+ local -x LD_PRELOAD= |
181 |
+ |
182 |
+ cmake-utils_src_make check-all |
183 |
+} |
184 |
|
185 |
diff --git a/sys-libs/compiler-rt-sanitizers/files/9.0.1/glibc-2.31.patch b/sys-libs/compiler-rt-sanitizers/files/9.0.1/glibc-2.31.patch |
186 |
new file mode 100644 |
187 |
index 00000000000..ed52c67dbc5 |
188 |
--- /dev/null |
189 |
+++ b/sys-libs/compiler-rt-sanitizers/files/9.0.1/glibc-2.31.patch |
190 |
@@ -0,0 +1,35 @@ |
191 |
+diff -ur compiler-rt.orig/lib/sanitizer_common/sanitizer_platform_limits_posix.cc compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc |
192 |
+--- compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 2019-12-11 19:15:30.000000000 +0000 |
193 |
++++ compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 2020-09-27 17:38:13.848840427 +0000 |
194 |
+@@ -1126,8 +1126,9 @@ |
195 |
+ CHECK_SIZE_AND_OFFSET(ipc_perm, gid); |
196 |
+ CHECK_SIZE_AND_OFFSET(ipc_perm, cuid); |
197 |
+ CHECK_SIZE_AND_OFFSET(ipc_perm, cgid); |
198 |
+-#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21) |
199 |
+-/* On aarch64 glibc 2.20 and earlier provided incorrect mode field. */ |
200 |
++#if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31) |
201 |
++/* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit |
202 |
++ on many architectures. */ |
203 |
+ CHECK_SIZE_AND_OFFSET(ipc_perm, mode); |
204 |
+ #endif |
205 |
+ |
206 |
+diff -ur compiler-rt.orig/lib/sanitizer_common/sanitizer_platform_limits_posix.h compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h |
207 |
+--- compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h 2019-12-11 19:15:30.000000000 +0000 |
208 |
++++ compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h 2020-09-27 17:37:29.433597671 +0000 |
209 |
+@@ -214,15 +214,8 @@ |
210 |
+ unsigned short __seq; |
211 |
+ unsigned long long __unused1; |
212 |
+ unsigned long long __unused2; |
213 |
+-#elif defined(__mips__) || defined(__aarch64__) || defined(__s390x__) |
214 |
+- unsigned int mode; |
215 |
+- unsigned short __seq; |
216 |
+- unsigned short __pad1; |
217 |
+- unsigned long __unused1; |
218 |
+- unsigned long __unused2; |
219 |
+ #else |
220 |
+- unsigned short mode; |
221 |
+- unsigned short __pad1; |
222 |
++ unsigned int mode; |
223 |
+ unsigned short __seq; |
224 |
+ unsigned short __pad2; |
225 |
+ #if defined(__x86_64__) && !defined(_LP64) |