From b8330d80ce605a72596ccfa1bfc087b9ded559b8 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 13 Oct 2023 18:18:15 +0100 Subject: gentoo auto-resync : 13:10:2023 - 18:18:15 --- sys-devel/clang/Manifest | 4 +- sys-devel/clang/clang-17.0.2.9999.ebuild | 474 ------------------------ sys-devel/clang/clang-17.0.3.9999.ebuild | 474 ++++++++++++++++++++++++ sys-devel/clang/clang-18.0.0_pre20231013.ebuild | 474 ++++++++++++++++++++++++ 4 files changed, 951 insertions(+), 475 deletions(-) delete mode 100644 sys-devel/clang/clang-17.0.2.9999.ebuild create mode 100644 sys-devel/clang/clang-17.0.3.9999.ebuild create mode 100644 sys-devel/clang/clang-18.0.0_pre20231013.ebuild (limited to 'sys-devel/clang') diff --git a/sys-devel/clang/Manifest b/sys-devel/clang/Manifest index d93a76ac0496..a7b5d7e37cd0 100644 --- a/sys-devel/clang/Manifest +++ b/sys-devel/clang/Manifest @@ -18,6 +18,7 @@ DIST llvm-project-17.0.1.src.tar.xz.sig 438 BLAKE2B 3182e3c3a48635fdec39b945ee3b DIST llvm-project-17.0.2.src.tar.xz 127833708 BLAKE2B fa9e2e48ce1117063f5cef0aeef85ce84b99bd8fae23022572a6f016eff2ffbf8aab6250b0bdb6e0bbea1c4daf10cecceb18e80496260b5aa81086075d503e12 SHA512 4586224c3f547e8065fa4f0ca3629a1dfed868dfc372ab192d8b9384f0f74dc8cb27dcb6269dc4230202e6a524aae852d98b40fa02ed0393086a162387ea7659 DIST llvm-project-17.0.2.src.tar.xz.sig 438 BLAKE2B 3ba5d7a09e9de3f38a6f7b5b771b08b1c4e96ea7eda948cfa679598d240fa5211fd37220fbe09e37682212b17fb71b8b5539475edb8ff46d9767054983f670cb SHA512 234276813e3f4b5ee9b1dc640a613fd2e60f1d659f4e089733278d08dd0e208ad37d4d64c9e1edd420b6b87e112458ecec5f76ed9a243c3023b0adbab19ab909 DIST llvm-project-39fec5457c0925bd39f67f63fe17391584e08258.tar.gz 198361956 BLAKE2B 001b9d9b7997762dcce4f0b1deb94d41c3d840c178ba1e92208782e7e21fdc0041cde359051b2b1b1fc75526ff6504d3b9375ff873831350de359530c944a961 SHA512 b560e71c9855aff9fb5385f9fb30f63fbef074fd695e7cb31847192837a161bfe4808ceb09c514a676ae817616f15fb5a57d325aa9744eaac46b8f4b20b77a13 +DIST llvm-project-5d35273a32d239b7407338e13ed71b59174d6536.tar.gz 198787569 BLAKE2B 7f4f1eb490028e18826a6ebade649a682e433252ceab1f3dcd9e50c34f24e7ef108c3325ec209a4d4fa1ded8e09ebda4980cb9d8ddce8a0d517923d6c38b8f4a SHA512 4d263561fb12cc07a5e8f7ed2f8f22a3645aa959cf963a6a735a9bb93cfc2a51bf7e4d36b54e8425725029cfcfd868dfcc53af95d26d84be72be124d8c564271 DIST llvm-project-f5cb9cb59d7c9c6ac3d5c41c677f68c9b75d34a3.tar.gz 198113948 BLAKE2B 1688920eb790421f4143e92bd7bd26794a2497e7b445dde6d55b59c9df4b1aebb848833c7cb1b7c273c5e002763f2531a341313500ce207242f992dfe343b988 SHA512 9817e8b7adf7c69d673124e8334c3e511dfd1cc386832c52b2fb0f2517475d29cd98513ad87188a962f9697dfac39ea03f5b2db6c549c307cf3d27b1370ffdf3 EBUILD clang-14.0.6-r1.ebuild 12014 BLAKE2B 0f9eed7779a5b9aa8f92002f6f4d8e22e7baf3d3f6d1930e4716abf3aa00d866f68a682dc2a404655f53800e26c8b388da552184da6943287b2d91c5c1c2672b SHA512 c5e46f1044604f4e41cdb6c42d2079096c0bcdd396d99f8e95a6b5b66918e3519e4226741202f716fa5f53295188ec2bfcec66ae32480a8e10b4ab18bdb880ab EBUILD clang-14.0.6-r4.ebuild 11941 BLAKE2B 7465741c3d32f432aabc000ef1d1e78c4538bdcb11983bc5e665b95b349345cf96ceab8d797763532ccb10e8d9311f3699043e5d5aeca08974caca1bd378a275 SHA512 16011488cb74e0fd477cd6950a4742abb44444537de5c07ccb0dea1d19ae8d482b3f75b5e38777f382284994e8f615c8d71bbb6d768585390bdb4bbd365984cd @@ -25,9 +26,10 @@ EBUILD clang-15.0.7-r1.ebuild 12617 BLAKE2B 780db8dc3c92efab35280d32f6b7d4ffcea9 EBUILD clang-15.0.7-r3.ebuild 12548 BLAKE2B ee294ceb058c489007ebb5b9f6bfdbd8fe0f5f77d32c1f71f97aa29ae2bb8234df687a931bb88865f8c5684121623f288620e538e2778dfb8f4fb3f900d14c46 SHA512 0e31baf473cc77b213e0fd7b8e1817439d9f8c94130f388fbb49900306378491b4715a3eab533ffa94e88c91b7e8a9a9303371a73e564df8a5fb2b4319765c94 EBUILD clang-16.0.6.ebuild 12462 BLAKE2B 532fbc03f98a4135371238de3f3d933ac321d4ecccb1e1ce2511563a6529a7bd55444dcdfa4b46140b4b592e1174d534be82e9b29fb1161522253e25c86f75fe SHA512 6e2dc62b7281caf5aa2378eb19f8c24023b62814be4f82e678ee8b98f92cc032de64d5feef0f29c7512aadb34a16b8f50e05a8eadc3bf6663f71504045ad3822 EBUILD clang-17.0.1.ebuild 12145 BLAKE2B 6470f6623bba6514bc91dd71435414f8e337ac83242c3542fee07848a8e4f95c8c5b16922d2a617855068d970687f84c043da7e7c92164da17833717bf08f3fe SHA512 5853c832b8588ab2a0013dfb4060896eaad5a6d21d7516124d18f6b47ce635a998d3306f0b3ff5f6dcec2aaf27699a142dff6ecb6dfe04790ea10a054b84ac36 -EBUILD clang-17.0.2.9999.ebuild 12066 BLAKE2B f8a467f1daa8688c5ff80977800fe0368b39d0c6061d3c790597d4ffb791e96f40013030ce634ab0a38972cca8f79562121ab16f8ecc31ac8a8ad6a283efe114 SHA512 df09fadd53294456b3ecd05c226647195731d3fc787362193c9f5c929aaaa40bc8c1dc02cb8d63eef356f54df271c3fa0a73c4910c9c43afd06f2bd7ff86d9c8 EBUILD clang-17.0.2.ebuild 12145 BLAKE2B 6470f6623bba6514bc91dd71435414f8e337ac83242c3542fee07848a8e4f95c8c5b16922d2a617855068d970687f84c043da7e7c92164da17833717bf08f3fe SHA512 5853c832b8588ab2a0013dfb4060896eaad5a6d21d7516124d18f6b47ce635a998d3306f0b3ff5f6dcec2aaf27699a142dff6ecb6dfe04790ea10a054b84ac36 +EBUILD clang-17.0.3.9999.ebuild 12066 BLAKE2B f8a467f1daa8688c5ff80977800fe0368b39d0c6061d3c790597d4ffb791e96f40013030ce634ab0a38972cca8f79562121ab16f8ecc31ac8a8ad6a283efe114 SHA512 df09fadd53294456b3ecd05c226647195731d3fc787362193c9f5c929aaaa40bc8c1dc02cb8d63eef356f54df271c3fa0a73c4910c9c43afd06f2bd7ff86d9c8 EBUILD clang-18.0.0.9999.ebuild 12065 BLAKE2B 055b0b1a98d944b8faceaa0d7a248e80e82c94f33f41e48f05036272618eee2955d069ce830dbdfba66752ee353229c6591b29b49988789e477a5f399224c9ee SHA512 67a2a39da3ba0d3dbaa1b7496344e91aaccb73675dc142708102dc5c1658a3d48ad58f4d14d38202b5f7cd72ad5fcd2b76675b169b58bd1d38453b859ca5e3ae EBUILD clang-18.0.0_pre20230925.ebuild 12066 BLAKE2B f8a467f1daa8688c5ff80977800fe0368b39d0c6061d3c790597d4ffb791e96f40013030ce634ab0a38972cca8f79562121ab16f8ecc31ac8a8ad6a283efe114 SHA512 df09fadd53294456b3ecd05c226647195731d3fc787362193c9f5c929aaaa40bc8c1dc02cb8d63eef356f54df271c3fa0a73c4910c9c43afd06f2bd7ff86d9c8 EBUILD clang-18.0.0_pre20231002.ebuild 12065 BLAKE2B 055b0b1a98d944b8faceaa0d7a248e80e82c94f33f41e48f05036272618eee2955d069ce830dbdfba66752ee353229c6591b29b49988789e477a5f399224c9ee SHA512 67a2a39da3ba0d3dbaa1b7496344e91aaccb73675dc142708102dc5c1658a3d48ad58f4d14d38202b5f7cd72ad5fcd2b76675b169b58bd1d38453b859ca5e3ae +EBUILD clang-18.0.0_pre20231013.ebuild 12065 BLAKE2B 055b0b1a98d944b8faceaa0d7a248e80e82c94f33f41e48f05036272618eee2955d069ce830dbdfba66752ee353229c6591b29b49988789e477a5f399224c9ee SHA512 67a2a39da3ba0d3dbaa1b7496344e91aaccb73675dc142708102dc5c1658a3d48ad58f4d14d38202b5f7cd72ad5fcd2b76675b169b58bd1d38453b859ca5e3ae MISC metadata.xml 1600 BLAKE2B 8e49e099132445cf695e904acad8a699f3d8c4c1e4cd6ba9d0b97180dfa5b67e9c30b00d1e4cb6cd2f61b27f022accc8d6ee889c6569fc58fbc058186ad216fc SHA512 96b7cf4988ff1fd923ec87311caed458b64888b5acaaf20cc1ad893f2a963158f7f59398f9fd4f9e65cab3df265c0d002048ff874f7a76b94f36377bf9e8f5f6 diff --git a/sys-devel/clang/clang-17.0.2.9999.ebuild b/sys-devel/clang/clang-17.0.2.9999.ebuild deleted file mode 100644 index aae7c602232c..000000000000 --- a/sys-devel/clang/clang-17.0.2.9999.ebuild +++ /dev/null @@ -1,474 +0,0 @@ -# Copyright 1999-2023 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -PYTHON_COMPAT=( python3_{10..12} ) - -inherit cmake llvm llvm.org multilib multilib-minimal -inherit prefix python-single-r1 toolchain-funcs - -DESCRIPTION="C language family frontend for LLVM" -HOMEPAGE="https://llvm.org/" - -# MSVCSetupApi.h: MIT -# sorttable.js: MIT - -LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA MIT" -SLOT="${LLVM_MAJOR}/${LLVM_SOABI}" -KEYWORDS="" -IUSE="+debug doc +extra ieee-long-double +pie +static-analyzer test xml" -REQUIRED_USE="${PYTHON_REQUIRED_USE}" -RESTRICT="!test? ( test )" - -DEPEND=" - ~sys-devel/llvm-${PV}:${LLVM_MAJOR}=[debug=,${MULTILIB_USEDEP}] - static-analyzer? ( dev-lang/perl:* ) - xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] ) -" - -RDEPEND=" - ${PYTHON_DEPS} - ${DEPEND} - >=sys-devel/clang-common-${PV} -" -BDEPEND=" - ${PYTHON_DEPS} - >=dev-util/cmake-3.16 - doc? ( $(python_gen_cond_dep ' - dev-python/recommonmark[${PYTHON_USEDEP}] - dev-python/sphinx[${PYTHON_USEDEP}] - ') ) - xml? ( virtual/pkgconfig ) -" -PDEPEND=" - ~sys-devel/clang-runtime-${PV} - sys-devel/clang-toolchain-symlinks:${LLVM_MAJOR} -" - -LLVM_COMPONENTS=( - clang clang-tools-extra cmake - llvm/lib/Transforms/Hello -) -LLVM_MANPAGES=1 -LLVM_TEST_COMPONENTS=( - llvm/utils -) -LLVM_USE_TARGETS=llvm -llvm.org_set_globals - -# Multilib notes: -# 1. ABI_* flags control ABIs libclang* is built for only. -# 2. clang is always capable of compiling code for all ABIs for enabled -# target. However, you will need appropriate crt* files (installed -# e.g. by sys-devel/gcc and sys-libs/glibc). -# 3. ${CHOST}-clang wrappers are always installed for all ABIs included -# in the current profile (i.e. alike supported by sys-devel/gcc). -# -# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need -# multilib clang* libraries (not runtime, not wrappers). - -pkg_setup() { - LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup - python-single-r1_pkg_setup -} - -src_prepare() { - # create extra parent dir for relative CLANG_RESOURCE_DIR access - mkdir -p x/y || die - BUILD_DIR=${WORKDIR}/x/y/clang - - llvm.org_src_prepare - - # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch) - eprefixify \ - lib/Lex/InitHeaderSearch.cpp \ - lib/Driver/ToolChains/Darwin.cpp || die - - if ! use prefix-guest && [[ -n ${EPREFIX} ]]; then - sed -i "/LibDir.*Loader/s@return \"\/\"@return \"${EPREFIX}/\"@" lib/Driver/ToolChains/Linux.cpp || die - fi -} - -check_distribution_components() { - if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]]; then - local all_targets=() my_targets=() l - cd "${BUILD_DIR}" || die - - while read -r l; do - if [[ ${l} == install-*-stripped:* ]]; then - l=${l#install-} - l=${l%%-stripped*} - - case ${l} in - # meta-targets - clang-libraries|distribution) - continue - ;; - # tools - clang|clangd|clang-*) - ;; - # static libraries - clang*|findAllSymbols) - continue - ;; - # conditional to USE=doc - docs-clang-html|docs-clang-tools-html) - use doc || continue - ;; - esac - - all_targets+=( "${l}" ) - fi - done < <(${NINJA} -t targets all) - - while read -r l; do - my_targets+=( "${l}" ) - done < <(get_distribution_components $"\n") - - local add=() remove=() - for l in "${all_targets[@]}"; do - if ! has "${l}" "${my_targets[@]}"; then - add+=( "${l}" ) - fi - done - for l in "${my_targets[@]}"; do - if ! has "${l}" "${all_targets[@]}"; then - remove+=( "${l}" ) - fi - done - - if [[ ${#add[@]} -gt 0 || ${#remove[@]} -gt 0 ]]; then - eqawarn "get_distribution_components() is outdated!" - eqawarn " Add: ${add[*]}" - eqawarn "Remove: ${remove[*]}" - fi - cd - >/dev/null || die - fi -} - -get_distribution_components() { - local sep=${1-;} - - local out=( - # common stuff - clang-cmake-exports - clang-headers - clang-resource-headers - libclang-headers - - aarch64-resource-headers - arm-common-resource-headers - arm-resource-headers - core-resource-headers - cuda-resource-headers - hexagon-resource-headers - hip-resource-headers - hlsl-resource-headers - mips-resource-headers - opencl-resource-headers - openmp-resource-headers - ppc-htm-resource-headers - ppc-resource-headers - riscv-resource-headers - systemz-resource-headers - utility-resource-headers - ve-resource-headers - webassembly-resource-headers - windows-resource-headers - x86-resource-headers - - # libs - clang-cpp - libclang - ) - - if multilib_is_native_abi; then - out+=( - # common stuff - bash-autocomplete - libclang-python-bindings - - # tools - amdgpu-arch - c-index-test - clang - clang-format - clang-linker-wrapper - clang-offload-bundler - clang-offload-packager - clang-refactor - clang-repl - clang-rename - clang-scan-deps - diagtool - hmaptool - nvptx-arch - - # needed for cross-compiling Clang - clang-tblgen - ) - - if use extra; then - out+=( - # extra tools - clang-apply-replacements - clang-change-namespace - clang-doc - clang-include-cleaner - clang-include-fixer - clang-move - clang-pseudo - clang-query - clang-reorder-fields - clang-tidy - clang-tidy-headers - clangd - find-all-symbols - modularize - pp-trace - ) - fi - - if llvm_are_manpages_built; then - out+=( docs-clang-man ) - use extra && out+=( docs-clang-tools-man ) - fi - - if use doc; then - out+=( docs-clang-html ) - use extra && out+=( docs-clang-tools-html ) - fi - - use static-analyzer && out+=( - clang-check - clang-extdef-mapping - scan-build - scan-build-py - scan-view - ) - fi - - printf "%s${sep}" "${out[@]}" -} - -multilib_src_configure() { - local mycmakeargs=( - -DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}") - -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}" - -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/share/man" - -DCLANG_CONFIG_FILE_SYSTEM_DIR="${EPREFIX}/etc/clang" - # relative to bindir - -DCLANG_RESOURCE_DIR="../../../../lib/clang/${LLVM_MAJOR}" - - -DBUILD_SHARED_LIBS=OFF - -DCLANG_LINK_CLANG_DYLIB=ON - -DLLVM_DISTRIBUTION_COMPONENTS=$(get_distribution_components) - -DCLANG_INCLUDE_TESTS=$(usex test) - - -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}" - - # these are not propagated reliably, so redefine them - -DLLVM_ENABLE_EH=ON - -DLLVM_ENABLE_RTTI=ON - - # libgomp support fails to find headers without explicit -I - # furthermore, it provides only syntax checking - -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp - - # disable using CUDA to autodetect GPU, just build for all - -DCMAKE_DISABLE_FIND_PACKAGE_CUDAToolkit=ON - # disable linking to HSA to avoid automagic dep, - # load it dynamically instead - -DCMAKE_DISABLE_FIND_PACKAGE_hsa-runtime64=ON - - -DCLANG_DEFAULT_PIE_ON_LINUX=$(usex pie) - - -DCLANG_ENABLE_LIBXML2=$(usex xml) - -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) - -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) - # TODO: CLANG_ENABLE_HLSL? - - -DPython3_EXECUTABLE="${PYTHON}" - ) - - if ! use elibc_musl; then - mycmakeargs+=( - -DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=$(usex ieee-long-double) - ) - fi - - use test && mycmakeargs+=( - -DLLVM_BUILD_TESTS=ON - -DLLVM_LIT_ARGS="$(get_lit_flags)" - ) - - if multilib_is_native_abi; then - local build_docs=OFF - if llvm_are_manpages_built; then - build_docs=ON - mycmakeargs+=( - -DLLVM_BUILD_DOCS=ON - -DLLVM_ENABLE_SPHINX=ON - -DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html" - -DSPHINX_WARNINGS_AS_ERRORS=OFF - ) - if use extra; then - mycmakeargs+=( - -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra" - ) - fi - fi - mycmakeargs+=( - -DCLANG_INCLUDE_DOCS=${build_docs} - ) - fi - if multilib_native_use extra; then - mycmakeargs+=( - -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR="${WORKDIR}"/clang-tools-extra - -DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=${build_docs} - ) - else - mycmakeargs+=( - -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF - ) - fi - - if [[ -n ${EPREFIX} ]]; then - mycmakeargs+=( - -DGCC_INSTALL_PREFIX="${EPREFIX}/usr" - ) - fi - - if tc-is-cross-compiler; then - has_version -b sys-devel/clang:${LLVM_MAJOR} || - die "sys-devel/clang:${LLVM_MAJOR} is required on the build host." - local tools_bin=${BROOT}/usr/lib/llvm/${LLVM_MAJOR}/bin - mycmakeargs+=( - -DLLVM_TOOLS_BINARY_DIR="${tools_bin}" - -DCLANG_TABLEGEN="${tools_bin}"/clang-tblgen - ) - fi - - # LLVM can have very high memory consumption while linking, - # exhausting the limit on 32-bit linker executable - use x86 && local -x LDFLAGS="${LDFLAGS} -Wl,--no-keep-memory" - - # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844 - use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG" - cmake_src_configure - - multilib_is_native_abi && check_distribution_components -} - -multilib_src_compile() { - cmake_build distribution -} - -multilib_src_test() { - # respect TMPDIR! - local -x LIT_PRESERVES_TMP=1 - local test_targets=( check-clang ) - if multilib_native_use extra; then - test_targets+=( - check-clang-tools - check-clangd - ) - fi - cmake_build "${test_targets[@]}" -} - -src_install() { - MULTILIB_WRAPPED_HEADERS=( - /usr/include/clang/Config/config.h - ) - - multilib-minimal_src_install - - # Move runtime headers to /usr/lib/clang, where they belong - mv "${ED}"/usr/include/clangrt "${ED}"/usr/lib/clang || die - # move (remaining) wrapped headers back - if use extra; then - mv "${T}"/clang-tidy "${ED}"/usr/include/ || die - fi - mv "${ED}"/usr/include "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/include || die - - # Apply CHOST and version suffix to clang tools - local clang_tools=( clang clang++ clang-cl clang-cpp ) - local abi i - - # cmake gives us: - # - clang-X - # - clang -> clang-X - # - clang++, clang-cl, clang-cpp -> clang - # we want to have: - # - clang-X - # - clang++-X, clang-cl-X, clang-cpp-X -> clang-X - # - clang, clang++, clang-cl, clang-cpp -> clang*-X - # also in CHOST variant - for i in "${clang_tools[@]:1}"; do - rm "${ED}/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}" || die - dosym "clang-${LLVM_MAJOR}" "/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}-${LLVM_MAJOR}" - dosym "${i}-${LLVM_MAJOR}" "/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}" - done - - # now create target symlinks for all supported ABIs - for abi in $(get_all_abis); do - local abi_chost=$(get_abi_CHOST "${abi}") - for i in "${clang_tools[@]}"; do - dosym "${i}-${LLVM_MAJOR}" \ - "/usr/lib/llvm/${LLVM_MAJOR}/bin/${abi_chost}-${i}-${LLVM_MAJOR}" - dosym "${abi_chost}-${i}-${LLVM_MAJOR}" \ - "/usr/lib/llvm/${LLVM_MAJOR}/bin/${abi_chost}-${i}" - done - done -} - -multilib_src_install() { - DESTDIR=${D} cmake_build install-distribution - - # move headers to /usr/include for wrapping & ABI mismatch checks - # (also drop the version suffix from runtime headers) - rm -rf "${ED}"/usr/include || die - mv "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/include "${ED}"/usr/include || die - mv "${ED}"/usr/lib/clang "${ED}"/usr/include/clangrt || die - if multilib_native_use extra; then - # don't wrap clang-tidy headers, the list is too long - # (they're fine for non-native ABI but enabling the targets is problematic) - mv "${ED}"/usr/include/clang-tidy "${T}/" || die - fi -} - -multilib_src_install_all() { - python_fix_shebang "${ED}" - if use static-analyzer; then - python_optimize "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/share/scan-view - fi - - docompress "/usr/lib/llvm/${LLVM_MAJOR}/share/man" - llvm_install_manpages - # match 'html' non-compression - use doc && docompress -x "/usr/share/doc/${PF}/tools-extra" - # +x for some reason; TODO: investigate - use static-analyzer && fperms a-x "/usr/lib/llvm/${LLVM_MAJOR}/share/man/man1/scan-build.1" -} - -pkg_postinst() { - if [[ -z ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then - eselect compiler-shadow update all - fi - - elog "You can find additional utility scripts in:" - elog " ${EROOT}/usr/lib/llvm/${LLVM_MAJOR}/share/clang" - if use extra; then - elog "Some of them are vim integration scripts (with instructions inside)." - elog "The run-clang-tidy.py script requires the following additional package:" - elog " dev-python/pyyaml" - fi -} - -pkg_postrm() { - if [[ -z ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then - eselect compiler-shadow clean all - fi -} diff --git a/sys-devel/clang/clang-17.0.3.9999.ebuild b/sys-devel/clang/clang-17.0.3.9999.ebuild new file mode 100644 index 000000000000..aae7c602232c --- /dev/null +++ b/sys-devel/clang/clang-17.0.3.9999.ebuild @@ -0,0 +1,474 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{10..12} ) + +inherit cmake llvm llvm.org multilib multilib-minimal +inherit prefix python-single-r1 toolchain-funcs + +DESCRIPTION="C language family frontend for LLVM" +HOMEPAGE="https://llvm.org/" + +# MSVCSetupApi.h: MIT +# sorttable.js: MIT + +LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA MIT" +SLOT="${LLVM_MAJOR}/${LLVM_SOABI}" +KEYWORDS="" +IUSE="+debug doc +extra ieee-long-double +pie +static-analyzer test xml" +REQUIRED_USE="${PYTHON_REQUIRED_USE}" +RESTRICT="!test? ( test )" + +DEPEND=" + ~sys-devel/llvm-${PV}:${LLVM_MAJOR}=[debug=,${MULTILIB_USEDEP}] + static-analyzer? ( dev-lang/perl:* ) + xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] ) +" + +RDEPEND=" + ${PYTHON_DEPS} + ${DEPEND} + >=sys-devel/clang-common-${PV} +" +BDEPEND=" + ${PYTHON_DEPS} + >=dev-util/cmake-3.16 + doc? ( $(python_gen_cond_dep ' + dev-python/recommonmark[${PYTHON_USEDEP}] + dev-python/sphinx[${PYTHON_USEDEP}] + ') ) + xml? ( virtual/pkgconfig ) +" +PDEPEND=" + ~sys-devel/clang-runtime-${PV} + sys-devel/clang-toolchain-symlinks:${LLVM_MAJOR} +" + +LLVM_COMPONENTS=( + clang clang-tools-extra cmake + llvm/lib/Transforms/Hello +) +LLVM_MANPAGES=1 +LLVM_TEST_COMPONENTS=( + llvm/utils +) +LLVM_USE_TARGETS=llvm +llvm.org_set_globals + +# Multilib notes: +# 1. ABI_* flags control ABIs libclang* is built for only. +# 2. clang is always capable of compiling code for all ABIs for enabled +# target. However, you will need appropriate crt* files (installed +# e.g. by sys-devel/gcc and sys-libs/glibc). +# 3. ${CHOST}-clang wrappers are always installed for all ABIs included +# in the current profile (i.e. alike supported by sys-devel/gcc). +# +# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need +# multilib clang* libraries (not runtime, not wrappers). + +pkg_setup() { + LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup + python-single-r1_pkg_setup +} + +src_prepare() { + # create extra parent dir for relative CLANG_RESOURCE_DIR access + mkdir -p x/y || die + BUILD_DIR=${WORKDIR}/x/y/clang + + llvm.org_src_prepare + + # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch) + eprefixify \ + lib/Lex/InitHeaderSearch.cpp \ + lib/Driver/ToolChains/Darwin.cpp || die + + if ! use prefix-guest && [[ -n ${EPREFIX} ]]; then + sed -i "/LibDir.*Loader/s@return \"\/\"@return \"${EPREFIX}/\"@" lib/Driver/ToolChains/Linux.cpp || die + fi +} + +check_distribution_components() { + if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]]; then + local all_targets=() my_targets=() l + cd "${BUILD_DIR}" || die + + while read -r l; do + if [[ ${l} == install-*-stripped:* ]]; then + l=${l#install-} + l=${l%%-stripped*} + + case ${l} in + # meta-targets + clang-libraries|distribution) + continue + ;; + # tools + clang|clangd|clang-*) + ;; + # static libraries + clang*|findAllSymbols) + continue + ;; + # conditional to USE=doc + docs-clang-html|docs-clang-tools-html) + use doc || continue + ;; + esac + + all_targets+=( "${l}" ) + fi + done < <(${NINJA} -t targets all) + + while read -r l; do + my_targets+=( "${l}" ) + done < <(get_distribution_components $"\n") + + local add=() remove=() + for l in "${all_targets[@]}"; do + if ! has "${l}" "${my_targets[@]}"; then + add+=( "${l}" ) + fi + done + for l in "${my_targets[@]}"; do + if ! has "${l}" "${all_targets[@]}"; then + remove+=( "${l}" ) + fi + done + + if [[ ${#add[@]} -gt 0 || ${#remove[@]} -gt 0 ]]; then + eqawarn "get_distribution_components() is outdated!" + eqawarn " Add: ${add[*]}" + eqawarn "Remove: ${remove[*]}" + fi + cd - >/dev/null || die + fi +} + +get_distribution_components() { + local sep=${1-;} + + local out=( + # common stuff + clang-cmake-exports + clang-headers + clang-resource-headers + libclang-headers + + aarch64-resource-headers + arm-common-resource-headers + arm-resource-headers + core-resource-headers + cuda-resource-headers + hexagon-resource-headers + hip-resource-headers + hlsl-resource-headers + mips-resource-headers + opencl-resource-headers + openmp-resource-headers + ppc-htm-resource-headers + ppc-resource-headers + riscv-resource-headers + systemz-resource-headers + utility-resource-headers + ve-resource-headers + webassembly-resource-headers + windows-resource-headers + x86-resource-headers + + # libs + clang-cpp + libclang + ) + + if multilib_is_native_abi; then + out+=( + # common stuff + bash-autocomplete + libclang-python-bindings + + # tools + amdgpu-arch + c-index-test + clang + clang-format + clang-linker-wrapper + clang-offload-bundler + clang-offload-packager + clang-refactor + clang-repl + clang-rename + clang-scan-deps + diagtool + hmaptool + nvptx-arch + + # needed for cross-compiling Clang + clang-tblgen + ) + + if use extra; then + out+=( + # extra tools + clang-apply-replacements + clang-change-namespace + clang-doc + clang-include-cleaner + clang-include-fixer + clang-move + clang-pseudo + clang-query + clang-reorder-fields + clang-tidy + clang-tidy-headers + clangd + find-all-symbols + modularize + pp-trace + ) + fi + + if llvm_are_manpages_built; then + out+=( docs-clang-man ) + use extra && out+=( docs-clang-tools-man ) + fi + + if use doc; then + out+=( docs-clang-html ) + use extra && out+=( docs-clang-tools-html ) + fi + + use static-analyzer && out+=( + clang-check + clang-extdef-mapping + scan-build + scan-build-py + scan-view + ) + fi + + printf "%s${sep}" "${out[@]}" +} + +multilib_src_configure() { + local mycmakeargs=( + -DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}") + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}" + -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/share/man" + -DCLANG_CONFIG_FILE_SYSTEM_DIR="${EPREFIX}/etc/clang" + # relative to bindir + -DCLANG_RESOURCE_DIR="../../../../lib/clang/${LLVM_MAJOR}" + + -DBUILD_SHARED_LIBS=OFF + -DCLANG_LINK_CLANG_DYLIB=ON + -DLLVM_DISTRIBUTION_COMPONENTS=$(get_distribution_components) + -DCLANG_INCLUDE_TESTS=$(usex test) + + -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}" + + # these are not propagated reliably, so redefine them + -DLLVM_ENABLE_EH=ON + -DLLVM_ENABLE_RTTI=ON + + # libgomp support fails to find headers without explicit -I + # furthermore, it provides only syntax checking + -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp + + # disable using CUDA to autodetect GPU, just build for all + -DCMAKE_DISABLE_FIND_PACKAGE_CUDAToolkit=ON + # disable linking to HSA to avoid automagic dep, + # load it dynamically instead + -DCMAKE_DISABLE_FIND_PACKAGE_hsa-runtime64=ON + + -DCLANG_DEFAULT_PIE_ON_LINUX=$(usex pie) + + -DCLANG_ENABLE_LIBXML2=$(usex xml) + -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) + -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) + # TODO: CLANG_ENABLE_HLSL? + + -DPython3_EXECUTABLE="${PYTHON}" + ) + + if ! use elibc_musl; then + mycmakeargs+=( + -DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=$(usex ieee-long-double) + ) + fi + + use test && mycmakeargs+=( + -DLLVM_BUILD_TESTS=ON + -DLLVM_LIT_ARGS="$(get_lit_flags)" + ) + + if multilib_is_native_abi; then + local build_docs=OFF + if llvm_are_manpages_built; then + build_docs=ON + mycmakeargs+=( + -DLLVM_BUILD_DOCS=ON + -DLLVM_ENABLE_SPHINX=ON + -DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html" + -DSPHINX_WARNINGS_AS_ERRORS=OFF + ) + if use extra; then + mycmakeargs+=( + -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra" + ) + fi + fi + mycmakeargs+=( + -DCLANG_INCLUDE_DOCS=${build_docs} + ) + fi + if multilib_native_use extra; then + mycmakeargs+=( + -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR="${WORKDIR}"/clang-tools-extra + -DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=${build_docs} + ) + else + mycmakeargs+=( + -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF + ) + fi + + if [[ -n ${EPREFIX} ]]; then + mycmakeargs+=( + -DGCC_INSTALL_PREFIX="${EPREFIX}/usr" + ) + fi + + if tc-is-cross-compiler; then + has_version -b sys-devel/clang:${LLVM_MAJOR} || + die "sys-devel/clang:${LLVM_MAJOR} is required on the build host." + local tools_bin=${BROOT}/usr/lib/llvm/${LLVM_MAJOR}/bin + mycmakeargs+=( + -DLLVM_TOOLS_BINARY_DIR="${tools_bin}" + -DCLANG_TABLEGEN="${tools_bin}"/clang-tblgen + ) + fi + + # LLVM can have very high memory consumption while linking, + # exhausting the limit on 32-bit linker executable + use x86 && local -x LDFLAGS="${LDFLAGS} -Wl,--no-keep-memory" + + # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844 + use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG" + cmake_src_configure + + multilib_is_native_abi && check_distribution_components +} + +multilib_src_compile() { + cmake_build distribution +} + +multilib_src_test() { + # respect TMPDIR! + local -x LIT_PRESERVES_TMP=1 + local test_targets=( check-clang ) + if multilib_native_use extra; then + test_targets+=( + check-clang-tools + check-clangd + ) + fi + cmake_build "${test_targets[@]}" +} + +src_install() { + MULTILIB_WRAPPED_HEADERS=( + /usr/include/clang/Config/config.h + ) + + multilib-minimal_src_install + + # Move runtime headers to /usr/lib/clang, where they belong + mv "${ED}"/usr/include/clangrt "${ED}"/usr/lib/clang || die + # move (remaining) wrapped headers back + if use extra; then + mv "${T}"/clang-tidy "${ED}"/usr/include/ || die + fi + mv "${ED}"/usr/include "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/include || die + + # Apply CHOST and version suffix to clang tools + local clang_tools=( clang clang++ clang-cl clang-cpp ) + local abi i + + # cmake gives us: + # - clang-X + # - clang -> clang-X + # - clang++, clang-cl, clang-cpp -> clang + # we want to have: + # - clang-X + # - clang++-X, clang-cl-X, clang-cpp-X -> clang-X + # - clang, clang++, clang-cl, clang-cpp -> clang*-X + # also in CHOST variant + for i in "${clang_tools[@]:1}"; do + rm "${ED}/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}" || die + dosym "clang-${LLVM_MAJOR}" "/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}-${LLVM_MAJOR}" + dosym "${i}-${LLVM_MAJOR}" "/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}" + done + + # now create target symlinks for all supported ABIs + for abi in $(get_all_abis); do + local abi_chost=$(get_abi_CHOST "${abi}") + for i in "${clang_tools[@]}"; do + dosym "${i}-${LLVM_MAJOR}" \ + "/usr/lib/llvm/${LLVM_MAJOR}/bin/${abi_chost}-${i}-${LLVM_MAJOR}" + dosym "${abi_chost}-${i}-${LLVM_MAJOR}" \ + "/usr/lib/llvm/${LLVM_MAJOR}/bin/${abi_chost}-${i}" + done + done +} + +multilib_src_install() { + DESTDIR=${D} cmake_build install-distribution + + # move headers to /usr/include for wrapping & ABI mismatch checks + # (also drop the version suffix from runtime headers) + rm -rf "${ED}"/usr/include || die + mv "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/include "${ED}"/usr/include || die + mv "${ED}"/usr/lib/clang "${ED}"/usr/include/clangrt || die + if multilib_native_use extra; then + # don't wrap clang-tidy headers, the list is too long + # (they're fine for non-native ABI but enabling the targets is problematic) + mv "${ED}"/usr/include/clang-tidy "${T}/" || die + fi +} + +multilib_src_install_all() { + python_fix_shebang "${ED}" + if use static-analyzer; then + python_optimize "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/share/scan-view + fi + + docompress "/usr/lib/llvm/${LLVM_MAJOR}/share/man" + llvm_install_manpages + # match 'html' non-compression + use doc && docompress -x "/usr/share/doc/${PF}/tools-extra" + # +x for some reason; TODO: investigate + use static-analyzer && fperms a-x "/usr/lib/llvm/${LLVM_MAJOR}/share/man/man1/scan-build.1" +} + +pkg_postinst() { + if [[ -z ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then + eselect compiler-shadow update all + fi + + elog "You can find additional utility scripts in:" + elog " ${EROOT}/usr/lib/llvm/${LLVM_MAJOR}/share/clang" + if use extra; then + elog "Some of them are vim integration scripts (with instructions inside)." + elog "The run-clang-tidy.py script requires the following additional package:" + elog " dev-python/pyyaml" + fi +} + +pkg_postrm() { + if [[ -z ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then + eselect compiler-shadow clean all + fi +} diff --git a/sys-devel/clang/clang-18.0.0_pre20231013.ebuild b/sys-devel/clang/clang-18.0.0_pre20231013.ebuild new file mode 100644 index 000000000000..7f28af23d564 --- /dev/null +++ b/sys-devel/clang/clang-18.0.0_pre20231013.ebuild @@ -0,0 +1,474 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{10..12} ) + +inherit cmake llvm llvm.org multilib multilib-minimal +inherit prefix python-single-r1 toolchain-funcs + +DESCRIPTION="C language family frontend for LLVM" +HOMEPAGE="https://llvm.org/" + +# MSVCSetupApi.h: MIT +# sorttable.js: MIT + +LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA MIT" +SLOT="${LLVM_MAJOR}/${LLVM_SOABI}" +KEYWORDS="" +IUSE="+debug doc +extra ieee-long-double +pie +static-analyzer test xml" +REQUIRED_USE="${PYTHON_REQUIRED_USE}" +RESTRICT="!test? ( test )" + +DEPEND=" + ~sys-devel/llvm-${PV}:${LLVM_MAJOR}=[debug=,${MULTILIB_USEDEP}] + static-analyzer? ( dev-lang/perl:* ) + xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] ) +" + +RDEPEND=" + ${PYTHON_DEPS} + ${DEPEND} + >=sys-devel/clang-common-${PV} +" +BDEPEND=" + ${PYTHON_DEPS} + >=dev-util/cmake-3.16 + doc? ( $(python_gen_cond_dep ' + dev-python/myst-parser[${PYTHON_USEDEP}] + dev-python/sphinx[${PYTHON_USEDEP}] + ') ) + xml? ( virtual/pkgconfig ) +" +PDEPEND=" + ~sys-devel/clang-runtime-${PV} + sys-devel/clang-toolchain-symlinks:${LLVM_MAJOR} +" + +LLVM_COMPONENTS=( + clang clang-tools-extra cmake + llvm/lib/Transforms/Hello +) +LLVM_MANPAGES=1 +LLVM_TEST_COMPONENTS=( + llvm/utils +) +LLVM_USE_TARGETS=llvm +llvm.org_set_globals + +# Multilib notes: +# 1. ABI_* flags control ABIs libclang* is built for only. +# 2. clang is always capable of compiling code for all ABIs for enabled +# target. However, you will need appropriate crt* files (installed +# e.g. by sys-devel/gcc and sys-libs/glibc). +# 3. ${CHOST}-clang wrappers are always installed for all ABIs included +# in the current profile (i.e. alike supported by sys-devel/gcc). +# +# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need +# multilib clang* libraries (not runtime, not wrappers). + +pkg_setup() { + LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup + python-single-r1_pkg_setup +} + +src_prepare() { + # create extra parent dir for relative CLANG_RESOURCE_DIR access + mkdir -p x/y || die + BUILD_DIR=${WORKDIR}/x/y/clang + + llvm.org_src_prepare + + # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch) + eprefixify \ + lib/Lex/InitHeaderSearch.cpp \ + lib/Driver/ToolChains/Darwin.cpp || die + + if ! use prefix-guest && [[ -n ${EPREFIX} ]]; then + sed -i "/LibDir.*Loader/s@return \"\/\"@return \"${EPREFIX}/\"@" lib/Driver/ToolChains/Linux.cpp || die + fi +} + +check_distribution_components() { + if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]]; then + local all_targets=() my_targets=() l + cd "${BUILD_DIR}" || die + + while read -r l; do + if [[ ${l} == install-*-stripped:* ]]; then + l=${l#install-} + l=${l%%-stripped*} + + case ${l} in + # meta-targets + clang-libraries|distribution) + continue + ;; + # tools + clang|clangd|clang-*) + ;; + # static libraries + clang*|findAllSymbols) + continue + ;; + # conditional to USE=doc + docs-clang-html|docs-clang-tools-html) + use doc || continue + ;; + esac + + all_targets+=( "${l}" ) + fi + done < <(${NINJA} -t targets all) + + while read -r l; do + my_targets+=( "${l}" ) + done < <(get_distribution_components $"\n") + + local add=() remove=() + for l in "${all_targets[@]}"; do + if ! has "${l}" "${my_targets[@]}"; then + add+=( "${l}" ) + fi + done + for l in "${my_targets[@]}"; do + if ! has "${l}" "${all_targets[@]}"; then + remove+=( "${l}" ) + fi + done + + if [[ ${#add[@]} -gt 0 || ${#remove[@]} -gt 0 ]]; then + eqawarn "get_distribution_components() is outdated!" + eqawarn " Add: ${add[*]}" + eqawarn "Remove: ${remove[*]}" + fi + cd - >/dev/null || die + fi +} + +get_distribution_components() { + local sep=${1-;} + + local out=( + # common stuff + clang-cmake-exports + clang-headers + clang-resource-headers + libclang-headers + + aarch64-resource-headers + arm-common-resource-headers + arm-resource-headers + core-resource-headers + cuda-resource-headers + hexagon-resource-headers + hip-resource-headers + hlsl-resource-headers + mips-resource-headers + opencl-resource-headers + openmp-resource-headers + ppc-htm-resource-headers + ppc-resource-headers + riscv-resource-headers + systemz-resource-headers + utility-resource-headers + ve-resource-headers + webassembly-resource-headers + windows-resource-headers + x86-resource-headers + + # libs + clang-cpp + libclang + ) + + if multilib_is_native_abi; then + out+=( + # common stuff + bash-autocomplete + libclang-python-bindings + + # tools + amdgpu-arch + c-index-test + clang + clang-format + clang-linker-wrapper + clang-offload-bundler + clang-offload-packager + clang-refactor + clang-repl + clang-rename + clang-scan-deps + diagtool + hmaptool + nvptx-arch + + # needed for cross-compiling Clang + clang-tblgen + ) + + if use extra; then + out+=( + # extra tools + clang-apply-replacements + clang-change-namespace + clang-doc + clang-include-cleaner + clang-include-fixer + clang-move + clang-pseudo + clang-query + clang-reorder-fields + clang-tidy + clang-tidy-headers + clangd + find-all-symbols + modularize + pp-trace + ) + fi + + if llvm_are_manpages_built; then + out+=( docs-clang-man ) + use extra && out+=( docs-clang-tools-man ) + fi + + if use doc; then + out+=( docs-clang-html ) + use extra && out+=( docs-clang-tools-html ) + fi + + use static-analyzer && out+=( + clang-check + clang-extdef-mapping + scan-build + scan-build-py + scan-view + ) + fi + + printf "%s${sep}" "${out[@]}" +} + +multilib_src_configure() { + local mycmakeargs=( + -DDEFAULT_SYSROOT=$(usex prefix-guest "" "${EPREFIX}") + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}" + -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/share/man" + -DCLANG_CONFIG_FILE_SYSTEM_DIR="${EPREFIX}/etc/clang" + # relative to bindir + -DCLANG_RESOURCE_DIR="../../../../lib/clang/${LLVM_MAJOR}" + + -DBUILD_SHARED_LIBS=OFF + -DCLANG_LINK_CLANG_DYLIB=ON + -DLLVM_DISTRIBUTION_COMPONENTS=$(get_distribution_components) + -DCLANG_INCLUDE_TESTS=$(usex test) + + -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}" + + # these are not propagated reliably, so redefine them + -DLLVM_ENABLE_EH=ON + -DLLVM_ENABLE_RTTI=ON + + # libgomp support fails to find headers without explicit -I + # furthermore, it provides only syntax checking + -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp + + # disable using CUDA to autodetect GPU, just build for all + -DCMAKE_DISABLE_FIND_PACKAGE_CUDAToolkit=ON + # disable linking to HSA to avoid automagic dep, + # load it dynamically instead + -DCMAKE_DISABLE_FIND_PACKAGE_hsa-runtime64=ON + + -DCLANG_DEFAULT_PIE_ON_LINUX=$(usex pie) + + -DCLANG_ENABLE_LIBXML2=$(usex xml) + -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) + -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) + # TODO: CLANG_ENABLE_HLSL? + + -DPython3_EXECUTABLE="${PYTHON}" + ) + + if ! use elibc_musl; then + mycmakeargs+=( + -DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=$(usex ieee-long-double) + ) + fi + + use test && mycmakeargs+=( + -DLLVM_BUILD_TESTS=ON + -DLLVM_LIT_ARGS="$(get_lit_flags)" + ) + + if multilib_is_native_abi; then + local build_docs=OFF + if llvm_are_manpages_built; then + build_docs=ON + mycmakeargs+=( + -DLLVM_BUILD_DOCS=ON + -DLLVM_ENABLE_SPHINX=ON + -DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html" + -DSPHINX_WARNINGS_AS_ERRORS=OFF + ) + if use extra; then + mycmakeargs+=( + -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra" + ) + fi + fi + mycmakeargs+=( + -DCLANG_INCLUDE_DOCS=${build_docs} + ) + fi + if multilib_native_use extra; then + mycmakeargs+=( + -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR="${WORKDIR}"/clang-tools-extra + -DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=${build_docs} + ) + else + mycmakeargs+=( + -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF + ) + fi + + if [[ -n ${EPREFIX} ]]; then + mycmakeargs+=( + -DGCC_INSTALL_PREFIX="${EPREFIX}/usr" + ) + fi + + if tc-is-cross-compiler; then + has_version -b sys-devel/clang:${LLVM_MAJOR} || + die "sys-devel/clang:${LLVM_MAJOR} is required on the build host." + local tools_bin=${BROOT}/usr/lib/llvm/${LLVM_MAJOR}/bin + mycmakeargs+=( + -DLLVM_TOOLS_BINARY_DIR="${tools_bin}" + -DCLANG_TABLEGEN="${tools_bin}"/clang-tblgen + ) + fi + + # LLVM can have very high memory consumption while linking, + # exhausting the limit on 32-bit linker executable + use x86 && local -x LDFLAGS="${LDFLAGS} -Wl,--no-keep-memory" + + # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844 + use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG" + cmake_src_configure + + multilib_is_native_abi && check_distribution_components +} + +multilib_src_compile() { + cmake_build distribution +} + +multilib_src_test() { + # respect TMPDIR! + local -x LIT_PRESERVES_TMP=1 + local test_targets=( check-clang ) + if multilib_native_use extra; then + test_targets+=( + check-clang-tools + check-clangd + ) + fi + cmake_build "${test_targets[@]}" +} + +src_install() { + MULTILIB_WRAPPED_HEADERS=( + /usr/include/clang/Config/config.h + ) + + multilib-minimal_src_install + + # Move runtime headers to /usr/lib/clang, where they belong + mv "${ED}"/usr/include/clangrt "${ED}"/usr/lib/clang || die + # move (remaining) wrapped headers back + if use extra; then + mv "${T}"/clang-tidy "${ED}"/usr/include/ || die + fi + mv "${ED}"/usr/include "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/include || die + + # Apply CHOST and version suffix to clang tools + local clang_tools=( clang clang++ clang-cl clang-cpp ) + local abi i + + # cmake gives us: + # - clang-X + # - clang -> clang-X + # - clang++, clang-cl, clang-cpp -> clang + # we want to have: + # - clang-X + # - clang++-X, clang-cl-X, clang-cpp-X -> clang-X + # - clang, clang++, clang-cl, clang-cpp -> clang*-X + # also in CHOST variant + for i in "${clang_tools[@]:1}"; do + rm "${ED}/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}" || die + dosym "clang-${LLVM_MAJOR}" "/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}-${LLVM_MAJOR}" + dosym "${i}-${LLVM_MAJOR}" "/usr/lib/llvm/${LLVM_MAJOR}/bin/${i}" + done + + # now create target symlinks for all supported ABIs + for abi in $(get_all_abis); do + local abi_chost=$(get_abi_CHOST "${abi}") + for i in "${clang_tools[@]}"; do + dosym "${i}-${LLVM_MAJOR}" \ + "/usr/lib/llvm/${LLVM_MAJOR}/bin/${abi_chost}-${i}-${LLVM_MAJOR}" + dosym "${abi_chost}-${i}-${LLVM_MAJOR}" \ + "/usr/lib/llvm/${LLVM_MAJOR}/bin/${abi_chost}-${i}" + done + done +} + +multilib_src_install() { + DESTDIR=${D} cmake_build install-distribution + + # move headers to /usr/include for wrapping & ABI mismatch checks + # (also drop the version suffix from runtime headers) + rm -rf "${ED}"/usr/include || die + mv "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/include "${ED}"/usr/include || die + mv "${ED}"/usr/lib/clang "${ED}"/usr/include/clangrt || die + if multilib_native_use extra; then + # don't wrap clang-tidy headers, the list is too long + # (they're fine for non-native ABI but enabling the targets is problematic) + mv "${ED}"/usr/include/clang-tidy "${T}/" || die + fi +} + +multilib_src_install_all() { + python_fix_shebang "${ED}" + if use static-analyzer; then + python_optimize "${ED}"/usr/lib/llvm/${LLVM_MAJOR}/share/scan-view + fi + + docompress "/usr/lib/llvm/${LLVM_MAJOR}/share/man" + llvm_install_manpages + # match 'html' non-compression + use doc && docompress -x "/usr/share/doc/${PF}/tools-extra" + # +x for some reason; TODO: investigate + use static-analyzer && fperms a-x "/usr/lib/llvm/${LLVM_MAJOR}/share/man/man1/scan-build.1" +} + +pkg_postinst() { + if [[ -z ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then + eselect compiler-shadow update all + fi + + elog "You can find additional utility scripts in:" + elog " ${EROOT}/usr/lib/llvm/${LLVM_MAJOR}/share/clang" + if use extra; then + elog "Some of them are vim integration scripts (with instructions inside)." + elog "The run-clang-tidy.py script requires the following additional package:" + elog " dev-python/pyyaml" + fi +} + +pkg_postrm() { + if [[ -z ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then + eselect compiler-shadow clean all + fi +} -- cgit v1.2.3