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: Sun, 06 Feb 2022 15:35:11
Message-Id: 1644161657.c1a5bd26b93619deded98d0f046a05888d190ba1.mgorny@gentoo
1 commit: c1a5bd26b93619deded98d0f046a05888d190ba1
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Feb 6 15:16:38 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Feb 6 15:34:17 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c1a5bd26
7
8 sys-devel/llvm: Add 15.x live ebuild
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 sys-devel/llvm/llvm-15.0.0.9999.ebuild | 515 +++++++++++++++++++++++++++++++++
13 1 file changed, 515 insertions(+)
14
15 diff --git a/sys-devel/llvm/llvm-15.0.0.9999.ebuild b/sys-devel/llvm/llvm-15.0.0.9999.ebuild
16 new file mode 100644
17 index 000000000000..71fdfeea8b60
18 --- /dev/null
19 +++ b/sys-devel/llvm/llvm-15.0.0.9999.ebuild
20 @@ -0,0 +1,515 @@
21 +# Copyright 1999-2022 Gentoo Authors
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +EAPI=7
25 +
26 +PYTHON_COMPAT=( python3_{8..10} )
27 +inherit cmake llvm.org multilib-minimal pax-utils python-any-r1 \
28 + toolchain-funcs
29 +
30 +DESCRIPTION="Low Level Virtual Machine"
31 +HOMEPAGE="https://llvm.org/"
32 +
33 +# Additional licenses:
34 +# 1. OpenBSD regex: Henry Spencer's license ('rc' in Gentoo) + BSD.
35 +# 2. xxhash: BSD.
36 +# 3. MD5 code: public-domain.
37 +# 4. ConvertUTF.h: TODO.
38 +
39 +LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA BSD public-domain rc"
40 +SLOT="$(ver_cut 1)"
41 +KEYWORDS=""
42 +IUSE="+binutils-plugin debug doc exegesis libedit +libffi ncurses test xar xml z3"
43 +RESTRICT="!test? ( test )"
44 +
45 +RDEPEND="
46 + sys-libs/zlib:0=[${MULTILIB_USEDEP}]
47 + binutils-plugin? ( >=sys-devel/binutils-2.31.1-r4:*[plugins] )
48 + exegesis? ( dev-libs/libpfm:= )
49 + libedit? ( dev-libs/libedit:0=[${MULTILIB_USEDEP}] )
50 + libffi? ( >=dev-libs/libffi-3.0.13-r1:0=[${MULTILIB_USEDEP}] )
51 + ncurses? ( >=sys-libs/ncurses-5.9-r3:0=[${MULTILIB_USEDEP}] )
52 + xar? ( app-arch/xar )
53 + xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] )
54 + z3? ( >=sci-mathematics/z3-4.7.1:0=[${MULTILIB_USEDEP}] )"
55 +DEPEND="${RDEPEND}
56 + binutils-plugin? ( sys-libs/binutils-libs )"
57 +BDEPEND="
58 + dev-lang/perl
59 + >=dev-util/cmake-3.16
60 + sys-devel/gnuconfig
61 + kernel_Darwin? (
62 + <sys-libs/libcxx-$(ver_cut 1-3).9999
63 + >=sys-devel/binutils-apple-5.1
64 + )
65 + doc? ( $(python_gen_any_dep '
66 + dev-python/recommonmark[${PYTHON_USEDEP}]
67 + dev-python/sphinx[${PYTHON_USEDEP}]
68 + ') )
69 + libffi? ( virtual/pkgconfig )
70 + ${PYTHON_DEPS}"
71 +# There are no file collisions between these versions but having :0
72 +# installed means llvm-config there will take precedence.
73 +RDEPEND="${RDEPEND}
74 + !sys-devel/llvm:0"
75 +PDEPEND="sys-devel/llvm-common
76 + binutils-plugin? ( >=sys-devel/llvmgold-${SLOT} )"
77 +
78 +LLVM_COMPONENTS=( llvm cmake third-party )
79 +LLVM_MANPAGES=build
80 +LLVM_PATCHSET=9999-r3
81 +LLVM_USE_TARGETS=provide
82 +llvm.org_set_globals
83 +
84 +python_check_deps() {
85 + use doc || return 0
86 +
87 + has_version -b "dev-python/recommonmark[${PYTHON_USEDEP}]" &&
88 + has_version -b "dev-python/sphinx[${PYTHON_USEDEP}]"
89 +}
90 +
91 +check_live_ebuild() {
92 + local prod_targets=(
93 + $(sed -n -e '/set(LLVM_ALL_TARGETS/,/)/p' CMakeLists.txt \
94 + | tail -n +2 | head -n -1)
95 + )
96 + local all_targets=(
97 + lib/Target/*/
98 + )
99 + all_targets=( "${all_targets[@]#lib/Target/}" )
100 + all_targets=( "${all_targets[@]%/}" )
101 +
102 + local exp_targets=() i
103 + for i in "${all_targets[@]}"; do
104 + has "${i}" "${prod_targets[@]}" || exp_targets+=( "${i}" )
105 + done
106 +
107 + if [[ ${exp_targets[*]} != ${ALL_LLVM_EXPERIMENTAL_TARGETS[*]} ]]; then
108 + eqawarn "ALL_LLVM_EXPERIMENTAL_TARGETS is outdated!"
109 + eqawarn " Have: ${ALL_LLVM_EXPERIMENTAL_TARGETS[*]}"
110 + eqawarn "Expected: ${exp_targets[*]}"
111 + eqawarn
112 + fi
113 +
114 + if [[ ${prod_targets[*]} != ${ALL_LLVM_PRODUCTION_TARGETS[*]} ]]; then
115 + eqawarn "ALL_LLVM_PRODUCTION_TARGETS is outdated!"
116 + eqawarn " Have: ${ALL_LLVM_PRODUCTION_TARGETS[*]}"
117 + eqawarn "Expected: ${prod_targets[*]}"
118 + fi
119 +}
120 +
121 +check_distribution_components() {
122 + if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]]; then
123 + local all_targets=() my_targets=() l
124 + cd "${BUILD_DIR}" || die
125 +
126 + while read -r l; do
127 + if [[ ${l} == install-*-stripped:* ]]; then
128 + l=${l#install-}
129 + l=${l%%-stripped*}
130 +
131 + case ${l} in
132 + # shared libs
133 + LLVM|LLVMgold)
134 + ;;
135 + # TableGen lib + deps
136 + LLVMDemangle|LLVMSupport|LLVMTableGen)
137 + ;;
138 + # static libs
139 + LLVM*)
140 + continue
141 + ;;
142 + # meta-targets
143 + distribution|llvm-libraries)
144 + continue
145 + ;;
146 + # used only w/ USE=doc
147 + docs-llvm-html)
148 + use doc || continue
149 + ;;
150 + esac
151 +
152 + all_targets+=( "${l}" )
153 + fi
154 + done < <(ninja -t targets all)
155 +
156 + while read -r l; do
157 + my_targets+=( "${l}" )
158 + done < <(get_distribution_components $"\n")
159 +
160 + local add=() remove=()
161 + for l in "${all_targets[@]}"; do
162 + if ! has "${l}" "${my_targets[@]}"; then
163 + add+=( "${l}" )
164 + fi
165 + done
166 + for l in "${my_targets[@]}"; do
167 + if ! has "${l}" "${all_targets[@]}"; then
168 + remove+=( "${l}" )
169 + fi
170 + done
171 +
172 + if [[ ${#add[@]} -gt 0 || ${#remove[@]} -gt 0 ]]; then
173 + eqawarn "get_distribution_components() is outdated!"
174 + eqawarn " Add: ${add[*]}"
175 + eqawarn "Remove: ${remove[*]}"
176 + fi
177 + cd - >/dev/null || die
178 + fi
179 +}
180 +
181 +src_prepare() {
182 + # disable use of SDK on OSX, bug #568758
183 + sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die
184 +
185 + # Update config.guess to support more systems
186 + cp "${BROOT}/usr/share/gnuconfig/config.guess" cmake/ || die
187 +
188 + # Verify that the live ebuild is up-to-date
189 + check_live_ebuild
190 +
191 + llvm.org_src_prepare
192 +}
193 +
194 +# Is LLVM being linked against libc++?
195 +is_libcxx_linked() {
196 + local code='#include <ciso646>
197 +#if defined(_LIBCPP_VERSION)
198 + HAVE_LIBCXX
199 +#endif
200 +'
201 + local out=$($(tc-getCXX) ${CXXFLAGS} ${CPPFLAGS} -x c++ -E -P - <<<"${code}") || return 1
202 +
203 + [[ ${out} == *HAVE_LIBCXX* ]]
204 +}
205 +
206 +get_distribution_components() {
207 + local sep=${1-;}
208 +
209 + local out=(
210 + # shared libs
211 + LLVM
212 + LTO
213 + Remarks
214 +
215 + # tools
216 + llvm-config
217 +
218 + # common stuff
219 + cmake-exports
220 + llvm-headers
221 +
222 + # libraries needed for clang-tblgen
223 + LLVMDemangle
224 + LLVMSupport
225 + LLVMTableGen
226 + )
227 +
228 + if multilib_is_native_abi; then
229 + out+=(
230 + # utilities
231 + llvm-tblgen
232 + FileCheck
233 + llvm-PerfectShuffle
234 + count
235 + not
236 + yaml-bench
237 +
238 + # tools
239 + bugpoint
240 + dsymutil
241 + llc
242 + lli
243 + lli-child-target
244 + llvm-addr2line
245 + llvm-ar
246 + llvm-as
247 + llvm-bcanalyzer
248 + llvm-bitcode-strip
249 + llvm-c-test
250 + llvm-cat
251 + llvm-cfi-verify
252 + llvm-config
253 + llvm-cov
254 + llvm-cvtres
255 + llvm-cxxdump
256 + llvm-cxxfilt
257 + llvm-cxxmap
258 + llvm-debuginfod-find
259 + llvm-diff
260 + llvm-dis
261 + llvm-dlltool
262 + llvm-dwarfdump
263 + llvm-dwp
264 + llvm-exegesis
265 + llvm-extract
266 + llvm-gsymutil
267 + llvm-ifs
268 + llvm-install-name-tool
269 + llvm-jitlink
270 + llvm-jitlink-executor
271 + llvm-lib
272 + llvm-libtool-darwin
273 + llvm-link
274 + llvm-lipo
275 + llvm-lto
276 + llvm-lto2
277 + llvm-mc
278 + llvm-mca
279 + llvm-ml
280 + llvm-modextract
281 + llvm-mt
282 + llvm-nm
283 + llvm-objcopy
284 + llvm-objdump
285 + llvm-opt-report
286 + llvm-otool
287 + llvm-pdbutil
288 + llvm-profdata
289 + llvm-profgen
290 + llvm-ranlib
291 + llvm-rc
292 + llvm-readelf
293 + llvm-readobj
294 + llvm-reduce
295 + llvm-rtdyld
296 + llvm-sim
297 + llvm-size
298 + llvm-split
299 + llvm-stress
300 + llvm-strings
301 + llvm-strip
302 + llvm-symbolizer
303 + llvm-tapi-diff
304 + llvm-tli-checker
305 + llvm-undname
306 + llvm-windres
307 + llvm-xray
308 + obj2yaml
309 + opt
310 + sancov
311 + sanstats
312 + split-file
313 + verify-uselistorder
314 + yaml2obj
315 +
316 + # python modules
317 + opt-viewer
318 + )
319 +
320 + if llvm_are_manpages_built; then
321 + out+=(
322 + # manpages
323 + docs-dsymutil-man
324 + docs-llvm-dwarfdump-man
325 + docs-llvm-man
326 + )
327 + fi
328 + use doc && out+=(
329 + docs-llvm-html
330 + )
331 +
332 + use binutils-plugin && out+=(
333 + LLVMgold
334 + )
335 + fi
336 +
337 + printf "%s${sep}" "${out[@]}"
338 +}
339 +
340 +multilib_src_configure() {
341 + local ffi_cflags ffi_ldflags
342 + if use libffi; then
343 + ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi)
344 + ffi_ldflags=$($(tc-getPKG_CONFIG) --libs-only-L libffi)
345 + fi
346 +
347 + local libdir=$(get_libdir)
348 + local mycmakeargs=(
349 + # disable appending VCS revision to the version to improve
350 + # direct cache hit ratio
351 + -DLLVM_APPEND_VC_REV=OFF
352 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}"
353 + -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
354 +
355 + -DBUILD_SHARED_LIBS=OFF
356 + -DLLVM_BUILD_LLVM_DYLIB=ON
357 + -DLLVM_LINK_LLVM_DYLIB=ON
358 + -DLLVM_DISTRIBUTION_COMPONENTS=$(get_distribution_components)
359 +
360 + # cheap hack: LLVM combines both anyway, and the only difference
361 + # is that the former list is explicitly verified at cmake time
362 + -DLLVM_TARGETS_TO_BUILD=""
363 + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}"
364 + -DLLVM_BUILD_TESTS=$(usex test)
365 +
366 + -DLLVM_ENABLE_FFI=$(usex libffi)
367 + -DLLVM_ENABLE_LIBEDIT=$(usex libedit)
368 + -DLLVM_ENABLE_TERMINFO=$(usex ncurses)
369 + -DLLVM_ENABLE_LIBXML2=$(usex xml)
370 + -DLLVM_ENABLE_ASSERTIONS=$(usex debug)
371 + -DLLVM_ENABLE_LIBPFM=$(usex exegesis)
372 + -DLLVM_ENABLE_EH=ON
373 + -DLLVM_ENABLE_RTTI=ON
374 + -DLLVM_ENABLE_Z3_SOLVER=$(usex z3)
375 +
376 + -DLLVM_HOST_TRIPLE="${CHOST}"
377 +
378 + -DFFI_INCLUDE_DIR="${ffi_cflags#-I}"
379 + -DFFI_LIBRARY_DIR="${ffi_ldflags#-L}"
380 + # used only for llvm-objdump tool
381 + -DLLVM_HAVE_LIBXAR=$(multilib_native_usex xar 1 0)
382 +
383 + -DPython3_EXECUTABLE="${PYTHON}"
384 +
385 + # disable OCaml bindings (now in dev-ml/llvm-ocaml)
386 + -DOCAMLFIND=NO
387 + )
388 +
389 + if is_libcxx_linked; then
390 + # Smart hack: alter version suffix -> SOVERSION when linking
391 + # against libc++. This way we won't end up mixing LLVM libc++
392 + # libraries with libstdc++ clang, and the other way around.
393 + mycmakeargs+=(
394 + -DLLVM_VERSION_SUFFIX="libcxx"
395 + -DLLVM_ENABLE_LIBCXX=ON
396 + )
397 + fi
398 +
399 +# Note: go bindings have no CMake rules at the moment
400 +# but let's kill the check in case they are introduced
401 +# if ! multilib_is_native_abi || ! use go; then
402 + mycmakeargs+=(
403 + -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND
404 + )
405 +# fi
406 +
407 + use test && mycmakeargs+=(
408 + -DLLVM_LIT_ARGS="$(get_lit_flags)"
409 + )
410 +
411 + if multilib_is_native_abi; then
412 + local build_docs=OFF
413 + if llvm_are_manpages_built; then
414 + build_docs=ON
415 + mycmakeargs+=(
416 + -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man"
417 + -DLLVM_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html"
418 + -DSPHINX_WARNINGS_AS_ERRORS=OFF
419 + )
420 + fi
421 +
422 + mycmakeargs+=(
423 + -DLLVM_BUILD_DOCS=${build_docs}
424 + -DLLVM_ENABLE_OCAMLDOC=OFF
425 + -DLLVM_ENABLE_SPHINX=${build_docs}
426 + -DLLVM_ENABLE_DOXYGEN=OFF
427 + -DLLVM_INSTALL_UTILS=ON
428 + )
429 + use binutils-plugin && mycmakeargs+=(
430 + -DLLVM_BINUTILS_INCDIR="${EPREFIX}"/usr/include
431 + )
432 + fi
433 +
434 + if tc-is-cross-compiler; then
435 + local tblgen="${EPREFIX}/usr/lib/llvm/${SLOT}/bin/llvm-tblgen"
436 + [[ -x "${tblgen}" ]] \
437 + || die "${tblgen} not found or usable"
438 + mycmakeargs+=(
439 + -DCMAKE_CROSSCOMPILING=ON
440 + -DLLVM_TABLEGEN="${tblgen}"
441 + )
442 + fi
443 +
444 + # workaround BMI bug in gcc-7 (fixed in 7.4)
445 + # https://bugs.gentoo.org/649880
446 + # apply only to x86, https://bugs.gentoo.org/650506
447 + if tc-is-gcc && [[ ${MULTILIB_ABI_FLAG} == abi_x86* ]] &&
448 + [[ $(gcc-major-version) -eq 7 && $(gcc-minor-version) -lt 4 ]]
449 + then
450 + local CFLAGS="${CFLAGS} -mno-bmi"
451 + local CXXFLAGS="${CXXFLAGS} -mno-bmi"
452 + fi
453 +
454 + # LLVM can have very high memory consumption while linking,
455 + # exhausting the limit on 32-bit linker executable
456 + use x86 && local -x LDFLAGS="${LDFLAGS} -Wl,--no-keep-memory"
457 +
458 + # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
459 + use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
460 + cmake_src_configure
461 +
462 + grep -q -E "^CMAKE_PROJECT_VERSION_MAJOR(:.*)?=$(ver_cut 1)$" \
463 + CMakeCache.txt ||
464 + die "Incorrect version, did you update _LLVM_MASTER_MAJOR?"
465 + multilib_is_native_abi && check_distribution_components
466 +}
467 +
468 +multilib_src_compile() {
469 + cmake_build distribution
470 +
471 + pax-mark m "${BUILD_DIR}"/bin/llvm-rtdyld
472 + pax-mark m "${BUILD_DIR}"/bin/lli
473 + pax-mark m "${BUILD_DIR}"/bin/lli-child-target
474 +
475 + if use test; then
476 + pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/Orc/OrcJITTests
477 + pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/MCJIT/MCJITTests
478 + pax-mark m "${BUILD_DIR}"/unittests/Support/SupportTests
479 + fi
480 +}
481 +
482 +multilib_src_test() {
483 + # respect TMPDIR!
484 + local -x LIT_PRESERVES_TMP=1
485 + cmake_build check
486 +}
487 +
488 +src_install() {
489 + local MULTILIB_CHOST_TOOLS=(
490 + /usr/lib/llvm/${SLOT}/bin/llvm-config
491 + )
492 +
493 + local MULTILIB_WRAPPED_HEADERS=(
494 + /usr/include/llvm/Config/llvm-config.h
495 + )
496 +
497 + local LLVM_LDPATHS=()
498 + multilib-minimal_src_install
499 +
500 + # move wrapped headers back
501 + mv "${ED}"/usr/include "${ED}"/usr/lib/llvm/${SLOT}/include || die
502 +}
503 +
504 +multilib_src_install() {
505 + DESTDIR=${D} cmake_build install-distribution
506 +
507 + # move headers to /usr/include for wrapping
508 + rm -rf "${ED}"/usr/include || die
509 + mv "${ED}"/usr/lib/llvm/${SLOT}/include "${ED}"/usr/include || die
510 +
511 + LLVM_LDPATHS+=( "${EPREFIX}/usr/lib/llvm/${SLOT}/$(get_libdir)" )
512 +}
513 +
514 +multilib_src_install_all() {
515 + local revord=$(( 9999 - ${SLOT} ))
516 + newenvd - "60llvm-${revord}" <<-_EOF_
517 + PATH="${EPREFIX}/usr/lib/llvm/${SLOT}/bin"
518 + # we need to duplicate it in ROOTPATH for Portage to respect...
519 + ROOTPATH="${EPREFIX}/usr/lib/llvm/${SLOT}/bin"
520 + MANPATH="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man"
521 + LDPATH="$( IFS=:; echo "${LLVM_LDPATHS[*]}" )"
522 + _EOF_
523 +
524 + docompress "/usr/lib/llvm/${SLOT}/share/man"
525 + llvm_install_manpages
526 +}
527 +
528 +pkg_postinst() {
529 + elog "You can find additional opt-viewer utility scripts in:"
530 + elog " ${EROOT}/usr/lib/llvm/${SLOT}/share/opt-viewer"
531 + elog "To use these scripts, you will need Python along with the following"
532 + elog "packages:"
533 + elog " dev-python/pygments (for opt-viewer)"
534 + elog " dev-python/pyyaml (for all of them)"
535 +}