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: Sat, 01 Oct 2016 19:06:04
Message-Id: 1475348751.e0a2bdf2d3c341f08ed2a340f8e33ce83e834893.mgorny@gentoo
1 commit: e0a2bdf2d3c341f08ed2a340f8e33ce83e834893
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 1 16:45:23 2016 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 1 19:05:51 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e0a2bdf2
7
8 sys-libs/compiler-rt-sanitizers: Introduce split ebuild
9
10 .../compiler-rt-sanitizers-9999.ebuild | 114 +++++++++++++++++++++
11 sys-libs/compiler-rt-sanitizers/metadata.xml | 7 ++
12 2 files changed, 121 insertions(+)
13
14 diff --git a/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-9999.ebuild b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-9999.ebuild
15 new file mode 100644
16 index 00000000..044c7b4
17 --- /dev/null
18 +++ b/sys-libs/compiler-rt-sanitizers/compiler-rt-sanitizers-9999.ebuild
19 @@ -0,0 +1,114 @@
20 +# Copyright 1999-2016 Gentoo Foundation
21 +# Distributed under the terms of the GNU General Public License v2
22 +# $Id$
23 +
24 +EAPI=6
25 +
26 +: ${CMAKE_MAKEFILE_GENERATOR:=ninja}
27 +CMAKE_MIN_VERSION=3.4.3
28 +PYTHON_COMPAT=( python2_7 )
29 +
30 +inherit cmake-utils flag-o-matic git-r3 python-single-r1
31 +
32 +DESCRIPTION="Compiler runtime libraries for clang (sanitizers & xray)"
33 +HOMEPAGE="http://llvm.org/"
34 +SRC_URI=""
35 +EGIT_REPO_URI="http://llvm.org/git/compiler-rt.git
36 + https://github.com/llvm-mirror/compiler-rt.git"
37 +
38 +LICENSE="UoI-NCSA"
39 +SLOT="0/${PV%.*}"
40 +KEYWORDS=""
41 +IUSE="test"
42 +
43 +RDEPEND="${PYTHON_DEPS}
44 + !<sys-devel/llvm-${PV}"
45 +DEPEND="${RDEPEND}
46 + ~sys-devel/llvm-${PV}
47 + test? ( ~sys-devel/clang-${PV}
48 + ~sys-libs/compiler-rt-${PV} )
49 + ${PYTHON_DEPS}"
50 +
51 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
52 +
53 +src_unpack() {
54 + if use test; then
55 + # needed for patched gtest
56 + git-r3_fetch "http://llvm.org/git/llvm.git
57 + https://github.com/llvm-mirror/llvm.git"
58 + fi
59 + git-r3_fetch
60 +
61 + if use test; then
62 + git-r3_checkout http://llvm.org/git/llvm.git \
63 + "${WORKDIR}"/llvm
64 + fi
65 + git-r3_checkout
66 +}
67 +
68 +src_configure() {
69 + # pre-set since we need to pass it to cmake
70 + BUILD_DIR=${WORKDIR}/${P}_build
71 +
72 + local clang_version=4.0.0
73 + local libdir=$(get_libdir)
74 + local mycmakeargs=(
75 + # used to find cmake modules
76 + -DLLVM_LIBDIR_SUFFIX="${libdir#lib}"
77 + -DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${clang_version}"
78 + # use a build dir structure consistent with install
79 + # this makes it possible to easily deploy test-friendly clang
80 + -DCOMPILER_RT_OUTPUT_DIR="${BUILD_DIR}/lib/clang/${clang_version}"
81 +
82 + -DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
83 + # built-ins installed by sys-libs/compiler-rt
84 + -DCOMPILER_RT_BUILD_BUILTINS=OFF
85 + -DCOMPILER_RT_BUILD_SANITIZERS=ON
86 + -DCOMPILER_RT_BUILD_XRAY=ON
87 + )
88 + if use test; then
89 + mycmakeargs+=(
90 + -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm"
91 +
92 + # they are created during src_test()
93 + -DCOMPILER_RT_TEST_COMPILER="${BUILD_DIR}/bin/clang"
94 + -DCOMPILER_RT_TEST_CXX_COMPILER="${BUILD_DIR}/bin/clang++"
95 + )
96 +
97 + # same flags are passed for build & tests, so we need to strip
98 + # them down to a subset supported by clang
99 + filter-flags -msahf -frecord-gcc-switches
100 + fi
101 +
102 + cmake-utils_src_configure
103 +
104 + if use test; then
105 + local sys_dir=( "${EPREFIX}/usr/lib/clang/${clang_version}/lib"/* )
106 + [[ -e ${sys_dir} ]] || die "Unable to find ${sys_dir}"
107 + [[ ${#sys_dir[@]} -eq 1 ]] || die "Non-deterministic compiler-rt install: ${sys_dir[@]}"
108 +
109 + # copy clang over since resource_dir is located relatively to binary
110 + # therefore, we can put our new libraries in it
111 + mkdir -p "${BUILD_DIR}"/{bin,lib/clang/"${clang_version}"/include} || die
112 + cp "${EPREFIX}/usr/bin/clang" "${EPREFIX}/usr/bin/clang++" \
113 + "${BUILD_DIR}"/bin/ || die
114 + cp "${EPREFIX}/usr/lib/clang/${clang_version}/include"/*.h \
115 + "${BUILD_DIR}/lib/clang/${clang_version}/include/" || die
116 + cp "${sys_dir}"/*builtins*.a \
117 + "${BUILD_DIR}/lib/clang/${clang_version}/lib/${sys_dir##*/}/" || die
118 + fi
119 +}
120 +
121 +src_test() {
122 + # sandbox breaks libasan tests... and is hard to kill
123 + # so abuse the fail in its algorithms
124 + local -x LD_PRELOAD=${LD_PRELOAD/libsandbox/nolibsandbox}
125 +
126 + cmake-utils_src_make check-all
127 +}
128 +
129 +src_install() {
130 + cmake-utils_src_install
131 +
132 + python_doscript "${S}"/lib/asan/scripts/asan_symbolize.py
133 +}
134
135 diff --git a/sys-libs/compiler-rt-sanitizers/metadata.xml b/sys-libs/compiler-rt-sanitizers/metadata.xml
136 new file mode 100644
137 index 00000000..89c4bdb
138 --- /dev/null
139 +++ b/sys-libs/compiler-rt-sanitizers/metadata.xml
140 @@ -0,0 +1,7 @@
141 +<?xml version="1.0" encoding="UTF-8"?>
142 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
143 +<pkgmetadata>
144 + <maintainer type="project">
145 + <email>llvm@g.o</email>
146 + </maintainer>
147 +</pkgmetadata>