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/llvm/
Date: Sat, 03 Jun 2017 08:27:58
Message-Id: 1496478451.e4b8cce48ee941fe06b2b6097defcd36efe66ab0.mgorny@gentoo
1 commit: e4b8cce48ee941fe06b2b6097defcd36efe66ab0
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 24 11:32:54 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat Jun 3 08:27:31 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e4b8cce4
7
8 sys-devel/llvm: Minimize 3.5 to be Darwin Prefix-compat only
9
10 sys-devel/llvm/Manifest | 1 -
11 sys-devel/llvm/llvm-3.5.2-r100.ebuild | 275 +++++++++++++++++
12 sys-devel/llvm/llvm-3.5.2.ebuild | 550 ----------------------------------
13 3 files changed, 275 insertions(+), 551 deletions(-)
14
15 diff --git a/sys-devel/llvm/Manifest b/sys-devel/llvm/Manifest
16 index 15ae027fa75..a0cc649999f 100644
17 --- a/sys-devel/llvm/Manifest
18 +++ b/sys-devel/llvm/Manifest
19 @@ -5,7 +5,6 @@ DIST cfe-3.7.1.src.tar.xz 9110616 SHA256 56e2164c7c2a1772d5ed2a3e57485ff73ff06c9
20 DIST cfe-3.8.1.src.tar.xz 9605548 SHA256 4cd3836dfb4b88b597e075341cae86d61c63ce3963e45c7fe6a8bf59bb382cdf SHA512 72d23a410271b50f97371b13dd7a6c6c5c0a993e35df436ab716ece8521d83406aa3d4bf8fdecd8154139f39fd5e011e480d405225d8c3ff152d0a2ac4573e04 WHIRLPOOL 7bcc9e6fed871b7490e2a280f2ad36008150a0af3605357fbe529aea8a7acbbed41c7da273dd150f8f50869cd321f114e909236261c4dd05ed7f644c75f208c4
21 DIST cfe-3.9.0.src.tar.xz 10390440 SHA256 7596a7c7d9376d0c89e60028fe1ceb4d3e535e8ea8b89e0eb094e0dcb3183d28 SHA512 f405b5819fd19276b2de4da80a51171a3b1c5c00df810e1f284184c693e410775fe2933576f942b881664dd3b75e78f0f15b7e5a3eca7819ffbcfe528d9a578e WHIRLPOOL cb4ff4eaababa3017b4a96548b7fe1dc5f4926bd27dc6de56c3ae1fc450c8af1faf1edea2e909e40289477ebaf79860fca3a9695b22402dc9385031d7b8ad5bf
22 DIST cfe-3.9.1.src.tar.xz 10363080 SHA256 e6c4cebb96dee827fa0470af313dff265af391cb6da8d429842ef208c8f25e63 SHA512 3f0eea194597e438bbe49ce9ef5fdced81459c21cbdd2653750b2fe02c55a0154d6a33a8cfd02e607b83314a8e35b2c300f944462120ab6de1d4139d85db56b8 WHIRLPOOL 9f70688c7c2857426bf5fbf039b9723ec73ec57e8d3b36da37589bcbdbdb090aa36cd1800f0521ef0c30065bf03083eade0ac81ef0939412919423db7779a6f8
23 -DIST clang-tools-extra-3.5.2.src.tar.xz 215804 SHA256 f21a374d74b194d8c984546266491b518859b5f12ed9abd49337b8060d3fc004 SHA512 6a8e662d2704147296c13626fbc5885911c646c67404f12eacc67ee2995221445bf4f6122b271b9cb3a56b716f550a651024822f72358d400b9052bf50423669 WHIRLPOOL 088d2725a88a439a1a2c4048e0eaf540587078078bd1c9823a4804200265cab4d32606abf5e72be76da45ea4aa6e7a7201a2bdbddc78d5f9e0024b0d7b59e222
24 DIST clang-tools-extra-3.6.2.src.tar.xz 248624 SHA256 6a0ec627d398f501ddf347060f7a2ccea4802b2494f1d4fd7bda3e0442d04feb SHA512 1b7710a7deee30cefb6a3b4edb026a96d8935a0c6f3056ccdb7a45564d10baf01a4f6722ae853ad9a3bad17e8de32a3c0ec99c5cf6144647a5e182809d403f7a WHIRLPOOL 3dc8888c302bac84f53b673784dec092a2c59ea2985d9983e87f057b9aa7b5d3e34cf13d2b0f1f60ea44f342b8167377204a510036872a087037cf02335c19cd
25 DIST clang-tools-extra-3.7.1.src.tar.xz 277476 SHA256 4a91edaccad1ce984c7c49a4a87db186b7f7b21267b2b03bcf4bd7820715bc6b SHA512 06e2db8af75f1e6ee82da6ee723b5256b9e3f6ba196428f18944ec02d07df26d04329ca8824a083c5f25274ce7e3469aa75e3a29ccfbdb6375524841d65e3ad7 WHIRLPOOL 2c1a459d6aff6bc24d5c8d38120ab665adbef61394050781a9707d50e83dae1b4997ed19459086e9bd7f6dd38a09c295d135e33515c947d64a7f1ab714ad8beb
26 DIST clang-tools-extra-3.8.1.src.tar.xz 334768 SHA256 664a5c60220de9c290bf2a5b03d902ab731a4f95fe73a00856175ead494ec396 SHA512 ec8c4a6ac4fd1a0e24fc15e56ba00828e0d718c2f7bd477ea134ab094c67f4f4b2f603f128ec11a03b7f25f3e9b8fe75181e40730c56b7b683f54e3f37573137 WHIRLPOOL b05213cbe21b778e718233cecbf4d01b92c1f133eced6fdd3fa5059c4b10e5f0407549634f65032af177ba1614250f5c02e283c2b03563db3e227b1afcae424b
27
28 diff --git a/sys-devel/llvm/llvm-3.5.2-r100.ebuild b/sys-devel/llvm/llvm-3.5.2-r100.ebuild
29 new file mode 100644
30 index 00000000000..d6512fff863
31 --- /dev/null
32 +++ b/sys-devel/llvm/llvm-3.5.2-r100.ebuild
33 @@ -0,0 +1,275 @@
34 +# Copyright 1999-2017 Gentoo Foundation
35 +# Distributed under the terms of the GNU General Public License v2
36 +
37 +EAPI=5
38 +
39 +PYTHON_COMPAT=( python2_7 )
40 +inherit eutils check-reqs flag-o-matic multilib pax-utils prefix \
41 + python-any-r1 toolchain-funcs
42 +
43 +DESCRIPTION="Low Level Virtual Machine"
44 +HOMEPAGE="http://llvm.org/"
45 +SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz
46 + clang? ( http://llvm.org/releases/${PV}/compiler-rt-${PV}.src.tar.xz
47 + http://llvm.org/releases/${PV}/cfe-${PV}.src.tar.xz )
48 + https://dev.gentoo.org/~voyageur/distfiles/${PN}-3.5.0-manpages.tar.bz2"
49 +
50 +# Additional licenses:
51 +# 1. OpenBSD regex: Henry Spencer's license ('rc' in Gentoo) + BSD.
52 +# 2. ARM backend: LLVM Software Grant by ARM.
53 +# 3. MD5 code: public-domain.
54 +# 4. autoconf (not installed): some undefined M.I.T. license.
55 +# 5. Tests (not installed):
56 +# a. gtest: BSD.
57 +# b. YAML tests: MIT.
58 +
59 +LICENSE="UoI-NCSA rc BSD public-domain"
60 +SLOT="0/3.5"
61 +KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
62 +IUSE="clang +libffi"
63 +
64 +COMMON_DEPEND="
65 + sys-libs/zlib:0=
66 + libffi? ( >=virtual/libffi-3.0.13-r1:0= )"
67 +# configparser-3.2 breaks the build (3.3 or none at all are fine)
68 +DEPEND="${COMMON_DEPEND}
69 + app-arch/xz-utils
70 + dev-lang/perl
71 + >=sys-devel/make-3.81
72 + >=sys-devel/flex-2.5.4
73 + >=sys-devel/bison-1.875d
74 + || ( >=sys-devel/gcc-apple-4.2.1 >=sys-devel/llvm-3.3 )
75 + >=sys-devel/binutils-apple-5.1
76 + libffi? ( virtual/pkgconfig )
77 + !!<dev-python/configparser-3.3.0.2
78 + ${PYTHON_DEPS}"
79 +RDEPEND="${COMMON_DEPEND}
80 + clang? ( !<=sys-devel/clang-${PV}-r99
81 + !>=sys-devel/clang-9999 )"
82 +PDEPEND="clang? ( =sys-devel/clang-${PV}-r100 )"
83 +
84 +S=${WORKDIR}/${P}.src
85 +
86 +check_space() {
87 + # in megs
88 + # !clang !debug !multitarget -O2 400
89 + # !clang !debug multitarget -O2 550
90 + # clang !debug !multitarget -O2 950
91 + # clang !debug multitarget -O2 1200
92 + # !clang debug multitarget -O2 5G
93 + # clang !debug multitarget -O0 -g 12G
94 + # clang debug multitarget -O2 16G
95 + # clang debug multitarget -O0 -g 14G
96 +
97 + local build_size=550
98 + use clang && build_size=1200
99 +
100 + if is-flagq '-g?(gdb)?([1-9])'; then
101 + ewarn "The C++ compiler -g option is known to increase the size of the package"
102 + ewarn "considerably. If you run out of space, please consider removing it."
103 + ewarn
104 +
105 + (( build_size *= 10 ))
106 + fi
107 +
108 + local CHECKREQS_DISK_BUILD=${build_size}M
109 + check-reqs_pkg_pretend
110 +
111 + if [[ ${MERGE_TYPE} != binary ]]; then
112 + echo 'int main() {return 0;}' > "${T}"/test.cxx || die
113 + ebegin "Trying to build a C++11 test program"
114 + if ! $(tc-getCXX) -std=c++11 -o /dev/null "${T}"/test.cxx; then
115 + eerror "LLVM-${PV} requires C++11-capable C++ compiler. Your current compiler"
116 + eerror "does not seem to support -std=c++11 option. Please upgrade your compiler"
117 + eerror "to gcc-4.7 or an equivalent version supporting C++11."
118 + die "Currently active compiler does not support -std=c++11"
119 + fi
120 + eend ${?}
121 + fi
122 +}
123 +
124 +pkg_pretend() {
125 + check_space
126 +}
127 +
128 +pkg_setup() {
129 + check_space
130 +}
131 +
132 +src_unpack() {
133 + default
134 +
135 + rm -f "${S}"/tools/clang "${S}"/projects/compiler-rt \
136 + || die "symlinks removal failed"
137 +
138 + if use clang; then
139 + mv "${WORKDIR}"/cfe-${PV}.src "${S}"/tools/clang \
140 + || die "clang source directory move failed"
141 + mv "${WORKDIR}"/compiler-rt-${PV}.src "${S}"/projects/compiler-rt \
142 + || die "compiler-rt source directory move failed"
143 + fi
144 +}
145 +
146 +src_prepare() {
147 + epatch "${FILESDIR}"/3.6.2/nodoctargz.patch
148 + epatch "${FILESDIR}"/3.6.2/gcc-4.9.patch
149 + epatch "${FILESDIR}"/3.5.2/gentoo-install.patch
150 + epatch "${FILESDIR}"/3.5.2/gcc-5.1.patch
151 +
152 + if use clang; then
153 + # Automatically select active system GCC's libraries, bugs #406163 and #417913
154 + epatch "${FILESDIR}"/3.9.0/clang/gentoo-runtime-gcc-detection-v3.patch
155 +
156 + epatch "${FILESDIR}"/3.5.2/clang/gentoo-install.patch
157 + epatch "${FILESDIR}"/3.9.1/clang/darwin_prefix-include-paths.patch
158 + eprefixify tools/clang/lib/Frontend/InitHeaderSearch.cpp
159 + fi
160 +
161 + if use prefix && use clang; then
162 + sed -i -e "/^CFLAGS /s@-Werror@-I${EPREFIX}/usr/include@" \
163 + projects/compiler-rt/make/platform/clang_*.mk || die
164 + fi
165 +
166 + # disable use of SDK on OSX, bug #568758
167 + sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die
168 +
169 + local sub_files=(
170 + Makefile.config.in
171 + Makefile.rules
172 + tools/llvm-config/llvm-config.cpp
173 + )
174 + use clang && sub_files+=(
175 + tools/clang/lib/Driver/Tools.cpp
176 + tools/clang/tools/scan-build/scan-build
177 + )
178 +
179 + # unfortunately ./configure won't listen to --mandir and the-like, so take
180 + # care of this.
181 + # note: we're setting the main libdir intentionally.
182 + # where per-ABI is appropriate, we use $(GENTOO_LIBDIR) make.
183 + einfo "Fixing install dirs"
184 + sed -e "s,@libdir@,$(get_libdir),g" \
185 + -e "s,@PF@,${PF},g" \
186 + -e "s,@EPREFIX@,${EPREFIX},g" \
187 + -i "${sub_files[@]}" \
188 + || die "install paths sed failed"
189 +
190 + if use clang; then
191 + # constantly fails for a long time, likely due to our patches
192 + rm tools/clang/test/Driver/cross-linux.c || die
193 + fi
194 +
195 + # User patches
196 + epatch_user
197 +
198 + python_setup
199 +}
200 +
201 +src_configure() {
202 + # disable timestamps since they confuse ccache
203 + local conf_flags=(
204 + --disable-timestamps
205 + --enable-keep-symbols
206 + --enable-shared
207 + --with-optimize-option=
208 + --enable-optimized
209 + --disable-assertions
210 + --disable-expensive-checks
211 + --disable-libedit
212 + --disable-terminfo
213 + $(use_enable libffi)
214 +
215 + --enable-bindings=none
216 + --enable-targets=host
217 +
218 + ac_cv_prog_XML2CONFIG=""
219 + )
220 +
221 + if use libffi; then
222 + local CPPFLAGS=${CPPFLAGS}
223 + append-cppflags "$($(tc-getPKG_CONFIG) --cflags libffi)"
224 + fi
225 +
226 + # llvm prefers clang over gcc, so we may need to force that
227 + tc-export CC CXX
228 +
229 + ECONF_SOURCE=${S} \
230 + econf "${conf_flags[@]}"
231 +}
232 +
233 +src_compile() {
234 + LLVM_MAKEARGS=(
235 + VERBOSE=1
236 + REQUIRES_RTTI=1
237 + GENTOO_LIBDIR=$(get_libdir)
238 + )
239 +
240 + emake "${LLVM_MAKEARGS[@]}"
241 +
242 + pax-mark m Release/bin/llvm-rtdyld
243 + pax-mark m Release/bin/lli
244 + pax-mark m Release/bin/lli-child-target
245 +}
246 +
247 +src_install() {
248 + emake "${LLVM_MAKEARGS[@]}" DESTDIR="${D}" install
249 +
250 + if ! use clang; then
251 + rm "${WORKDIR}"/${PN}-3.5.0-manpages/clang.1 || die
252 + else
253 + for tool in clang{,++} ; do
254 + dosym ${tool} /usr/bin/${CHOST}-${tool}
255 + done
256 + fi
257 + doman "${WORKDIR}"/${PN}-3.5.0-manpages/*.1
258 +
259 + # Fix install_names on Darwin. The build system is too complicated
260 + # to just fix this, so we correct it post-install
261 + local lib= f= odylib= ndylib= libpv=${PV}
262 + if [[ ${CHOST} == *-darwin* ]] ; then
263 + eval $(grep PACKAGE_VERSION= configure)
264 + [[ -n ${PACKAGE_VERSION} ]] && libpv=${PACKAGE_VERSION}
265 + libpvminor=${libpv%.[0-9]*}
266 + for lib in lib{EnhancedDisassembly,LLVM-${libpv},LTO,profile_rt,clang}.dylib LLVMHello.dylib clang/${libpv}/lib/darwin/libclang_rt.asan_{osx,iossim}_dynamic.dylib; do
267 + # libEnhancedDisassembly is Darwin10 only, so non-fatal
268 + # + omit clang libs if not enabled
269 + [[ -f ${ED}/usr/lib/${lib} ]] || continue
270 +
271 + ebegin "fixing install_name of $lib"
272 + install_name_tool \
273 + -id "${EPREFIX}"/usr/lib/${lib} \
274 + "${ED}"/usr/lib/${lib}
275 + eend $?
276 + done
277 + for f in "${ED}"/usr/bin/* "${ED}"/usr/lib/lib*.dylib "${ED}"/usr/lib/clang/${libpv}/lib/darwin/*.dylib ; do
278 + # omit clang libs if not enabled
279 + [[ -f "${f}" ]] || continue
280 +
281 + scanmacho -BF'%n#f' "${f}" | tr ',' '\n' | \
282 + while read odylib ; do
283 + ndylib=
284 + case ${odylib} in
285 + */libclang.dylib)
286 + ndylib="${EPREFIX}"/usr/lib/libclang.dylib
287 + ;;
288 + */libLLVM-${libpv}.dylib)
289 + ndylib="${EPREFIX}"/usr/lib/libLLVM-${libpv}.dylib
290 + ;;
291 + */libLLVM-${libpvminor}.dylib)
292 + ndylib="${EPREFIX}"/usr/lib/libLLVM-${libpvminor}.dylib
293 + ;;
294 + */libLTO.dylib)
295 + ndylib="${EPREFIX}"/usr/lib/libLTO.dylib
296 + ;;
297 + esac
298 + if [[ -n ${ndylib} ]] ; then
299 + ebegin "fixing install_name reference to ${odylib} of ${f##*/}"
300 + install_name_tool \
301 + -change "${odylib}" "${ndylib}" \
302 + "${f}"
303 + eend $?
304 + fi
305 + done
306 + done
307 + fi
308 +}
309
310 diff --git a/sys-devel/llvm/llvm-3.5.2.ebuild b/sys-devel/llvm/llvm-3.5.2.ebuild
311 deleted file mode 100644
312 index dafbd5aa1f1..00000000000
313 --- a/sys-devel/llvm/llvm-3.5.2.ebuild
314 +++ /dev/null
315 @@ -1,550 +0,0 @@
316 -# Copyright 1999-2017 Gentoo Foundation
317 -# Distributed under the terms of the GNU General Public License v2
318 -
319 -EAPI=5
320 -
321 -PYTHON_COMPAT=( python2_7 pypy )
322 -
323 -inherit eutils flag-o-matic multibuild multilib \
324 - multilib-minimal python-r1 toolchain-funcs pax-utils check-reqs prefix
325 -
326 -DESCRIPTION="Low Level Virtual Machine"
327 -HOMEPAGE="http://llvm.org/"
328 -SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz
329 - clang? ( http://llvm.org/releases/${PV}/compiler-rt-${PV}.src.tar.xz
330 - http://llvm.org/releases/${PV}/cfe-${PV}.src.tar.xz
331 - http://llvm.org/releases/${PV}/clang-tools-extra-${PV}.src.tar.xz )
332 - !doc? ( https://dev.gentoo.org/~voyageur/distfiles/${PN}-3.5.0-manpages.tar.bz2 )"
333 -
334 -# Additional licenses:
335 -# 1. OpenBSD regex: Henry Spencer's license ('rc' in Gentoo) + BSD.
336 -# 2. ARM backend: LLVM Software Grant by ARM.
337 -# 3. MD5 code: public-domain.
338 -# 4. autoconf (not installed): some undefined M.I.T. license.
339 -# 5. Tests (not installed):
340 -# a. gtest: BSD.
341 -# b. YAML tests: MIT.
342 -
343 -LICENSE="UoI-NCSA rc BSD public-domain
344 - arm? ( LLVM-Grant )
345 - arm64? ( LLVM-Grant )
346 - multitarget? ( LLVM-Grant )"
347 -SLOT="0/3.5"
348 -KEYWORDS="~amd64 ~arm ~arm64 ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
349 -IUSE="clang debug doc gold libedit +libffi multitarget ncurses ocaml python
350 - +static-analyzer test xml video_cards_radeon
351 - kernel_Darwin kernel_FreeBSD"
352 -
353 -COMMON_DEPEND="
354 - sys-libs/zlib:0=
355 - clang? (
356 - python? ( ${PYTHON_DEPS} )
357 - static-analyzer? (
358 - dev-lang/perl:*
359 - ${PYTHON_DEPS}
360 - )
361 - xml? ( dev-libs/libxml2:2= )
362 - )
363 - gold? ( >=sys-devel/binutils-2.22:*[cxx] )
364 - libedit? ( dev-libs/libedit:0=[${MULTILIB_USEDEP}] )
365 - libffi? ( >=virtual/libffi-3.0.13-r1:0=[${MULTILIB_USEDEP}] )
366 - ncurses? ( >=sys-libs/ncurses-5.9-r3:0=[${MULTILIB_USEDEP}] )
367 - ocaml? ( dev-lang/ocaml:0= )"
368 -# configparser-3.2 breaks the build (3.3 or none at all are fine)
369 -DEPEND="${COMMON_DEPEND}
370 - app-arch/xz-utils
371 - dev-lang/perl
372 - >=sys-devel/make-3.81
373 - >=sys-devel/flex-2.5.4
374 - >=sys-devel/bison-1.875d
375 - || ( >=sys-devel/gcc-3.0 >=sys-devel/llvm-3.3
376 - ( >=sys-freebsd/freebsd-lib-9.1-r10 sys-libs/libcxx )
377 - )
378 - || ( >=sys-devel/binutils-2.18 >=sys-devel/binutils-apple-5.1 )
379 - clang? ( xml? ( virtual/pkgconfig ) )
380 - doc? ( dev-python/sphinx )
381 - libffi? ( virtual/pkgconfig )
382 - !!<dev-python/configparser-3.3.0.2
383 - ${PYTHON_DEPS}"
384 -RDEPEND="${COMMON_DEPEND}
385 - clang? ( !<=sys-devel/clang-${PV}-r99
386 - !>=sys-devel/clang-9999 )
387 - abi_x86_32? ( !<=app-emulation/emul-linux-x86-baselibs-20130224-r2
388 - !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)] )"
389 -PDEPEND="clang? ( =sys-devel/clang-${PV}-r100 )
390 - kernel_Darwin? ( =sys-libs/libcxx-${SLOT#*/}* )"
391 -
392 -# pypy gives me around 1700 unresolved tests due to open file limit
393 -# being exceeded. probably GC does not close them fast enough.
394 -REQUIRED_USE="${PYTHON_REQUIRED_USE}
395 - test? ( || ( $(python_gen_useflags 'python*') ) )"
396 -
397 -S=${WORKDIR}/${P}.src
398 -
399 -# Some people actually override that in make.conf. That sucks since
400 -# we need to run install per-directory, and ninja can't do that...
401 -# so why did it call itself ninja in the first place?
402 -CMAKE_MAKEFILE_GENERATOR=emake
403 -
404 -check_space() {
405 - # in megs
406 - # !clang !debug !multitarget -O2 400
407 - # !clang !debug multitarget -O2 550
408 - # clang !debug !multitarget -O2 950
409 - # clang !debug multitarget -O2 1200
410 - # !clang debug multitarget -O2 5G
411 - # clang !debug multitarget -O0 -g 12G
412 - # clang debug multitarget -O2 16G
413 - # clang debug multitarget -O0 -g 14G
414 -
415 - local build_size=550
416 - use clang && build_size=1200
417 -
418 - if use debug; then
419 - ewarn "USE=debug is known to increase the size of package considerably"
420 - ewarn "and cause the tests to fail."
421 - ewarn
422 -
423 - (( build_size *= 14 ))
424 - elif is-flagq '-g?(gdb)?([1-9])'; then
425 - ewarn "The C++ compiler -g option is known to increase the size of the package"
426 - ewarn "considerably. If you run out of space, please consider removing it."
427 - ewarn
428 -
429 - (( build_size *= 10 ))
430 - fi
431 -
432 - # Multiply by number of ABIs :).
433 - local abis=( $(multilib_get_enabled_abis) )
434 - (( build_size *= ${#abis[@]} ))
435 -
436 - local CHECKREQS_DISK_BUILD=${build_size}M
437 - check-reqs_pkg_pretend
438 -
439 - if [[ ${MERGE_TYPE} != binary ]]; then
440 - echo 'int main() {return 0;}' > "${T}"/test.cxx || die
441 - ebegin "Trying to build a C++11 test program"
442 - if ! $(tc-getCXX) -std=c++11 -o /dev/null "${T}"/test.cxx; then
443 - eerror "LLVM-${PV} requires C++11-capable C++ compiler. Your current compiler"
444 - eerror "does not seem to support -std=c++11 option. Please upgrade your compiler"
445 - eerror "to gcc-4.7 or an equivalent version supporting C++11."
446 - die "Currently active compiler does not support -std=c++11"
447 - fi
448 - eend ${?}
449 - fi
450 -}
451 -
452 -pkg_pretend() {
453 - check_space
454 -}
455 -
456 -pkg_setup() {
457 - check_space
458 -}
459 -
460 -src_unpack() {
461 - default
462 -
463 - rm -f "${S}"/tools/clang "${S}"/projects/compiler-rt \
464 - || die "symlinks removal failed"
465 -
466 - if use clang; then
467 - mv "${WORKDIR}"/cfe-${PV}.src "${S}"/tools/clang \
468 - || die "clang source directory move failed"
469 - mv "${WORKDIR}"/compiler-rt-${PV}.src "${S}"/projects/compiler-rt \
470 - || die "compiler-rt source directory move failed"
471 - mv "${WORKDIR}"/clang-tools-extra-${PV}.src "${S}"/tools/clang/tools/extra \
472 - || die "clang-tools-extra source directory move failed"
473 - fi
474 -}
475 -
476 -src_prepare() {
477 - epatch "${FILESDIR}"/3.6.2/nodoctargz.patch
478 - epatch "${FILESDIR}"/3.6.2/gcc-4.9.patch
479 - epatch "${FILESDIR}"/3.5.2/gentoo-install.patch
480 - epatch "${FILESDIR}"/3.5.2/gcc-5.1.patch
481 - # Make ocaml warnings non-fatal, bug #537308
482 - sed -e "/RUN/s/-warn-error A//" -i test/Bindings/Ocaml/*ml || die
483 -
484 - if use clang; then
485 - # Automatically select active system GCC's libraries, bugs #406163 and #417913
486 - epatch "${FILESDIR}"/3.9.0/clang/gentoo-runtime-gcc-detection-v3.patch
487 -
488 - epatch "${FILESDIR}"/3.5.2/clang/gentoo-install.patch
489 - epatch "${FILESDIR}"/3.9.1/clang/darwin_prefix-include-paths.patch
490 - eprefixify tools/clang/lib/Frontend/InitHeaderSearch.cpp
491 - fi
492 -
493 - if use prefix && use clang; then
494 - sed -i -e "/^CFLAGS /s@-Werror@-I${EPREFIX}/usr/include@" \
495 - projects/compiler-rt/make/platform/clang_*.mk || die
496 - fi
497 -
498 - # disable use of SDK on OSX, bug #568758
499 - sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die
500 -
501 - local sub_files=(
502 - Makefile.config.in
503 - Makefile.rules
504 - tools/llvm-config/llvm-config.cpp
505 - )
506 - use clang && sub_files+=(
507 - tools/clang/lib/Driver/Tools.cpp
508 - tools/clang/tools/scan-build/scan-build
509 - )
510 -
511 - # unfortunately ./configure won't listen to --mandir and the-like, so take
512 - # care of this.
513 - # note: we're setting the main libdir intentionally.
514 - # where per-ABI is appropriate, we use $(GENTOO_LIBDIR) make.
515 - einfo "Fixing install dirs"
516 - sed -e "s,@libdir@,$(get_libdir),g" \
517 - -e "s,@PF@,${PF},g" \
518 - -e "s,@EPREFIX@,${EPREFIX},g" \
519 - -i "${sub_files[@]}" \
520 - || die "install paths sed failed"
521 -
522 - if use clang; then
523 - # constantly fails for a long time, likely due to our patches
524 - rm tools/clang/test/Driver/cross-linux.c || die
525 - fi
526 -
527 - # User patches
528 - epatch_user
529 -
530 - python_setup
531 -}
532 -
533 -multilib_src_configure() {
534 - # disable timestamps since they confuse ccache
535 - local conf_flags=(
536 - --disable-timestamps
537 - --enable-keep-symbols
538 - --enable-shared
539 - --with-optimize-option=
540 - $(tc-is-static-only && echo --disable-shared)
541 - $(use_enable !debug optimized)
542 - $(use_enable debug assertions)
543 - $(use_enable debug expensive-checks)
544 - $(use_enable libedit)
545 - $(use_enable ncurses terminfo)
546 - $(use_enable libffi)
547 - )
548 -
549 - # well, it's used only by clang executable c-index-test
550 - if multilib_is_native_abi && use clang && use xml; then
551 - conf_flags+=( XML2CONFIG="$(tc-getPKG_CONFIG) libxml-2.0" )
552 - else
553 - conf_flags+=( ac_cv_prog_XML2CONFIG="" )
554 - fi
555 -
556 - local targets bindings
557 - if use multitarget; then
558 - targets='all'
559 - else
560 - targets='host,cpp'
561 - use video_cards_radeon && targets+=',r600'
562 - fi
563 - conf_flags+=( --enable-targets=${targets} )
564 -
565 - if multilib_is_native_abi; then
566 - use gold && conf_flags+=( --with-binutils-include="${EPREFIX}"/usr/include/ )
567 - # extra commas don't hurt
568 - use ocaml && bindings+=',ocaml'
569 - fi
570 -
571 - [[ ${bindings} ]] || bindings='none'
572 - conf_flags+=( --enable-bindings=${bindings} )
573 -
574 - if use libffi; then
575 - local CPPFLAGS=${CPPFLAGS}
576 - append-cppflags "$($(tc-getPKG_CONFIG) --cflags libffi)"
577 - fi
578 -
579 - # llvm prefers clang over gcc, so we may need to force that
580 - tc-export CC CXX
581 -
582 - ECONF_SOURCE=${S} \
583 - econf "${conf_flags[@]}"
584 -}
585 -
586 -set_makeargs() {
587 - MAKEARGS=(
588 - VERBOSE=1
589 - REQUIRES_RTTI=1
590 - GENTOO_LIBDIR=$(get_libdir)
591 - )
592 -
593 - # for tests, we want it all! otherwise, we may use a little filtering...
594 - # adding ONLY_TOOLS also disables unittest building...
595 - if [[ ${EBUILD_PHASE_FUNC} != src_test ]]; then
596 - local tools=( llvm-config )
597 - use clang && tools+=( clang )
598 -
599 - if multilib_is_native_abi; then
600 - tools+=(
601 - opt llvm-as llvm-dis llc llvm-ar llvm-nm llvm-link lli
602 - llvm-extract llvm-mc llvm-bcanalyzer llvm-diff macho-dump
603 - llvm-objdump llvm-readobj llvm-rtdyld llvm-dwarfdump llvm-cov
604 - llvm-size llvm-stress llvm-mcmarkup llvm-profdata
605 - llvm-symbolizer obj2yaml yaml2obj lto bugpoint
606 - )
607 -
608 - # the build system runs explicitly specified tools in parallel,
609 - # so we need to split it into two runs
610 - if [[ ${1} != -1 ]]; then
611 - # those require lto
612 - tools+=( llvm-lto )
613 - use gold && tools+=( gold )
614 -
615 - # those require clang :)
616 - # we need to explicitly specify all its tools
617 - # since we're passing BUILD_CLANG_ONLY
618 - use clang && tools+=(
619 - clang/tools/{clang-check,clang-format,extra}
620 - )
621 - fi
622 - fi
623 -
624 - MAKEARGS+=(
625 - # filter tools + disable unittests implicitly
626 - ONLY_TOOLS="${tools[*]}"
627 -
628 - # this disables unittests & docs from clang
629 - BUILD_CLANG_ONLY=YES
630 - )
631 - fi
632 -}
633 -
634 -multilib_src_compile() {
635 - local MAKEARGS
636 - set_makeargs -1
637 - emake "${MAKEARGS[@]}"
638 -
639 - if multilib_is_native_abi; then
640 - set_makeargs
641 - emake -C tools "${MAKEARGS[@]}"
642 -
643 - if use doc; then
644 - emake -C "${S}"/docs -f Makefile.sphinx man
645 - use clang && emake -C "${S}"/tools/clang/docs/tools \
646 - BUILD_FOR_WEBSITE=1 DST_MAN_DIR="${T}"/ man
647 - emake -C "${S}"/docs -f Makefile.sphinx html
648 - fi
649 - fi
650 -
651 - if use debug; then
652 - pax-mark m Debug+Asserts+Checks/bin/llvm-rtdyld
653 - pax-mark m Debug+Asserts+Checks/bin/lli
654 - pax-mark m Debug+Asserts+Checks/bin/lli-child-target
655 - else
656 - pax-mark m Release/bin/llvm-rtdyld
657 - pax-mark m Release/bin/lli
658 - pax-mark m Release/bin/lli-child-target
659 - fi
660 -}
661 -
662 -multilib_src_test() {
663 - local MAKEARGS
664 - set_makeargs
665 -
666 - # build the remaining tools & unittests
667 - emake "${MAKEARGS[@]}"
668 -
669 - pax-mark m unittests/ExecutionEngine/JIT/Release/JITTests
670 - pax-mark m unittests/ExecutionEngine/MCJIT/Release/MCJITTests
671 - pax-mark m unittests/Support/Release/SupportTests
672 -
673 - # respect TMPDIR!
674 - local -x LIT_PRESERVES_TMP=1
675 - emake "${MAKEARGS[@]}" check
676 - use clang && emake "${MAKEARGS[@]}" -C tools/clang test
677 -}
678 -
679 -src_install() {
680 - local MULTILIB_CHOST_TOOLS=(
681 - /usr/bin/llvm-config
682 - )
683 -
684 - local MULTILIB_WRAPPED_HEADERS=(
685 - /usr/include/llvm/Config/config.h
686 - /usr/include/llvm/Config/llvm-config.h
687 - )
688 -
689 - if use clang; then
690 - # note: magic applied below
691 - MULTILIB_CHOST_TOOLS+=(
692 - /usr/bin/clang
693 - /usr/bin/clang++
694 - /usr/bin/clang-${PV}
695 - /usr/bin/clang++-${PV}
696 - )
697 -
698 - MULTILIB_WRAPPED_HEADERS+=(
699 - /usr/include/clang/Config/config.h
700 - )
701 - fi
702 -
703 - multilib-minimal_src_install
704 -
705 - # Remove unnecessary headers on FreeBSD, bug #417171
706 - use kernel_FreeBSD && use clang && rm "${ED}"usr/lib/clang/${PV}/include/{std,float,iso,limits,tgmath,varargs}*.h
707 -}
708 -
709 -multilib_src_install() {
710 - local MAKEARGS
711 - set_makeargs
712 -
713 - local root=${D}/_${ABI}
714 -
715 - emake "${MAKEARGS[@]}" DESTDIR="${root}" install
716 - multibuild_merge_root "${root}" "${D}"
717 -
718 - if ! multilib_is_native_abi; then
719 - # Backwards compat, will be happily removed someday.
720 - dosym "${CHOST}"-llvm-config /usr/bin/llvm-config.${ABI}
721 - else
722 - # Install docs.
723 - if use doc; then
724 - doman "${S}"/docs/_build/man/*.1
725 - use clang && doman "${T}"/clang.1
726 - dohtml -r "${S}"/docs/_build/html/
727 - else
728 - if ! use clang; then
729 - rm "${WORKDIR}"/${PN}-3.5.0-manpages/clang.1 || die
730 - fi
731 - doman "${WORKDIR}"/${PN}-3.5.0-manpages/*.1
732 - fi
733 -
734 - # Symlink the gold plugin.
735 - if use gold; then
736 - dodir /usr/${CHOST}/binutils-bin/lib/bfd-plugins
737 - dosym ../../../../$(get_libdir)/LLVMgold.so \
738 - /usr/${CHOST}/binutils-bin/lib/bfd-plugins/LLVMgold.so
739 - fi
740 - fi
741 -
742 - # apply CHOST and PV to clang executables
743 - # they're statically linked so we don't have to worry about the lib
744 - if use clang; then
745 - local clang_tools=( clang clang++ )
746 - local i
747 -
748 - # append ${PV} and symlink back
749 - # TODO: use alternatives.eclass? does that make any sense?
750 - # maybe with USE=-clang on :0 and USE=clang on older
751 - for i in "${clang_tools[@]}"; do
752 - mv "${ED%/}/usr/bin/${i}"{,-${PV}} || die
753 - dosym "${i}"-${PV} /usr/bin/${i}
754 - done
755 -
756 - # now prepend ${CHOST} and let the multilib-build.eclass symlink it
757 - if ! multilib_is_native_abi; then
758 - # non-native? let's replace it with a simple wrapper
759 - for i in "${clang_tools[@]}"; do
760 - rm "${ED%/}/usr/bin/${i}-${PV}" || die
761 - cat > "${T}"/wrapper.tmp <<-_EOF_
762 - #!${EPREFIX}/bin/sh
763 - exec "${i}-${PV}" $(get_abi_CFLAGS) "\${@}"
764 - _EOF_
765 - newbin "${T}"/wrapper.tmp "${i}-${PV}"
766 - done
767 - fi
768 - fi
769 -
770 - # Fix install_names on Darwin. The build system is too complicated
771 - # to just fix this, so we correct it post-install
772 - local lib= f= odylib= ndylib= libpv=${PV}
773 - if [[ ${CHOST} == *-darwin* ]] ; then
774 - eval $(grep PACKAGE_VERSION= configure)
775 - [[ -n ${PACKAGE_VERSION} ]] && libpv=${PACKAGE_VERSION}
776 - libpvminor=${libpv%.[0-9]*}
777 - for lib in lib{EnhancedDisassembly,LLVM-${libpv},LTO,profile_rt,clang}.dylib LLVMHello.dylib clang/${libpv}/lib/darwin/libclang_rt.asan_{osx,iossim}_dynamic.dylib; do
778 - # libEnhancedDisassembly is Darwin10 only, so non-fatal
779 - # + omit clang libs if not enabled
780 - [[ -f ${ED}/usr/lib/${lib} ]] || continue
781 -
782 - ebegin "fixing install_name of $lib"
783 - install_name_tool \
784 - -id "${EPREFIX}"/usr/lib/${lib} \
785 - "${ED}"/usr/lib/${lib}
786 - eend $?
787 - done
788 - for f in "${ED}"/usr/bin/* "${ED}"/usr/lib/lib*.dylib "${ED}"/usr/lib/clang/${libpv}/lib/darwin/*.dylib ; do
789 - # omit clang libs if not enabled
790 - [[ -f "${f}" ]] || continue
791 -
792 - scanmacho -BF'%n#f' "${f}" | tr ',' '\n' | \
793 - while read odylib ; do
794 - ndylib=
795 - case ${odylib} in
796 - */libclang.dylib)
797 - ndylib="${EPREFIX}"/usr/lib/libclang.dylib
798 - ;;
799 - */libLLVM-${libpv}.dylib)
800 - ndylib="${EPREFIX}"/usr/lib/libLLVM-${libpv}.dylib
801 - ;;
802 - */libLLVM-${libpvminor}.dylib)
803 - ndylib="${EPREFIX}"/usr/lib/libLLVM-${libpvminor}.dylib
804 - ;;
805 - */libLTO.dylib)
806 - ndylib="${EPREFIX}"/usr/lib/libLTO.dylib
807 - ;;
808 - esac
809 - if [[ -n ${ndylib} ]] ; then
810 - ebegin "fixing install_name reference to ${odylib} of ${f##*/}"
811 - install_name_tool \
812 - -change "${odylib}" "${ndylib}" \
813 - "${f}"
814 - eend $?
815 - fi
816 - done
817 - done
818 - fi
819 -}
820 -
821 -multilib_src_install_all() {
822 - insinto /usr/share/vim/vimfiles/syntax
823 - doins utils/vim/*.vim
824 -
825 - if use clang; then
826 - cd tools/clang || die
827 -
828 - if use static-analyzer ; then
829 - dobin tools/scan-build/ccc-analyzer
830 - dosym ccc-analyzer /usr/bin/c++-analyzer
831 - dobin tools/scan-build/scan-build
832 -
833 - insinto /usr/share/${PN}
834 - doins tools/scan-build/scanview.css
835 - doins tools/scan-build/sorttable.js
836 - fi
837 -
838 - python_inst() {
839 - if use static-analyzer ; then
840 - pushd tools/scan-view >/dev/null || die
841 -
842 - python_doscript scan-view
843 -
844 - touch __init__.py || die
845 - python_moduleinto clang
846 - python_domodule __init__.py Reporter.py Resources ScanView.py startfile.py
847 -
848 - popd >/dev/null || die
849 - fi
850 -
851 - if use python ; then
852 - pushd bindings/python/clang >/dev/null || die
853 -
854 - python_moduleinto clang
855 - python_domodule __init__.py cindex.py enumerations.py
856 -
857 - popd >/dev/null || die
858 - fi
859 -
860 - # AddressSanitizer symbolizer (currently separate)
861 - python_doscript "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py
862 - }
863 - python_foreach_impl python_inst
864 - fi
865 -}