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