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, 03 Jan 2018 22:22:33
Message-Id: 1515018101.0f9e17fd5b75a27b06b83b378e5fcd5732d620b0.mgorny@gentoo
1 commit: 0f9e17fd5b75a27b06b83b378e5fcd5732d620b0
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 3 21:26:01 2018 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 3 22:21:41 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0f9e17fd
7
8 sys-libs/compiler-rt-sanitizers: Add a live ebuild for 6.0 branch
9
10 .../compiler-rt-sanitizers-6.0.9999.ebuild | 150 +++++++++++++++++++++
11 1 file changed, 150 insertions(+)
12
13 diff --git a/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-6.0.9999.ebuild b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-6.0.9999.ebuild
14 new file mode 100644
15 index 00000000000..879e08005bb
16 --- /dev/null
17 +++ b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-6.0.9999.ebuild
18 @@ -0,0 +1,150 @@
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 python-any-r1
30 +
31 +DESCRIPTION="Compiler runtime libraries for clang (sanitizers & xray)"
32 +HOMEPAGE="https://llvm.org/"
33 +SRC_URI=""
34 +EGIT_REPO_URI="https://git.llvm.org/git/compiler-rt.git
35 + https://github.com/llvm-mirror/compiler-rt.git"
36 +EGIT_BRANCH="release_60"
37 +
38 +LICENSE="|| ( UoI-NCSA MIT )"
39 +# Note: this needs to be updated to match version of clang-9999
40 +SLOT="6.0.0"
41 +KEYWORDS=""
42 +IUSE="test"
43 +RESTRICT="!test? ( test )"
44 +
45 +LLVM_SLOT=${SLOT%%.*}
46 +# llvm-4 needed for --cmakedir
47 +DEPEND="
48 + >=sys-devel/llvm-4
49 + test? (
50 + app-portage/unsandbox
51 + $(python_gen_any_dep "~dev-python/lit-${PV}[\${PYTHON_USEDEP}]")
52 + =sys-devel/clang-${PV%_*}*:${LLVM_SLOT}
53 + sys-libs/compiler-rt:${SLOT} )
54 + ${PYTHON_DEPS}"
55 +
56 +# least intrusive of all
57 +CMAKE_BUILD_TYPE=RelWithDebInfo
58 +
59 +check_space() {
60 + if use test; then
61 + local CHECKREQS_DISK_BUILD=11G
62 + check-reqs_pkg_pretend
63 + fi
64 +}
65 +
66 +pkg_pretend() {
67 + check_space
68 +}
69 +
70 +pkg_setup() {
71 + check_space
72 + llvm_pkg_setup
73 + python-any-r1_pkg_setup
74 +}
75 +
76 +src_unpack() {
77 + if use test; then
78 + # needed for patched gtest
79 + git-r3_fetch "https://git.llvm.org/git/llvm.git
80 + https://github.com/llvm-mirror/llvm.git"
81 + fi
82 + git-r3_fetch
83 +
84 + if use test; then
85 + git-r3_checkout https://llvm.org/git/llvm.git \
86 + "${WORKDIR}"/llvm '' utils/unittest
87 + fi
88 + git-r3_checkout
89 +}
90 +
91 +src_configure() {
92 + # pre-set since we need to pass it to cmake
93 + BUILD_DIR=${WORKDIR}/${P}_build
94 +
95 + local mycmakeargs=(
96 + -DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${SLOT}"
97 + # use a build dir structure consistent with install
98 + # this makes it possible to easily deploy test-friendly clang
99 + -DCOMPILER_RT_OUTPUT_DIR="${BUILD_DIR}/lib/clang/${SLOT}"
100 +
101 + -DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
102 + # built-ins installed by sys-libs/compiler-rt
103 + -DCOMPILER_RT_BUILD_BUILTINS=OFF
104 + -DCOMPILER_RT_BUILD_LIBFUZZER=ON
105 + -DCOMPILER_RT_BUILD_PROFILE=ON
106 + -DCOMPILER_RT_BUILD_SANITIZERS=ON
107 + -DCOMPILER_RT_BUILD_XRAY=ON
108 + )
109 + if use test; then
110 + cat > "${T}"/unsandbox-lit.py <<-EOF || die
111 + import os, sys
112 + os.execlp("unsandbox", sys.argv[0], "lit", *sys.argv[1:])
113 + EOF
114 +
115 + mycmakeargs+=(
116 + -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm"
117 + -DLLVM_EXTERNAL_LIT="${T}/unsandbox-lit.py"
118 + -DLLVM_LIT_ARGS="-vv"
119 +
120 + # they are created during src_test()
121 + -DCOMPILER_RT_TEST_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_SLOT}/bin/clang"
122 + -DCOMPILER_RT_TEST_CXX_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_SLOT}/bin/clang++"
123 + )
124 +
125 + # same flags are passed for build & tests, so we need to strip
126 + # them down to a subset supported by clang
127 + CC=${EPREFIX}/usr/lib/llvm/${LLVM_SLOT}/bin/clang \
128 + CXX=${EPREFIX}/usr/lib/llvm/${LLVM_SLOT}/bin/clang++ \
129 + strip-unsupported-flags
130 + fi
131 +
132 + if use prefix && [[ "${CHOST}" == *-darwin* ]] ; then
133 + mycmakeargs+=(
134 + # disable use of SDK for the system itself
135 + -DDARWIN_macosx_CACHED_SYSROOT=/
136 + )
137 + fi
138 +
139 + cmake-utils_src_configure
140 +
141 + if use test; then
142 + local sys_dir=( "${EPREFIX}"/usr/lib/clang/${SLOT}/lib/* )
143 + [[ -e ${sys_dir} ]] || die "Unable to find ${sys_dir}"
144 + [[ ${#sys_dir[@]} -eq 1 ]] || die "Non-deterministic compiler-rt install: ${sys_dir[*]}"
145 +
146 + # copy clang over since resource_dir is located relatively to binary
147 + # therefore, we can put our new libraries in it
148 + mkdir -p "${BUILD_DIR}"/lib/{llvm/${LLVM_SLOT}/{bin,$(get_libdir)},clang/${SLOT}/include} || die
149 + cp "${EPREFIX}"/usr/lib/llvm/${LLVM_SLOT}/bin/clang{,++} \
150 + "${BUILD_DIR}"/lib/llvm/${LLVM_SLOT}/bin/ || die
151 + cp "${EPREFIX}"/usr/lib/clang/${SLOT}/include/*.h \
152 + "${BUILD_DIR}"/lib/clang/${SLOT}/include/ || die
153 + cp "${sys_dir}"/*builtins*.a \
154 + "${BUILD_DIR}/lib/clang/${SLOT}/lib/${sys_dir##*/}/" || die
155 + # we also need LLVMgold.so for gold-based tests
156 + if [[ -f ${EPREFIX}/usr/lib/llvm/${LLVM_SLOT}/$(get_libdir)/LLVMgold.so ]]; then
157 + ln -s "${EPREFIX}"/usr/lib/llvm/${LLVM_SLOT}/$(get_libdir)/LLVMgold.so \
158 + "${BUILD_DIR}"/lib/llvm/${LLVM_SLOT}/$(get_libdir)/ || die
159 + fi
160 + fi
161 +}
162 +
163 +src_test() {
164 + # respect TMPDIR!
165 + local -x LIT_PRESERVES_TMP=1
166 +
167 + cmake-utils_src_make check-all
168 +}