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: Wed, 16 Jan 2019 14:53:00
Message-Id: 1547650354.83af4d219d624af39e967af9e5425dec4f64792c.mgorny@gentoo
1 commit: 83af4d219d624af39e967af9e5425dec4f64792c
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 16 13:50:14 2019 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 16 14:52:34 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=83af4d21
7
8 sys-libs/compiler-rt-sanitizers: Add a live ebuild for 8.* branch
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 .../compiler-rt-sanitizers-8.0.9999.ebuild | 173 +++++++++++++++++++++
13 1 file changed, 173 insertions(+)
14
15 diff --git a/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-8.0.9999.ebuild b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-8.0.9999.ebuild
16 new file mode 100644
17 index 00000000000..e2589f02ba5
18 --- /dev/null
19 +++ b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-8.0.9999.ebuild
20 @@ -0,0 +1,173 @@
21 +# Copyright 1999-2019 Gentoo Authors
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +EAPI=6
25 +
26 +: ${CMAKE_MAKEFILE_GENERATOR:=ninja}
27 +# (needed due to CMAKE_BUILD_TYPE != Gentoo)
28 +CMAKE_MIN_VERSION=3.7.0-r1
29 +PYTHON_COMPAT=( python2_7 )
30 +
31 +inherit check-reqs cmake-utils flag-o-matic git-r3 llvm \
32 + multiprocessing python-any-r1
33 +
34 +DESCRIPTION="Compiler runtime libraries for clang (sanitizers & xray)"
35 +HOMEPAGE="https://llvm.org/"
36 +SRC_URI=""
37 +EGIT_REPO_URI="https://git.llvm.org/git/compiler-rt.git
38 + https://github.com/llvm-mirror/compiler-rt.git"
39 +EGIT_BRANCH="release_80"
40 +
41 +LICENSE="|| ( UoI-NCSA MIT )"
42 +# Note: this needs to be updated to match version of clang-9999
43 +SLOT="8.0.0"
44 +KEYWORDS=""
45 +IUSE="+clang +libfuzzer +profile +sanitize test +xray elibc_glibc"
46 +# FIXME: libfuzzer does not enable all its necessary dependencies
47 +REQUIRED_USE="libfuzzer? ( || ( sanitize xray ) )"
48 +RESTRICT="!test? ( test ) !clang? ( test )"
49 +
50 +CLANG_SLOT=${SLOT%%.*}
51 +# llvm-6 for new lit options
52 +DEPEND="
53 + >=sys-devel/llvm-6
54 + clang? ( sys-devel/clang )
55 + elibc_glibc? ( net-libs/libtirpc )
56 + test? (
57 + !<sys-apps/sandbox-2.13
58 + $(python_gen_any_dep ">=dev-python/lit-5[\${PYTHON_USEDEP}]")
59 + =sys-devel/clang-${PV%_*}*:${CLANG_SLOT}
60 + sys-libs/compiler-rt:${SLOT} )
61 + ${PYTHON_DEPS}"
62 +
63 +# least intrusive of all
64 +CMAKE_BUILD_TYPE=RelWithDebInfo
65 +
66 +check_space() {
67 + if use test; then
68 + local CHECKREQS_DISK_BUILD=11G
69 + check-reqs_pkg_pretend
70 + fi
71 +}
72 +
73 +pkg_pretend() {
74 + check_space
75 +}
76 +
77 +pkg_setup() {
78 + check_space
79 + llvm_pkg_setup
80 + python-any-r1_pkg_setup
81 +}
82 +
83 +src_unpack() {
84 + if use test; then
85 + # needed for patched gtest
86 + git-r3_fetch "https://git.llvm.org/git/llvm.git
87 + https://github.com/llvm-mirror/llvm.git"
88 + fi
89 + git-r3_fetch
90 +
91 + if use test; then
92 + git-r3_checkout https://llvm.org/git/llvm.git \
93 + "${WORKDIR}"/llvm '' utils/unittest
94 + fi
95 + git-r3_checkout
96 +}
97 +
98 +src_prepare() {
99 + cmake-utils_src_prepare
100 +
101 + if use test; then
102 + # remove tests that are (still) broken by new glibc
103 + # https://bugs.llvm.org/show_bug.cgi?id=36065
104 + if use elibc_glibc && has_version '>=sys-libs/glibc-2.25'; then
105 + rm test/lsan/TestCases/Linux/use_tls_dynamic.cc || die
106 + rm test/msan/dtls_test.c || die
107 + fi
108 + fi
109 +}
110 +
111 +src_configure() {
112 + # pre-set since we need to pass it to cmake
113 + BUILD_DIR=${WORKDIR}/${P}_build
114 +
115 + if use clang; then
116 + local -x CC=${CHOST}-clang
117 + local -x CXX=${CHOST}-clang++
118 + strip-unsupported-flags
119 + fi
120 +
121 + local mycmakeargs=(
122 + -DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${SLOT}"
123 + # use a build dir structure consistent with install
124 + # this makes it possible to easily deploy test-friendly clang
125 + -DCOMPILER_RT_OUTPUT_DIR="${BUILD_DIR}/lib/clang/${SLOT}"
126 +
127 + -DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
128 + # built-ins installed by sys-libs/compiler-rt
129 + -DCOMPILER_RT_BUILD_BUILTINS=OFF
130 + -DCOMPILER_RT_BUILD_LIBFUZZER=$(usex libfuzzer)
131 + -DCOMPILER_RT_BUILD_PROFILE=$(usex profile)
132 + -DCOMPILER_RT_BUILD_SANITIZERS=$(usex sanitize)
133 + -DCOMPILER_RT_BUILD_XRAY=$(usex xray)
134 + )
135 + if use test; then
136 + mycmakeargs+=(
137 + -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm"
138 + -DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
139 + -DLLVM_LIT_ARGS="-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}"
140 +
141 + # they are created during src_test()
142 + -DCOMPILER_RT_TEST_COMPILER="${BUILD_DIR}/lib/llvm/${CLANG_SLOT}/bin/clang"
143 + -DCOMPILER_RT_TEST_CXX_COMPILER="${BUILD_DIR}/lib/llvm/${CLANG_SLOT}/bin/clang++"
144 + )
145 +
146 + # same flags are passed for build & tests, so we need to strip
147 + # them down to a subset supported by clang
148 + CC=${EPREFIX}/usr/lib/llvm/${CLANG_SLOT}/bin/clang \
149 + CXX=${EPREFIX}/usr/lib/llvm/${CLANG_SLOT}/bin/clang++ \
150 + strip-unsupported-flags
151 + fi
152 +
153 + if use prefix && [[ "${CHOST}" == *-darwin* ]] ; then
154 + mycmakeargs+=(
155 + # disable use of SDK for the system itself
156 + -DDARWIN_macosx_CACHED_SYSROOT=/
157 + )
158 + fi
159 +
160 + cmake-utils_src_configure
161 +
162 + if use test; then
163 + local sys_dir=( "${EPREFIX}"/usr/lib/clang/${SLOT}/lib/* )
164 + [[ -e ${sys_dir} ]] || die "Unable to find ${sys_dir}"
165 + [[ ${#sys_dir[@]} -eq 1 ]] || die "Non-deterministic compiler-rt install: ${sys_dir[*]}"
166 +
167 + # copy clang over since resource_dir is located relatively to binary
168 + # therefore, we can put our new libraries in it
169 + mkdir -p "${BUILD_DIR}"/lib/{llvm/${CLANG_SLOT}/{bin,$(get_libdir)},clang/${SLOT}/include} || die
170 + cp "${EPREFIX}"/usr/lib/llvm/${CLANG_SLOT}/bin/clang{,++} \
171 + "${BUILD_DIR}"/lib/llvm/${CLANG_SLOT}/bin/ || die
172 + cp "${EPREFIX}"/usr/lib/clang/${SLOT}/include/*.h \
173 + "${BUILD_DIR}"/lib/clang/${SLOT}/include/ || die
174 + cp "${sys_dir}"/*builtins*.a \
175 + "${BUILD_DIR}/lib/clang/${SLOT}/lib/${sys_dir##*/}/" || die
176 + # we also need LLVMgold.so for gold-based tests
177 + if [[ -f ${EPREFIX}/usr/lib/llvm/${CLANG_SLOT}/$(get_libdir)/LLVMgold.so ]]; then
178 + ln -s "${EPREFIX}"/usr/lib/llvm/${CLANG_SLOT}/$(get_libdir)/LLVMgold.so \
179 + "${BUILD_DIR}"/lib/llvm/${CLANG_SLOT}/$(get_libdir)/ || die
180 + fi
181 + fi
182 +}
183 +
184 +src_test() {
185 + # respect TMPDIR!
186 + local -x LIT_PRESERVES_TMP=1
187 + # disable sandbox to have it stop clobbering LD_PRELOAD
188 + local -x SANDBOX_ON=0
189 + # wipe LD_PRELOAD to make ASAN happy
190 + local -x LD_PRELOAD=
191 +
192 + cmake-utils_src_make check-all
193 +}