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-devel/clang/
Date: Mon, 24 Jul 2017 19:04:05
Message-Id: 1500923026.d2e809ef8a4145bbcbc79ecb0e9613cca121dfb8.mgorny@gentoo
1 commit: d2e809ef8a4145bbcbc79ecb0e9613cca121dfb8
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jul 23 16:45:14 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Mon Jul 24 19:03:46 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d2e809ef
7
8 sys-devel/clang: Branch for 5.0.0 release
9
10 sys-devel/clang/clang-5.0.9999.ebuild | 277 ++++++++++++++++++++++++++++++++++
11 1 file changed, 277 insertions(+)
12
13 diff --git a/sys-devel/clang/clang-5.0.9999.ebuild b/sys-devel/clang/clang-5.0.9999.ebuild
14 new file mode 100644
15 index 00000000000..df33aa3a8b7
16 --- /dev/null
17 +++ b/sys-devel/clang/clang-5.0.9999.ebuild
18 @@ -0,0 +1,277 @@
19 +# Copyright 1999-2017 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 cmake-utils flag-o-matic git-r3 llvm multilib-minimal \
30 + python-single-r1 toolchain-funcs pax-utils versionator
31 +
32 +DESCRIPTION="C language family frontend for LLVM"
33 +HOMEPAGE="https://llvm.org/"
34 +SRC_URI=""
35 +EGIT_REPO_URI="https://git.llvm.org/git/clang.git
36 + https://github.com/llvm-mirror/clang.git"
37 +EGIT_BRANCH="release_50"
38 +
39 +# Keep in sync with sys-devel/llvm
40 +ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430
41 + NVPTX PowerPC RISCV Sparc SystemZ X86 XCore )
42 +ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
43 +LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?}
44 +
45 +LICENSE="UoI-NCSA"
46 +SLOT="$(get_major_version)"
47 +KEYWORDS=""
48 +IUSE="debug default-compiler-rt default-libcxx +doc multitarget
49 + +static-analyzer test xml z3 elibc_musl kernel_FreeBSD
50 + ${ALL_LLVM_TARGETS[*]}"
51 +
52 +RDEPEND="
53 + ~sys-devel/llvm-${PV}:${SLOT}=[debug=,${LLVM_TARGET_USEDEPS// /,},${MULTILIB_USEDEP}]
54 + static-analyzer? (
55 + dev-lang/perl:*
56 + z3? ( sci-mathematics/z3:0= )
57 + )
58 + xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] )
59 + ${PYTHON_DEPS}"
60 +# configparser-3.2 breaks the build (3.3 or none at all are fine)
61 +DEPEND="${RDEPEND}
62 + doc? ( dev-python/sphinx )
63 + test? ( ~dev-python/lit-${PV}[${PYTHON_USEDEP}] )
64 + xml? ( virtual/pkgconfig )
65 + !!<dev-python/configparser-3.3.0.2
66 + ${PYTHON_DEPS}"
67 +RDEPEND="${RDEPEND}
68 + !<sys-devel/llvm-4.0.0_rc:0
69 + !sys-devel/clang:0"
70 +PDEPEND="
71 + ~sys-devel/clang-runtime-${PV}
72 + default-compiler-rt? ( =sys-libs/compiler-rt-${PV%_*}* )
73 + default-libcxx? ( sys-libs/libcxx )"
74 +
75 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
76 + || ( ${ALL_LLVM_TARGETS[*]} )
77 + multitarget? ( ${ALL_LLVM_TARGETS[*]} )"
78 +
79 +# We need extra level of indirection for CLANG_RESOURCE_DIR
80 +S=${WORKDIR}/x/y/${P}
81 +
82 +# least intrusive of all
83 +CMAKE_BUILD_TYPE=RelWithDebInfo
84 +
85 +# Multilib notes:
86 +# 1. ABI_* flags control ABIs libclang* is built for only.
87 +# 2. clang is always capable of compiling code for all ABIs for enabled
88 +# target. However, you will need appropriate crt* files (installed
89 +# e.g. by sys-devel/gcc and sys-libs/glibc).
90 +# 3. ${CHOST}-clang wrappers are always installed for all ABIs included
91 +# in the current profile (i.e. alike supported by sys-devel/gcc).
92 +#
93 +# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
94 +# multilib clang* libraries (not runtime, not wrappers).
95 +
96 +pkg_setup() {
97 + LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
98 + python-single-r1_pkg_setup
99 +}
100 +
101 +src_unpack() {
102 + # create extra parent dir for CLANG_RESOURCE_DIR
103 + mkdir -p x/y || die
104 + cd x/y || die
105 +
106 + git-r3_fetch "https://git.llvm.org/git/clang-tools-extra.git
107 + https://github.com/llvm-mirror/clang-tools-extra.git"
108 + if use test; then
109 + # needed for patched gtest
110 + git-r3_fetch "https://git.llvm.org/git/llvm.git
111 + https://github.com/llvm-mirror/llvm.git"
112 + fi
113 + git-r3_fetch
114 +
115 + git-r3_checkout https://llvm.org/git/clang-tools-extra.git \
116 + "${S}"/tools/extra
117 + if use test; then
118 + git-r3_checkout https://llvm.org/git/llvm.git \
119 + "${WORKDIR}"/llvm
120 + fi
121 + git-r3_checkout "${EGIT_REPO_URI}" "${S}"
122 +}
123 +
124 +src_prepare() {
125 + # fix finding compiler-rt libs
126 + eapply "${FILESDIR}"/9999/0001-Driver-Use-arch-type-to-find-compiler-rt-libraries-o.patch
127 +
128 + # fix stand-alone doc build
129 + eapply "${FILESDIR}"/9999/0007-cmake-Support-stand-alone-Sphinx-doxygen-doc-build.patch
130 +
131 + # User patches
132 + eapply_user
133 +}
134 +
135 +multilib_src_configure() {
136 + local llvm_version=$(llvm-config --version) || die
137 + local clang_version=$(get_version_component_range 1-3 "${llvm_version}")
138 +
139 + local mycmakeargs=(
140 + # ensure that the correct llvm-config is used
141 + -DLLVM_CONFIG="$(type -P "${CHOST}-llvm-config")"
142 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}"
143 + # relative to bindir
144 + -DCLANG_RESOURCE_DIR="../../../../lib/clang/${clang_version}"
145 +
146 + -DBUILD_SHARED_LIBS=ON
147 + -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}"
148 + -DLLVM_BUILD_TESTS=$(usex test)
149 +
150 + # these are not propagated reliably, so redefine them
151 + -DLLVM_ENABLE_EH=ON
152 + -DLLVM_ENABLE_RTTI=ON
153 +
154 + -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=$(usex !xml)
155 + # libgomp support fails to find headers without explicit -I
156 + # furthermore, it provides only syntax checking
157 + -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp
158 +
159 + # override default stdlib and rtlib
160 + -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "")
161 + -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "")
162 +
163 + -DCLANG_ENABLE_ARCMT=$(usex static-analyzer)
164 + -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer)
165 + # z3 is not multilib-friendly
166 + -DCLANG_ANALYZER_BUILD_Z3=$(multilib_native_usex z3)
167 + -DZ3_INCLUDE_DIR="${EPREFIX}/usr/include/z3"
168 + )
169 + use test && mycmakeargs+=(
170 + -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm"
171 + -DLIT_COMMAND="${EPREFIX}/usr/bin/lit"
172 + )
173 +
174 + if multilib_is_native_abi; then
175 + mycmakeargs+=(
176 + -DLLVM_BUILD_DOCS=$(usex doc)
177 + -DLLVM_ENABLE_SPHINX=$(usex doc)
178 + -DLLVM_ENABLE_DOXYGEN=OFF
179 + )
180 + use doc && mycmakeargs+=(
181 + -DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html"
182 + -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra"
183 + -DSPHINX_WARNINGS_AS_ERRORS=OFF
184 + )
185 + else
186 + mycmakeargs+=(
187 + -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF
188 + )
189 + fi
190 +
191 + if tc-is-cross-compiler; then
192 + [[ -x "/usr/bin/clang-tblgen" ]] \
193 + || die "/usr/bin/clang-tblgen not found or usable"
194 + mycmakeargs+=(
195 + -DCMAKE_CROSSCOMPILING=ON
196 + -DCLANG_TABLEGEN=/usr/bin/clang-tblgen
197 + )
198 + fi
199 +
200 + # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
201 + use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
202 + cmake-utils_src_configure
203 +}
204 +
205 +multilib_src_compile() {
206 + cmake-utils_src_compile
207 +
208 + # provide a symlink for tests
209 + if [[ ! -L ${WORKDIR}/lib/clang ]]; then
210 + mkdir -p "${WORKDIR}"/lib || die
211 + ln -s "${BUILD_DIR}/$(get_libdir)/clang" "${WORKDIR}"/lib/clang || die
212 + fi
213 +}
214 +
215 +multilib_src_test() {
216 + # respect TMPDIR!
217 + local -x LIT_PRESERVES_TMP=1
218 + cmake-utils_src_make check-clang
219 + multilib_is_native_abi && cmake-utils_src_make check-clang-tools
220 +}
221 +
222 +src_install() {
223 + MULTILIB_WRAPPED_HEADERS=(
224 + /usr/include/clang/Config/config.h
225 + )
226 +
227 + multilib-minimal_src_install
228 +
229 + # Move runtime headers to /usr/lib/clang, where they belong
230 + mv "${ED%/}"/usr/include/clangrt "${ED%/}"/usr/lib/clang || die
231 + # move (remaining) wrapped headers back
232 + mv "${ED%/}"/usr/include "${ED%/}"/usr/lib/llvm/${SLOT}/include || die
233 +
234 + # Apply CHOST and version suffix to clang tools
235 + # note: we use two version components here (vs 3 in runtime path)
236 + local llvm_version=$(llvm-config --version) || die
237 + local clang_version=$(get_version_component_range 1-2 "${llvm_version}")
238 + local clang_full_version=$(get_version_component_range 1-3 "${llvm_version}")
239 + local clang_tools=( clang clang++ clang-cl clang-cpp )
240 + local abi i
241 +
242 + # cmake gives us:
243 + # - clang-X.Y
244 + # - clang -> clang-X.Y
245 + # - clang++, clang-cl, clang-cpp -> clang
246 + # we want to have:
247 + # - clang-X.Y
248 + # - clang++-X.Y, clang-cl-X.Y, clang-cpp-X.Y -> clang-X.Y
249 + # - clang, clang++, clang-cl, clang-cpp -> clang*-X.Y
250 + # also in CHOST variant
251 + for i in "${clang_tools[@]:1}"; do
252 + rm "${ED%/}/usr/lib/llvm/${SLOT}/bin/${i}" || die
253 + dosym "clang-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}-${clang_version}"
254 + dosym "${i}-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}"
255 + done
256 +
257 + # now create target symlinks for all supported ABIs
258 + for abi in $(get_all_abis); do
259 + local abi_chost=$(get_abi_CHOST "${abi}")
260 + for i in "${clang_tools[@]}"; do
261 + dosym "${i}-${clang_version}" \
262 + "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}-${clang_version}"
263 + dosym "${abi_chost}-${i}-${clang_version}" \
264 + "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}"
265 + done
266 + done
267 +
268 + # Remove unnecessary headers on FreeBSD, bug #417171
269 + if use kernel_FreeBSD; then
270 + rm "${ED}"usr/lib/clang/${clang_full_version}/include/{std,float,iso,limits,tgmath,varargs}*.h || die
271 + fi
272 +}
273 +
274 +multilib_src_install() {
275 + cmake-utils_src_install
276 +
277 + # move headers to /usr/include for wrapping & ABI mismatch checks
278 + # (also drop the version suffix from runtime headers)
279 + rm -rf "${ED%/}"/usr/include || die
280 + mv "${ED%/}"/usr/lib/llvm/${SLOT}/include "${ED%/}"/usr/include || die
281 + mv "${ED%/}"/usr/lib/llvm/${SLOT}/$(get_libdir)/clang "${ED%/}"/usr/include/clangrt || die
282 +}
283 +
284 +multilib_src_install_all() {
285 + python_fix_shebang "${ED}"
286 + if use static-analyzer; then
287 + python_optimize "${ED}"usr/lib/llvm/${SLOT}/share/scan-view
288 + fi
289 +
290 + docompress "/usr/lib/llvm/${SLOT}/share/man"
291 + # match 'html' non-compression
292 + use doc && docompress -x "/usr/share/doc/${PF}/tools-extra"
293 + # +x for some reason; TODO: investigate
294 + use static-analyzer && fperms a-x "/usr/lib/llvm/${SLOT}/share/man/man1/scan-build.1"
295 +}