From 82fd88ea93e273f4b02580552f808b6305d1e840 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Tue, 26 Mar 2024 19:01:21 +0000 Subject: gentoo auto-resync : 26:03:2024 - 19:01:20 --- sys-devel/clang-common/Manifest | 10 +- .../clang-common/clang-common-15.0.7-r8.ebuild | 185 +++++++++++++ .../clang-common/clang-common-16.0.6-r3.ebuild | 191 +++++++++++++ .../clang-common/clang-common-17.0.6-r2.ebuild | 295 -------------------- .../clang-common/clang-common-17.0.6-r3.ebuild | 295 ++++++++++++++++++++ .../clang-common/clang-common-18.1.2-r1.ebuild | 297 --------------------- .../clang-common/clang-common-18.1.2-r2.ebuild | 297 +++++++++++++++++++++ .../clang-common/clang-common-19.0.0.9999.ebuild | 6 +- .../clang-common-19.0.0_pre20240322-r1.ebuild | 296 ++++++++++++++++++++ .../clang-common-19.0.0_pre20240322.ebuild | 296 -------------------- 10 files changed, 1273 insertions(+), 895 deletions(-) create mode 100644 sys-devel/clang-common/clang-common-15.0.7-r8.ebuild create mode 100644 sys-devel/clang-common/clang-common-16.0.6-r3.ebuild delete mode 100644 sys-devel/clang-common/clang-common-17.0.6-r2.ebuild create mode 100644 sys-devel/clang-common/clang-common-17.0.6-r3.ebuild delete mode 100644 sys-devel/clang-common/clang-common-18.1.2-r1.ebuild create mode 100644 sys-devel/clang-common/clang-common-18.1.2-r2.ebuild create mode 100644 sys-devel/clang-common/clang-common-19.0.0_pre20240322-r1.ebuild delete mode 100644 sys-devel/clang-common/clang-common-19.0.0_pre20240322.ebuild (limited to 'sys-devel/clang-common') diff --git a/sys-devel/clang-common/Manifest b/sys-devel/clang-common/Manifest index 07f28b2c51f6..75768c180aed 100644 --- a/sys-devel/clang-common/Manifest +++ b/sys-devel/clang-common/Manifest @@ -9,12 +9,14 @@ DIST llvm-project-18.1.2.src.tar.xz.sig 566 BLAKE2B 97c6b6b4a041316e70abd54ff715 DIST llvm-project-6d3cec01a6c29fa4e51ba129fa13dbf55d2b928e.tar.gz 207700152 BLAKE2B 855720b7a9cc7b1d8fdf398394eb5c702dd615c04e7dad51c449cb1c2f46e75f2ccf2ee10fa3a3403d6aec29f557023a11bd8cdb525bc9c3d76c79f23cd15e82 SHA512 ff6269158e165907c69bd3e4d2d6b87b4f4670546b7e290d7e6665e7097ec887d71174fa37bf5e1755524317e8ae8f0c7c7e428049e8b553faa52c614f1f4490 DIST llvm-project-f3cfe016c5d8429c0dccfa6f85442e2ea0d45a58.tar.gz 208184654 BLAKE2B abd35798f7c921866bb221cecc42aa94915271d0804acbf44dbe5640efb787ef9d928c329eacde768fac4292217ed4d3c4187fba02dd1c826059aeaa1bad33f0 SHA512 513f7278367114ba3fe3271e8a790b62adbca97d280968537e44e5df9a7afb467a5ca93480f4d4fb7c4d5c0734d00ab54559bf68c00f09a1fcff2fee492aa84f EBUILD clang-common-15.0.7-r7.ebuild 5462 BLAKE2B 098697c65115e672a1e878167997d820c93cad6a71c5a1dc17c731a031d37f20e50ef41e2f1d3238bc91065ba23bab5db4ab48e8274be9db3cb086ec6cdf7868 SHA512 7500bf0c4fde82b90aac68d09b95a49c241fae8b0d2340f7780e9baed1c85d855e45c4296a7daaa0b831a07f442e0be4faf6510a335fa5c979b3061e28fdb99d +EBUILD clang-common-15.0.7-r8.ebuild 5481 BLAKE2B 581f6dcec8a01aef5d8121bc4051bfea0f1b414cb277fcb6ad750472662dd0a1597f048772c33a3e2f72f4f500f4b4f185b03460b2e7ace3b14a2ad22ae5be23 SHA512 49878c9bac0ea61b009863f45f0ee28a55c0937f49a0c91e4b9c9c884b5a3a9a3fa4128b049631304c31ad809a7d275bf992498f2736e64d78027c1a2f8addc0 EBUILD clang-common-16.0.6-r2.ebuild 5694 BLAKE2B 18498071d0ca64d58e19ba1e11a42aa7bdf630f66b30aa80e4b72a9aa69f45723baea1da53462cb351075481ad1500544fbb3243ffd8aec16c04c526e2844723 SHA512 70736fa50d37a505b41b385ed0ecd5bca571e1a04d9bc66dfb010e5e1ab61aadaf26bdec17bb46d7a7850dcb90cbabdb173887c0f93fe94c78a460784bc04ab8 +EBUILD clang-common-16.0.6-r3.ebuild 5725 BLAKE2B fef6abf4d29c76572e1598efccb4c7cf32e1238b2cea63d5d01c83e057d52baa82ff70abcacad84121edaf5c06777ee4b13daf40bc57e221e7c3cabd0c3820b7 SHA512 bac47f80fedeeb88394f126a3393e94dba8cd9f464b446e0d8291d444c44d4879afb6db23c29404978ac6b84a8b2c4be7c3c334b3fbb5c9fb7712ab63effe0db EBUILD clang-common-17.0.6-r1.ebuild 8629 BLAKE2B 37c71ff17e805407826bd6ac8e040820c041b37754b9bc55ee67b9ff75bbc993cb4903f9d4018bfda5e37e7dd6d42ac2ea6e16c17a6f369d2fa3862da9607a79 SHA512 d6c8e2731cf29263cd1f17fd90257e9cd9bff372afa1e35f652197c3691ce879794b840a930c02b1ff394dac39d016f6362a86d4938740a65ef084d2ee4b5147 -EBUILD clang-common-17.0.6-r2.ebuild 8773 BLAKE2B 9dea244cea6a5ea2d15849e1f6b743a7582cd0a7ee96dfbbd914099b6090592e9766613177797b0a469427d2bdbd47d94af45b3d073602cc573ef3830b705020 SHA512 73221f17fae62df6b5f2264c9a12abf8b5cad4ffa19b42ca85a50f44201c186e66e55343ffd7c372257ba5b4971af31dbf312a0123d9658f10eaa04d68bf5af2 -EBUILD clang-common-18.1.2-r1.ebuild 8890 BLAKE2B 12e5d615ed30b0f69f8b65fb4eeeabb3db5498de6f9c88d738abbb6079fe5a3762a7aa88f1651646c194ae960e28738760d72b186cef2b6888a7d0bf39cbe937 SHA512 5837c3c0180bc695641fdadf96430485a19a305af5b56fbf5f833681dabe6960852f670678e3c7b6689100fb0022da814d8a95ce39347c6f91b2b25e7a4767ff +EBUILD clang-common-17.0.6-r3.ebuild 8809 BLAKE2B b8f534730118e3553b3c02065da860b73608fc63a4e89090d3115afde69bdb590af4ab3d9218a7f19b55e13cb719992be7d3d643572ce7cb779aa362279b743f SHA512 7a5a8ca6c301e9a1bcefb0b4af014af1d41f77dc622a89075b6aac3413bf077f7e65f4ed6fba066e839fd1d94a7e9e7e306bf3ff7d0d3960f44cf43bcba190a1 +EBUILD clang-common-18.1.2-r2.ebuild 8926 BLAKE2B a14c560cede33e7aa1fc0b8b5d56c4ec15f0fc5f6675a192463223644fa444fb27ec49b30ddc405e618425505cff781c91a6d8ff833e332350030ecd93d79981 SHA512 8a01f5d53029bb993f5671dc95b82ed91a8daaf586f2cb53e1c4e050ff24888616d8d22f7028dee0b9c01422cc1103cfd83c1d1ad57b61df202e4b9579475eb0 EBUILD clang-common-18.1.2.ebuild 8753 BLAKE2B 562cd03f515472d69eb0be89030066863ec8de6525420eeffab8388241f1d2a4896ec62df754dad5edf7d79061878019d6425cf6c433a27a8b2d69ef0db8f72b SHA512 1ad9a3c60a9d63aa0051e9bfba12c7d5596f443924c1afc122f8c47701f6bcd7109d663596faf284924fd117f80a97ec592ab8465beda03bd9c20a963376946a -EBUILD clang-common-19.0.0.9999.ebuild 8774 BLAKE2B 441c37d7db6d4964fe8427af6631f4cdac92df372e66a4b43ea3558c153965152b060f1acef91f230f5a6e23fac08116bb09129cd1ee23ec0ecc636e332ef8d1 SHA512 29944fc4c718ddf998474b62f9022ac1505b9b4c011a0e957a2de6c801ccbf4b77d7c39a005cb8f310c51afb6b2f3fa7c99e9b408549f00146bced5883a2a1dd +EBUILD clang-common-19.0.0.9999.ebuild 8810 BLAKE2B 48a14a93dcbbafd4a2cd62705c4c05bde2bc8c94e6bcc7455e401b0ce7e01bb3534beac8a84f865f66dff94a8c63f2113e468b09daa998f28d7bfa7542977a80 SHA512 0f34ca4bf18f937ca60be571dc14f8ae06ef5ba269c251e0f391f202b683070d7a96d76aa4df84e01f03a5be886cea82beee9f9fa4fb304aa0a258f20df0c597 EBUILD clang-common-19.0.0_pre20240316.ebuild 8774 BLAKE2B 441c37d7db6d4964fe8427af6631f4cdac92df372e66a4b43ea3558c153965152b060f1acef91f230f5a6e23fac08116bb09129cd1ee23ec0ecc636e332ef8d1 SHA512 29944fc4c718ddf998474b62f9022ac1505b9b4c011a0e957a2de6c801ccbf4b77d7c39a005cb8f310c51afb6b2f3fa7c99e9b408549f00146bced5883a2a1dd -EBUILD clang-common-19.0.0_pre20240322.ebuild 8774 BLAKE2B 441c37d7db6d4964fe8427af6631f4cdac92df372e66a4b43ea3558c153965152b060f1acef91f230f5a6e23fac08116bb09129cd1ee23ec0ecc636e332ef8d1 SHA512 29944fc4c718ddf998474b62f9022ac1505b9b4c011a0e957a2de6c801ccbf4b77d7c39a005cb8f310c51afb6b2f3fa7c99e9b408549f00146bced5883a2a1dd +EBUILD clang-common-19.0.0_pre20240322-r1.ebuild 8810 BLAKE2B 48a14a93dcbbafd4a2cd62705c4c05bde2bc8c94e6bcc7455e401b0ce7e01bb3534beac8a84f865f66dff94a8c63f2113e468b09daa998f28d7bfa7542977a80 SHA512 0f34ca4bf18f937ca60be571dc14f8ae06ef5ba269c251e0f391f202b683070d7a96d76aa4df84e01f03a5be886cea82beee9f9fa4fb304aa0a258f20df0c597 MISC metadata.xml 1248 BLAKE2B d9c542ec74a08857a87a42927feef909c343b5b672145e471ebc69753a3f93432d2ae93ed2659a67d504e2c5ff4212640e4208b173d96e5a173a1043766b66f8 SHA512 eb6d4be1dfbdf6b70b774d42493f6b3015472d5e4bba9386254f6e4ae92307169fe1ac6f0f613d452a9c21c6d61ed57ab50efb54813146983f4d6809b32ddacb diff --git a/sys-devel/clang-common/clang-common-15.0.7-r8.ebuild b/sys-devel/clang-common/clang-common-15.0.7-r8.ebuild new file mode 100644 index 000000000000..ddefc1b716bb --- /dev/null +++ b/sys-devel/clang-common/clang-common-15.0.7-r8.ebuild @@ -0,0 +1,185 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit bash-completion-r1 llvm.org + +DESCRIPTION="Common files shared between multiple slots of clang" +HOMEPAGE="https://llvm.org/" + +LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~ppc-macos ~x64-macos" +IUSE=" + default-compiler-rt default-libcxx default-lld llvm-libunwind + hardened stricter +" + +PDEPEND=" + sys-devel/clang:* + default-compiler-rt? ( + sys-devel/clang-runtime[compiler-rt] + llvm-libunwind? ( sys-libs/llvm-libunwind[static-libs] ) + !llvm-libunwind? ( sys-libs/libunwind[static-libs] ) + ) + !default-compiler-rt? ( sys-devel/gcc ) + default-libcxx? ( >=sys-libs/libcxx-${PV}[static-libs] ) + !default-libcxx? ( sys-devel/gcc ) + default-lld? ( sys-devel/lld ) + !default-lld? ( sys-devel/binutils ) +" +IDEPEND=" + !default-compiler-rt? ( sys-devel/gcc-config ) + !default-libcxx? ( sys-devel/gcc-config ) +" + +LLVM_COMPONENTS=( clang/utils ) +llvm.org_set_globals + +pkg_pretend() { + [[ ${CLANG_IGNORE_DEFAULT_RUNTIMES} ]] && return + + local flag missing_flags=() + for flag in default-{compiler-rt,libcxx,lld}; do + if ! use "${flag}" && has_version "sys-devel/clang[${flag}]"; then + missing_flags+=( "${flag}" ) + fi + done + + if [[ ${missing_flags[@]} ]]; then + eerror "It seems that you have the following flags set on sys-devel/clang:" + eerror + eerror " ${missing_flags[*]}" + eerror + eerror "The default runtimes are now set via flags on sys-devel/clang-common." + eerror "The build is being aborted to prevent breakage. Please either set" + eerror "the respective flags on this ebuild, e.g.:" + eerror + eerror " sys-devel/clang-common ${missing_flags[*]}" + eerror + eerror "or build with CLANG_IGNORE_DEFAULT_RUNTIMES=1." + die "Mismatched defaults detected between sys-devel/clang and sys-devel/clang-common" + fi +} + +src_install() { + newbashcomp bash-autocomplete.sh clang + + insinto /etc/clang + newins - gentoo-runtimes.cfg <<-EOF + # This file is initially generated by sys-devel/clang-runtime. + # It is used to control the default runtimes using by clang. + + --rtlib=$(usex default-compiler-rt compiler-rt libgcc) + --unwindlib=$(usex default-compiler-rt libunwind libgcc) + --stdlib=$(usex default-libcxx libc++ libstdc++) + -fuse-ld=$(usex default-lld lld bfd) + EOF + + newins - gentoo-gcc-install.cfg <<-EOF + # This file is maintained by gcc-config. + # It is used to specify the selected GCC installation. + EOF + + newins - gentoo-common.cfg <<-EOF + # This file contains flags common to clang, clang++ and clang-cpp. + @gentoo-runtimes.cfg + @gentoo-gcc-install.cfg + @gentoo-hardened.cfg + # bug #870001 + -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h" + EOF + + # Baseline hardening (bug #851111) + # (-fstack-clash-protection is omitted because of a possible Clang bug, + # see bug #892537 and bug #865339.) + newins - gentoo-hardened.cfg <<-EOF + # Some of these options are added unconditionally, regardless of + # USE=hardened, for parity with sys-devel/gcc. + -Xarch_host -fstack-protector-strong + -fPIE + -include "${EPREFIX}/usr/include/gentoo/fortify.h" + EOF + + dodir /usr/include/gentoo + + cat >> "${ED}/usr/include/gentoo/maybe-stddefs.h" <<-EOF || die + /* __has_include is an extension, but it's fine, because this is only + for Clang anyway. */ + #if defined __has_include && __has_include () && !defined(__GLIBC__) + # include + #endif + EOF + + local fortify_level=$(usex hardened 3 2) + # We have to do this because glibc's headers warn if F_S is set + # without optimization and that would at the very least be very noisy + # during builds and at worst trigger many -Werror builds. + cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die + #ifdef __clang__ + # pragma clang system_header + #endif + #ifndef _FORTIFY_SOURCE + # if defined(__has_feature) + # define __GENTOO_HAS_FEATURE(x) __has_feature(x) + # else + # define __GENTOO_HAS_FEATURE(x) 0 + # endif + # + # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 + # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) + # define _FORTIFY_SOURCE ${fortify_level} + # endif + # endif + # undef __GENTOO_HAS_FEATURE + #endif + EOF + + if use hardened ; then + cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die + # Options below are conditional on USE=hardened. + -D_GLIBCXX_ASSERTIONS + + # Analogue to GLIBCXX_ASSERTIONS + # https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode + -D_LIBCPP_ENABLE_ASSERTIONS=1 + EOF + fi + + if use stricter; then + newins - gentoo-stricter.cfg <<-EOF + # This file increases the strictness of older clang versions + # to match the newest upstream version. + + # clang-16 defaults + -Werror=implicit-function-declaration + -Werror=implicit-int + -Werror=incompatible-function-pointer-types + EOF + + cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die + @gentoo-stricter.cfg + EOF + fi + + local tool + for tool in clang{,++,-cpp}; do + newins - "${tool}.cfg" <<-EOF + # This configuration file is used by ${tool} driver. + @gentoo-common.cfg + EOF + done +} + +pkg_preinst() { + if has_version -b sys-devel/gcc-config && has_version sys-devel/gcc + then + local gcc_path=$(gcc-config --get-lib-path 2>/dev/null) + if [[ -n ${gcc_path} ]]; then + cat >> "${ED}/etc/clang/gentoo-gcc-install.cfg" <<-EOF + --gcc-install-dir="${gcc_path%%:*}" + EOF + fi + fi +} diff --git a/sys-devel/clang-common/clang-common-16.0.6-r3.ebuild b/sys-devel/clang-common/clang-common-16.0.6-r3.ebuild new file mode 100644 index 000000000000..2b4f5f8e714b --- /dev/null +++ b/sys-devel/clang-common/clang-common-16.0.6-r3.ebuild @@ -0,0 +1,191 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit bash-completion-r1 llvm.org + +DESCRIPTION="Common files shared between multiple slots of clang" +HOMEPAGE="https://llvm.org/" + +LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~arm64-macos ~ppc-macos ~x64-macos" +IUSE=" + default-compiler-rt default-libcxx default-lld + bootstrap-prefix hardened llvm-libunwind +" + +PDEPEND=" + sys-devel/clang:* + default-compiler-rt? ( + sys-devel/clang-runtime[compiler-rt] + llvm-libunwind? ( sys-libs/llvm-libunwind[static-libs] ) + !llvm-libunwind? ( sys-libs/libunwind[static-libs] ) + ) + !default-compiler-rt? ( sys-devel/gcc ) + default-libcxx? ( >=sys-libs/libcxx-${PV}[static-libs] ) + !default-libcxx? ( sys-devel/gcc ) + default-lld? ( sys-devel/lld ) + !default-lld? ( sys-devel/binutils ) +" +IDEPEND=" + !default-compiler-rt? ( sys-devel/gcc-config ) + !default-libcxx? ( sys-devel/gcc-config ) +" + +LLVM_COMPONENTS=( clang/utils ) +llvm.org_set_globals + +pkg_pretend() { + [[ ${CLANG_IGNORE_DEFAULT_RUNTIMES} ]] && return + + local flag missing_flags=() + for flag in default-{compiler-rt,libcxx,lld}; do + if ! use "${flag}" && has_version "sys-devel/clang[${flag}]"; then + missing_flags+=( "${flag}" ) + fi + done + + if [[ ${missing_flags[@]} ]]; then + eerror "It seems that you have the following flags set on sys-devel/clang:" + eerror + eerror " ${missing_flags[*]}" + eerror + eerror "The default runtimes are now set via flags on sys-devel/clang-common." + eerror "The build is being aborted to prevent breakage. Please either set" + eerror "the respective flags on this ebuild, e.g.:" + eerror + eerror " sys-devel/clang-common ${missing_flags[*]}" + eerror + eerror "or build with CLANG_IGNORE_DEFAULT_RUNTIMES=1." + die "Mismatched defaults detected between sys-devel/clang and sys-devel/clang-common" + fi +} + +src_install() { + newbashcomp bash-autocomplete.sh clang + + insinto /etc/clang + newins - gentoo-runtimes.cfg <<-EOF + # This file is initially generated by sys-devel/clang-runtime. + # It is used to control the default runtimes using by clang. + + --rtlib=$(usex default-compiler-rt compiler-rt libgcc) + --unwindlib=$(usex default-compiler-rt libunwind libgcc) + --stdlib=$(usex default-libcxx libc++ libstdc++) + -fuse-ld=$(usex default-lld lld bfd) + EOF + + newins - gentoo-gcc-install.cfg <<-EOF + # This file is maintained by gcc-config. + # It is used to specify the selected GCC installation. + EOF + + newins - gentoo-common.cfg <<-EOF + # This file contains flags common to clang, clang++ and clang-cpp. + @gentoo-runtimes.cfg + @gentoo-gcc-install.cfg + @gentoo-hardened.cfg + # bug #870001 + -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h" + EOF + + # Baseline hardening (bug #851111) + newins - gentoo-hardened.cfg <<-EOF + # Some of these options are added unconditionally, regardless of + # USE=hardened, for parity with sys-devel/gcc. + -Xarch_host -fstack-clash-protection + -Xarch_host -fstack-protector-strong + -fPIE + -include "${EPREFIX}/usr/include/gentoo/fortify.h" + EOF + + dodir /usr/include/gentoo + + cat >> "${ED}/usr/include/gentoo/maybe-stddefs.h" <<-EOF || die + /* __has_include is an extension, but it's fine, because this is only + for Clang anyway. */ + #if defined __has_include && __has_include () && !defined(__GLIBC__) + # include + #endif + EOF + + local fortify_level=$(usex hardened 3 2) + # We have to do this because glibc's headers warn if F_S is set + # without optimization and that would at the very least be very noisy + # during builds and at worst trigger many -Werror builds. + cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die + #ifdef __clang__ + # pragma clang system_header + #endif + #ifndef _FORTIFY_SOURCE + # if defined(__has_feature) + # define __GENTOO_HAS_FEATURE(x) __has_feature(x) + # else + # define __GENTOO_HAS_FEATURE(x) 0 + # endif + # + # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 + # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) + # define _FORTIFY_SOURCE ${fortify_level} + # endif + # endif + # undef __GENTOO_HAS_FEATURE + #endif + EOF + + if use hardened ; then + cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die + # Options below are conditional on USE=hardened. + -D_GLIBCXX_ASSERTIONS + + # Analogue to GLIBCXX_ASSERTIONS + # https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode + -D_LIBCPP_ENABLE_ASSERTIONS=1 + EOF + fi + + local tool + for tool in clang{,++,-cpp}; do + newins - "${tool}.cfg" <<-EOF + # This configuration file is used by ${tool} driver. + @gentoo-common.cfg + EOF + done + + if use kernel_Darwin; then + cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die + # Gentoo Prefix on Darwin + -Wl,-search_paths_first + -Wl,-rpath,${EPREFIX}/usr/lib + -L ${EPREFIX}/usr/lib + -isystem ${EPREFIX}/usr/include + -isysroot ${EPREFIX}/MacOSX.sdk + EOF + if use bootstrap-prefix ; then + # bootstrap-prefix is only set during stage2 of bootstrapping + # Prefix, where EPREFIX is set to EPREFIX/tmp. + # Here we need to point it at the future lib dir of the stage3's + # EPREFIX. + cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die + -Wl,-rpath,${EPREFIX}/../usr/lib + EOF + fi + cat >> "${ED}/etc/clang/clang++.cfg" <<-EOF || die + -lc++abi + EOF + fi +} + +pkg_preinst() { + if has_version -b sys-devel/gcc-config && has_version sys-devel/gcc + then + local gcc_path=$(gcc-config --get-lib-path 2>/dev/null) + if [[ -n ${gcc_path} ]]; then + cat >> "${ED}/etc/clang/gentoo-gcc-install.cfg" <<-EOF + --gcc-install-dir="${gcc_path%%:*}" + EOF + fi + fi +} diff --git a/sys-devel/clang-common/clang-common-17.0.6-r2.ebuild b/sys-devel/clang-common/clang-common-17.0.6-r2.ebuild deleted file mode 100644 index 987b7b40aa50..000000000000 --- a/sys-devel/clang-common/clang-common-17.0.6-r2.ebuild +++ /dev/null @@ -1,295 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -inherit bash-completion-r1 llvm.org multilib - -DESCRIPTION="Common files shared between multiple slots of clang" -HOMEPAGE="https://llvm.org/" - -LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA" -SLOT="0" -KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~arm64-macos ~ppc-macos ~x64-macos" -IUSE=" - default-compiler-rt default-libcxx default-lld - bootstrap-prefix cet hardened llvm-libunwind -" - -PDEPEND=" - sys-devel/clang:* - default-compiler-rt? ( - sys-devel/clang-runtime[compiler-rt] - llvm-libunwind? ( sys-libs/llvm-libunwind[static-libs] ) - !llvm-libunwind? ( sys-libs/libunwind[static-libs] ) - ) - !default-compiler-rt? ( sys-devel/gcc ) - default-libcxx? ( >=sys-libs/libcxx-${PV}[static-libs] ) - !default-libcxx? ( sys-devel/gcc ) - default-lld? ( sys-devel/lld ) - !default-lld? ( sys-devel/binutils ) -" -IDEPEND=" - !default-compiler-rt? ( sys-devel/gcc-config ) - !default-libcxx? ( sys-devel/gcc-config ) -" - -LLVM_COMPONENTS=( clang/utils ) -llvm.org_set_globals - -pkg_pretend() { - [[ ${CLANG_IGNORE_DEFAULT_RUNTIMES} ]] && return - - local flag missing_flags=() - for flag in default-{compiler-rt,libcxx,lld}; do - if ! use "${flag}" && has_version "sys-devel/clang[${flag}]"; then - missing_flags+=( "${flag}" ) - fi - done - - if [[ ${missing_flags[@]} ]]; then - eerror "It seems that you have the following flags set on sys-devel/clang:" - eerror - eerror " ${missing_flags[*]}" - eerror - eerror "The default runtimes are now set via flags on sys-devel/clang-common." - eerror "The build is being aborted to prevent breakage. Please either set" - eerror "the respective flags on this ebuild, e.g.:" - eerror - eerror " sys-devel/clang-common ${missing_flags[*]}" - eerror - eerror "or build with CLANG_IGNORE_DEFAULT_RUNTIMES=1." - die "Mismatched defaults detected between sys-devel/clang and sys-devel/clang-common" - fi -} - -_doclang_cfg() { - local triple="${1}" - - local tool - for tool in ${triple}-clang{,++}; do - newins - "${tool}.cfg" <<-EOF - # This configuration file is used by ${tool} driver. - @gentoo-common.cfg - @gentoo-common-ld.cfg - EOF - done - - if use kernel_Darwin; then - cat >> "${ED}/etc/clang/${triple}-clang++.cfg" <<-EOF || die - -lc++abi - EOF - fi - - newins - "${triple}-clang-cpp.cfg" <<-EOF - # This configuration file is used by the ${triple}-clang-cpp driver. - @gentoo-common.cfg - EOF - - # Install symlinks for triples with other vendor strings since some - # programs insist on mangling the triple. - local vendor - for vendor in gentoo pc unknown; do - local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}" - for tool in clang{,++,-cpp}; do - if [[ ! -f "${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then - dosym "${triple}-${tool}.cfg" "/etc/clang/${vendor_triple}-${tool}.cfg" - fi - done - done -} - -doclang_cfg() { - local triple="${1}" - - _doclang_cfg ${triple} - - # LLVM may have different arch names in some cases. For example in x86 - # profiles the triple uses i686, but llvm will prefer i386 if invoked - # with "clang" on x86 or "clang -m32" on x86_64. The gentoo triple will - # be used if invoked through ${CHOST}-clang{,++,-cpp} though. - # - # To make sure the correct triples are installed, - # see Triple::getArchTypeName() in llvm/lib/TargetParser/Triple.cpp - # and compare with CHOST values in profiles. - - local abi=${triple%%-*} - case ${abi} in - armv4l|armv4t|armv5tel|armv6j|armv7a) - _doclang_cfg ${triple/${abi}/arm} - ;; - i686) - _doclang_cfg ${triple/${abi}/i386} - ;; - sparc) - _doclang_cfg ${triple/${abi}/sparcel} - ;; - sparc64) - _doclang_cfg ${triple/${abi}/sparcv9} - ;; - esac -} - -src_install() { - newbashcomp bash-autocomplete.sh clang - - insinto /etc/clang - newins - gentoo-runtimes.cfg <<-EOF - # This file is initially generated by sys-devel/clang-runtime. - # It is used to control the default runtimes using by clang. - - --rtlib=$(usex default-compiler-rt compiler-rt libgcc) - --unwindlib=$(usex default-compiler-rt libunwind libgcc) - --stdlib=$(usex default-libcxx libc++ libstdc++) - -fuse-ld=$(usex default-lld lld bfd) - EOF - - newins - gentoo-gcc-install.cfg <<-EOF - # This file is maintained by gcc-config. - # It is used to specify the selected GCC installation. - EOF - - newins - gentoo-common.cfg <<-EOF - # This file contains flags common to clang, clang++ and clang-cpp. - @gentoo-runtimes.cfg - @gentoo-gcc-install.cfg - @gentoo-hardened.cfg - # bug #870001 - -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h" - EOF - - # clang-cpp does not like link args being passed to it when directly - # invoked, so use a separate configuration file. - newins - gentoo-common-ld.cfg <<-EOF - # This file contains flags common to clang and clang++ - @gentoo-hardened-ld.cfg - EOF - - # Baseline hardening (bug #851111) - newins - gentoo-hardened.cfg <<-EOF - # Some of these options are added unconditionally, regardless of - # USE=hardened, for parity with sys-devel/gcc. - -fstack-clash-protection - -fstack-protector-strong - -fPIE - -include "${EPREFIX}/usr/include/gentoo/fortify.h" - EOF - - if use amd64; then - cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die - -fcf-protection=$(usex cet full none) - EOF - fi - - if use kernel_Darwin; then - newins - gentoo-hardened-ld.cfg <<-EOF - # There was -Wl,-z,relro here, but it's not supported on Mac - # TODO: investigate whether -bind_at_load or -read_only_stubs will do the job - EOF - else - newins - gentoo-hardened-ld.cfg <<-EOF - # Some of these options are added unconditionally, regardless of - # USE=hardened, for parity with sys-devel/gcc. - -Wl,-z,relro - -Wl,-z,now - EOF - fi - - dodir /usr/include/gentoo - - cat >> "${ED}/usr/include/gentoo/maybe-stddefs.h" <<-EOF || die - /* __has_include is an extension, but it's fine, because this is only - for Clang anyway. */ - #if defined __has_include && __has_include () && !defined(__GLIBC__) - # include - #endif - EOF - - local fortify_level=$(usex hardened 3 2) - # We have to do this because glibc's headers warn if F_S is set - # without optimization and that would at the very least be very noisy - # during builds and at worst trigger many -Werror builds. - cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die - #ifdef __clang__ - # pragma clang system_header - #endif - #ifndef _FORTIFY_SOURCE - # if defined(__has_feature) - # define __GENTOO_HAS_FEATURE(x) __has_feature(x) - # else - # define __GENTOO_HAS_FEATURE(x) 0 - # endif - # - # if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1 - # define __GENTOO_NOT_FREESTANDING 1 - # else - # define __GENTOO_NOT_FREESTANDING 0 - # endif - # - # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && __GENTOO_NOT_FREESTANDING > 0 - # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) - # define _FORTIFY_SOURCE ${fortify_level} - # endif - # endif - # undef __GENTOO_HAS_FEATURE - # undef __GENTOO_NOT_FREESTANDING - #endif - EOF - - if use hardened ; then - cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die - # Options below are conditional on USE=hardened. - -D_GLIBCXX_ASSERTIONS - - # Analogue to GLIBCXX_ASSERTIONS - # https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode - # https://libcxx.llvm.org/Hardening.html#using-hardened-mode - -D_LIBCPP_ENABLE_ASSERTIONS=1 - EOF - - cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die - # Options below are conditional on USE=hardened. - EOF - fi - - # We only install config files for supported ABIs because unprefixed tools - # might be used for crosscompilation where e.g. PIE may not be supported. - # See bug #912237 and bug #901247. Just ${CHOST} won't do due to bug #912685. - local abi - for abi in $(get_all_abis); do - local abi_chost=$(get_abi_CHOST "${abi}") - doclang_cfg "${abi_chost}" - done - - if use kernel_Darwin; then - cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die - # Gentoo Prefix on Darwin - -Wl,-search_paths_first - -Wl,-rpath,${EPREFIX}/usr/lib - -L ${EPREFIX}/usr/lib - -isystem ${EPREFIX}/usr/include - -isysroot ${EPREFIX}/MacOSX.sdk - EOF - if use bootstrap-prefix ; then - # bootstrap-prefix is only set during stage2 of bootstrapping - # Prefix, where EPREFIX is set to EPREFIX/tmp. - # Here we need to point it at the future lib dir of the stage3's - # EPREFIX. - cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die - -Wl,-rpath,${EPREFIX}/../usr/lib - EOF - fi - fi -} - -pkg_preinst() { - if has_version -b sys-devel/gcc-config && has_version sys-devel/gcc - then - local gcc_path=$(gcc-config --get-lib-path 2>/dev/null) - if [[ -n ${gcc_path} ]]; then - cat >> "${ED}/etc/clang/gentoo-gcc-install.cfg" <<-EOF - --gcc-install-dir="${gcc_path%%:*}" - EOF - fi - fi -} diff --git a/sys-devel/clang-common/clang-common-17.0.6-r3.ebuild b/sys-devel/clang-common/clang-common-17.0.6-r3.ebuild new file mode 100644 index 000000000000..f6796cb95d4e --- /dev/null +++ b/sys-devel/clang-common/clang-common-17.0.6-r3.ebuild @@ -0,0 +1,295 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit bash-completion-r1 llvm.org multilib + +DESCRIPTION="Common files shared between multiple slots of clang" +HOMEPAGE="https://llvm.org/" + +LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~arm64-macos ~ppc-macos ~x64-macos" +IUSE=" + default-compiler-rt default-libcxx default-lld + bootstrap-prefix cet hardened llvm-libunwind +" + +PDEPEND=" + sys-devel/clang:* + default-compiler-rt? ( + sys-devel/clang-runtime[compiler-rt] + llvm-libunwind? ( sys-libs/llvm-libunwind[static-libs] ) + !llvm-libunwind? ( sys-libs/libunwind[static-libs] ) + ) + !default-compiler-rt? ( sys-devel/gcc ) + default-libcxx? ( >=sys-libs/libcxx-${PV}[static-libs] ) + !default-libcxx? ( sys-devel/gcc ) + default-lld? ( sys-devel/lld ) + !default-lld? ( sys-devel/binutils ) +" +IDEPEND=" + !default-compiler-rt? ( sys-devel/gcc-config ) + !default-libcxx? ( sys-devel/gcc-config ) +" + +LLVM_COMPONENTS=( clang/utils ) +llvm.org_set_globals + +pkg_pretend() { + [[ ${CLANG_IGNORE_DEFAULT_RUNTIMES} ]] && return + + local flag missing_flags=() + for flag in default-{compiler-rt,libcxx,lld}; do + if ! use "${flag}" && has_version "sys-devel/clang[${flag}]"; then + missing_flags+=( "${flag}" ) + fi + done + + if [[ ${missing_flags[@]} ]]; then + eerror "It seems that you have the following flags set on sys-devel/clang:" + eerror + eerror " ${missing_flags[*]}" + eerror + eerror "The default runtimes are now set via flags on sys-devel/clang-common." + eerror "The build is being aborted to prevent breakage. Please either set" + eerror "the respective flags on this ebuild, e.g.:" + eerror + eerror " sys-devel/clang-common ${missing_flags[*]}" + eerror + eerror "or build with CLANG_IGNORE_DEFAULT_RUNTIMES=1." + die "Mismatched defaults detected between sys-devel/clang and sys-devel/clang-common" + fi +} + +_doclang_cfg() { + local triple="${1}" + + local tool + for tool in ${triple}-clang{,++}; do + newins - "${tool}.cfg" <<-EOF + # This configuration file is used by ${tool} driver. + @gentoo-common.cfg + @gentoo-common-ld.cfg + EOF + done + + if use kernel_Darwin; then + cat >> "${ED}/etc/clang/${triple}-clang++.cfg" <<-EOF || die + -lc++abi + EOF + fi + + newins - "${triple}-clang-cpp.cfg" <<-EOF + # This configuration file is used by the ${triple}-clang-cpp driver. + @gentoo-common.cfg + EOF + + # Install symlinks for triples with other vendor strings since some + # programs insist on mangling the triple. + local vendor + for vendor in gentoo pc unknown; do + local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}" + for tool in clang{,++,-cpp}; do + if [[ ! -f "${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then + dosym "${triple}-${tool}.cfg" "/etc/clang/${vendor_triple}-${tool}.cfg" + fi + done + done +} + +doclang_cfg() { + local triple="${1}" + + _doclang_cfg ${triple} + + # LLVM may have different arch names in some cases. For example in x86 + # profiles the triple uses i686, but llvm will prefer i386 if invoked + # with "clang" on x86 or "clang -m32" on x86_64. The gentoo triple will + # be used if invoked through ${CHOST}-clang{,++,-cpp} though. + # + # To make sure the correct triples are installed, + # see Triple::getArchTypeName() in llvm/lib/TargetParser/Triple.cpp + # and compare with CHOST values in profiles. + + local abi=${triple%%-*} + case ${abi} in + armv4l|armv4t|armv5tel|armv6j|armv7a) + _doclang_cfg ${triple/${abi}/arm} + ;; + i686) + _doclang_cfg ${triple/${abi}/i386} + ;; + sparc) + _doclang_cfg ${triple/${abi}/sparcel} + ;; + sparc64) + _doclang_cfg ${triple/${abi}/sparcv9} + ;; + esac +} + +src_install() { + newbashcomp bash-autocomplete.sh clang + + insinto /etc/clang + newins - gentoo-runtimes.cfg <<-EOF + # This file is initially generated by sys-devel/clang-runtime. + # It is used to control the default runtimes using by clang. + + --rtlib=$(usex default-compiler-rt compiler-rt libgcc) + --unwindlib=$(usex default-compiler-rt libunwind libgcc) + --stdlib=$(usex default-libcxx libc++ libstdc++) + -fuse-ld=$(usex default-lld lld bfd) + EOF + + newins - gentoo-gcc-install.cfg <<-EOF + # This file is maintained by gcc-config. + # It is used to specify the selected GCC installation. + EOF + + newins - gentoo-common.cfg <<-EOF + # This file contains flags common to clang, clang++ and clang-cpp. + @gentoo-runtimes.cfg + @gentoo-gcc-install.cfg + @gentoo-hardened.cfg + # bug #870001 + -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h" + EOF + + # clang-cpp does not like link args being passed to it when directly + # invoked, so use a separate configuration file. + newins - gentoo-common-ld.cfg <<-EOF + # This file contains flags common to clang and clang++ + @gentoo-hardened-ld.cfg + EOF + + # Baseline hardening (bug #851111) + newins - gentoo-hardened.cfg <<-EOF + # Some of these options are added unconditionally, regardless of + # USE=hardened, for parity with sys-devel/gcc. + -Xarch_host -fstack-clash-protection + -Xarch_host -fstack-protector-strong + -fPIE + -include "${EPREFIX}/usr/include/gentoo/fortify.h" + EOF + + if use amd64; then + cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die + -Xarch_host -fcf-protection=$(usex cet full none) + EOF + fi + + if use kernel_Darwin; then + newins - gentoo-hardened-ld.cfg <<-EOF + # There was -Wl,-z,relro here, but it's not supported on Mac + # TODO: investigate whether -bind_at_load or -read_only_stubs will do the job + EOF + else + newins - gentoo-hardened-ld.cfg <<-EOF + # Some of these options are added unconditionally, regardless of + # USE=hardened, for parity with sys-devel/gcc. + -Wl,-z,relro + -Wl,-z,now + EOF + fi + + dodir /usr/include/gentoo + + cat >> "${ED}/usr/include/gentoo/maybe-stddefs.h" <<-EOF || die + /* __has_include is an extension, but it's fine, because this is only + for Clang anyway. */ + #if defined __has_include && __has_include () && !defined(__GLIBC__) + # include + #endif + EOF + + local fortify_level=$(usex hardened 3 2) + # We have to do this because glibc's headers warn if F_S is set + # without optimization and that would at the very least be very noisy + # during builds and at worst trigger many -Werror builds. + cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die + #ifdef __clang__ + # pragma clang system_header + #endif + #ifndef _FORTIFY_SOURCE + # if defined(__has_feature) + # define __GENTOO_HAS_FEATURE(x) __has_feature(x) + # else + # define __GENTOO_HAS_FEATURE(x) 0 + # endif + # + # if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1 + # define __GENTOO_NOT_FREESTANDING 1 + # else + # define __GENTOO_NOT_FREESTANDING 0 + # endif + # + # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && __GENTOO_NOT_FREESTANDING > 0 + # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) + # define _FORTIFY_SOURCE ${fortify_level} + # endif + # endif + # undef __GENTOO_HAS_FEATURE + # undef __GENTOO_NOT_FREESTANDING + #endif + EOF + + if use hardened ; then + cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die + # Options below are conditional on USE=hardened. + -D_GLIBCXX_ASSERTIONS + + # Analogue to GLIBCXX_ASSERTIONS + # https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode + # https://libcxx.llvm.org/Hardening.html#using-hardened-mode + -D_LIBCPP_ENABLE_ASSERTIONS=1 + EOF + + cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die + # Options below are conditional on USE=hardened. + EOF + fi + + # We only install config files for supported ABIs because unprefixed tools + # might be used for crosscompilation where e.g. PIE may not be supported. + # See bug #912237 and bug #901247. Just ${CHOST} won't do due to bug #912685. + local abi + for abi in $(get_all_abis); do + local abi_chost=$(get_abi_CHOST "${abi}") + doclang_cfg "${abi_chost}" + done + + if use kernel_Darwin; then + cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die + # Gentoo Prefix on Darwin + -Wl,-search_paths_first + -Wl,-rpath,${EPREFIX}/usr/lib + -L ${EPREFIX}/usr/lib + -isystem ${EPREFIX}/usr/include + -isysroot ${EPREFIX}/MacOSX.sdk + EOF + if use bootstrap-prefix ; then + # bootstrap-prefix is only set during stage2 of bootstrapping + # Prefix, where EPREFIX is set to EPREFIX/tmp. + # Here we need to point it at the future lib dir of the stage3's + # EPREFIX. + cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die + -Wl,-rpath,${EPREFIX}/../usr/lib + EOF + fi + fi +} + +pkg_preinst() { + if has_version -b sys-devel/gcc-config && has_version sys-devel/gcc + then + local gcc_path=$(gcc-config --get-lib-path 2>/dev/null) + if [[ -n ${gcc_path} ]]; then + cat >> "${ED}/etc/clang/gentoo-gcc-install.cfg" <<-EOF + --gcc-install-dir="${gcc_path%%:*}" + EOF + fi + fi +} diff --git a/sys-devel/clang-common/clang-common-18.1.2-r1.ebuild b/sys-devel/clang-common/clang-common-18.1.2-r1.ebuild deleted file mode 100644 index 085bc3ca2202..000000000000 --- a/sys-devel/clang-common/clang-common-18.1.2-r1.ebuild +++ /dev/null @@ -1,297 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -inherit bash-completion-r1 llvm.org multilib - -DESCRIPTION="Common files shared between multiple slots of clang" -HOMEPAGE="https://llvm.org/" - -LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA" -SLOT="0" -KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~arm64-macos ~ppc-macos ~x64-macos" -IUSE=" - default-compiler-rt default-libcxx default-lld - bootstrap-prefix cet hardened llvm-libunwind -" - -PDEPEND=" - sys-devel/clang:* - default-compiler-rt? ( - sys-devel/clang-runtime[compiler-rt] - llvm-libunwind? ( sys-libs/llvm-libunwind[static-libs] ) - !llvm-libunwind? ( sys-libs/libunwind[static-libs] ) - ) - !default-compiler-rt? ( sys-devel/gcc ) - default-libcxx? ( >=sys-libs/libcxx-${PV}[static-libs] ) - !default-libcxx? ( sys-devel/gcc ) - default-lld? ( sys-devel/lld ) - !default-lld? ( sys-devel/binutils ) -" -IDEPEND=" - !default-compiler-rt? ( sys-devel/gcc-config ) - !default-libcxx? ( sys-devel/gcc-config ) -" - -LLVM_COMPONENTS=( clang/utils ) -llvm.org_set_globals - -pkg_pretend() { - [[ ${CLANG_IGNORE_DEFAULT_RUNTIMES} ]] && return - - local flag missing_flags=() - for flag in default-{compiler-rt,libcxx,lld}; do - if ! use "${flag}" && has_version "sys-devel/clang[${flag}]"; then - missing_flags+=( "${flag}" ) - fi - done - - if [[ ${missing_flags[@]} ]]; then - eerror "It seems that you have the following flags set on sys-devel/clang:" - eerror - eerror " ${missing_flags[*]}" - eerror - eerror "The default runtimes are now set via flags on sys-devel/clang-common." - eerror "The build is being aborted to prevent breakage. Please either set" - eerror "the respective flags on this ebuild, e.g.:" - eerror - eerror " sys-devel/clang-common ${missing_flags[*]}" - eerror - eerror "or build with CLANG_IGNORE_DEFAULT_RUNTIMES=1." - die "Mismatched defaults detected between sys-devel/clang and sys-devel/clang-common" - fi -} - -_doclang_cfg() { - local triple="${1}" - - local tool - for tool in ${triple}-clang{,++}; do - newins - "${tool}.cfg" <<-EOF - # This configuration file is used by ${tool} driver. - @gentoo-common.cfg - @gentoo-common-ld.cfg - EOF - done - - if use kernel_Darwin; then - cat >> "${ED}/etc/clang/${triple}-clang++.cfg" <<-EOF || die - -lc++abi - EOF - fi - - newins - "${triple}-clang-cpp.cfg" <<-EOF - # This configuration file is used by the ${triple}-clang-cpp driver. - @gentoo-common.cfg - EOF - - # Install symlinks for triples with other vendor strings since some - # programs insist on mangling the triple. - local vendor - for vendor in gentoo pc unknown; do - local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}" - for tool in clang{,++,-cpp}; do - if [[ ! -f "${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then - dosym "${triple}-${tool}.cfg" "/etc/clang/${vendor_triple}-${tool}.cfg" - fi - done - done -} - -doclang_cfg() { - local triple="${1}" - - _doclang_cfg ${triple} - - # LLVM may have different arch names in some cases. For example in x86 - # profiles the triple uses i686, but llvm will prefer i386 if invoked - # with "clang" on x86 or "clang -m32" on x86_64. The gentoo triple will - # be used if invoked through ${CHOST}-clang{,++,-cpp} though. - # - # To make sure the correct triples are installed, - # see Triple::getArchTypeName() in llvm/lib/TargetParser/Triple.cpp - # and compare with CHOST values in profiles. - - local abi=${triple%%-*} - case ${abi} in - armv4l|armv4t|armv5tel|armv6j|armv7a) - _doclang_cfg ${triple/${abi}/arm} - ;; - i686) - _doclang_cfg ${triple/${abi}/i386} - ;; - sparc) - _doclang_cfg ${triple/${abi}/sparcel} - ;; - sparc64) - _doclang_cfg ${triple/${abi}/sparcv9} - ;; - esac -} - -src_install() { - newbashcomp bash-autocomplete.sh clang - - insinto /etc/clang - newins - gentoo-runtimes.cfg <<-EOF - # This file is initially generated by sys-devel/clang-runtime. - # It is used to control the default runtimes using by clang. - - --rtlib=$(usex default-compiler-rt compiler-rt libgcc) - --unwindlib=$(usex default-compiler-rt libunwind libgcc) - --stdlib=$(usex default-libcxx libc++ libstdc++) - -fuse-ld=$(usex default-lld lld bfd) - EOF - - newins - gentoo-gcc-install.cfg <<-EOF - # This file is maintained by gcc-config. - # It is used to specify the selected GCC installation. - EOF - - newins - gentoo-common.cfg <<-EOF - # This file contains flags common to clang, clang++ and clang-cpp. - @gentoo-runtimes.cfg - @gentoo-gcc-install.cfg - @gentoo-hardened.cfg - # bug #870001 - -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h" - EOF - - # clang-cpp does not like link args being passed to it when directly - # invoked, so use a separate configuration file. - newins - gentoo-common-ld.cfg <<-EOF - # This file contains flags common to clang and clang++ - @gentoo-hardened-ld.cfg - EOF - - # Baseline hardening (bug #851111) - newins - gentoo-hardened.cfg <<-EOF - # Some of these options are added unconditionally, regardless of - # USE=hardened, for parity with sys-devel/gcc. - -fstack-clash-protection - -fstack-protector-strong - -fPIE - -include "${EPREFIX}/usr/include/gentoo/fortify.h" - EOF - - if use amd64; then - cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die - -fcf-protection=$(usex cet full none) - EOF - fi - - if use kernel_Darwin; then - newins - gentoo-hardened-ld.cfg <<-EOF - # There was -Wl,-z,relro here, but it's not supported on Mac - # TODO: investigate whether -bind_at_load or -read_only_stubs will do the job - EOF - else - newins - gentoo-hardened-ld.cfg <<-EOF - # Some of these options are added unconditionally, regardless of - # USE=hardened, for parity with sys-devel/gcc. - -Wl,-z,relro - -Wl,-z,now - EOF - fi - - dodir /usr/include/gentoo - - cat >> "${ED}/usr/include/gentoo/maybe-stddefs.h" <<-EOF || die - /* __has_include is an extension, but it's fine, because this is only - for Clang anyway. */ - #if defined __has_include && __has_include () && !defined(__GLIBC__) - # include - #endif - EOF - - local fortify_level=$(usex hardened 3 2) - # We have to do this because glibc's headers warn if F_S is set - # without optimization and that would at the very least be very noisy - # during builds and at worst trigger many -Werror builds. - cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die - #ifdef __clang__ - # pragma clang system_header - #endif - #ifndef _FORTIFY_SOURCE - # if defined(__has_feature) - # define __GENTOO_HAS_FEATURE(x) __has_feature(x) - # else - # define __GENTOO_HAS_FEATURE(x) 0 - # endif - # - # if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1 - # define __GENTOO_NOT_FREESTANDING 1 - # else - # define __GENTOO_NOT_FREESTANDING 0 - # endif - # - # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && __GENTOO_NOT_FREESTANDING > 0 - # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) - # define _FORTIFY_SOURCE ${fortify_level} - # endif - # endif - # undef __GENTOO_HAS_FEATURE - # undef __GENTOO_NOT_FREESTANDING - #endif - EOF - - # TODO: Maybe -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST for - # non-hardened? - if use hardened ; then - cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die - # Options below are conditional on USE=hardened. - -D_GLIBCXX_ASSERTIONS - - # Analogue to GLIBCXX_ASSERTIONS - # https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode - # https://libcxx.llvm.org/Hardening.html#using-hardened-mode - -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE - EOF - - cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die - # Options below are conditional on USE=hardened. - EOF - fi - - # We only install config files for supported ABIs because unprefixed tools - # might be used for crosscompilation where e.g. PIE may not be supported. - # See bug #912237 and bug #901247. Just ${CHOST} won't do due to bug #912685. - local abi - for abi in $(get_all_abis); do - local abi_chost=$(get_abi_CHOST "${abi}") - doclang_cfg "${abi_chost}" - done - - if use kernel_Darwin; then - cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die - # Gentoo Prefix on Darwin - -Wl,-search_paths_first - -Wl,-rpath,${EPREFIX}/usr/lib - -L ${EPREFIX}/usr/lib - -isystem ${EPREFIX}/usr/include - -isysroot ${EPREFIX}/MacOSX.sdk - EOF - if use bootstrap-prefix ; then - # bootstrap-prefix is only set during stage2 of bootstrapping - # Prefix, where EPREFIX is set to EPREFIX/tmp. - # Here we need to point it at the future lib dir of the stage3's - # EPREFIX. - cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die - -Wl,-rpath,${EPREFIX}/../usr/lib - EOF - fi - fi -} - -pkg_preinst() { - if has_version -b sys-devel/gcc-config && has_version sys-devel/gcc - then - local gcc_path=$(gcc-config --get-lib-path 2>/dev/null) - if [[ -n ${gcc_path} ]]; then - cat >> "${ED}/etc/clang/gentoo-gcc-install.cfg" <<-EOF - --gcc-install-dir="${gcc_path%%:*}" - EOF - fi - fi -} diff --git a/sys-devel/clang-common/clang-common-18.1.2-r2.ebuild b/sys-devel/clang-common/clang-common-18.1.2-r2.ebuild new file mode 100644 index 000000000000..986593dfbbc2 --- /dev/null +++ b/sys-devel/clang-common/clang-common-18.1.2-r2.ebuild @@ -0,0 +1,297 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit bash-completion-r1 llvm.org multilib + +DESCRIPTION="Common files shared between multiple slots of clang" +HOMEPAGE="https://llvm.org/" + +LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~arm64-macos ~ppc-macos ~x64-macos" +IUSE=" + default-compiler-rt default-libcxx default-lld + bootstrap-prefix cet hardened llvm-libunwind +" + +PDEPEND=" + sys-devel/clang:* + default-compiler-rt? ( + sys-devel/clang-runtime[compiler-rt] + llvm-libunwind? ( sys-libs/llvm-libunwind[static-libs] ) + !llvm-libunwind? ( sys-libs/libunwind[static-libs] ) + ) + !default-compiler-rt? ( sys-devel/gcc ) + default-libcxx? ( >=sys-libs/libcxx-${PV}[static-libs] ) + !default-libcxx? ( sys-devel/gcc ) + default-lld? ( sys-devel/lld ) + !default-lld? ( sys-devel/binutils ) +" +IDEPEND=" + !default-compiler-rt? ( sys-devel/gcc-config ) + !default-libcxx? ( sys-devel/gcc-config ) +" + +LLVM_COMPONENTS=( clang/utils ) +llvm.org_set_globals + +pkg_pretend() { + [[ ${CLANG_IGNORE_DEFAULT_RUNTIMES} ]] && return + + local flag missing_flags=() + for flag in default-{compiler-rt,libcxx,lld}; do + if ! use "${flag}" && has_version "sys-devel/clang[${flag}]"; then + missing_flags+=( "${flag}" ) + fi + done + + if [[ ${missing_flags[@]} ]]; then + eerror "It seems that you have the following flags set on sys-devel/clang:" + eerror + eerror " ${missing_flags[*]}" + eerror + eerror "The default runtimes are now set via flags on sys-devel/clang-common." + eerror "The build is being aborted to prevent breakage. Please either set" + eerror "the respective flags on this ebuild, e.g.:" + eerror + eerror " sys-devel/clang-common ${missing_flags[*]}" + eerror + eerror "or build with CLANG_IGNORE_DEFAULT_RUNTIMES=1." + die "Mismatched defaults detected between sys-devel/clang and sys-devel/clang-common" + fi +} + +_doclang_cfg() { + local triple="${1}" + + local tool + for tool in ${triple}-clang{,++}; do + newins - "${tool}.cfg" <<-EOF + # This configuration file is used by ${tool} driver. + @gentoo-common.cfg + @gentoo-common-ld.cfg + EOF + done + + if use kernel_Darwin; then + cat >> "${ED}/etc/clang/${triple}-clang++.cfg" <<-EOF || die + -lc++abi + EOF + fi + + newins - "${triple}-clang-cpp.cfg" <<-EOF + # This configuration file is used by the ${triple}-clang-cpp driver. + @gentoo-common.cfg + EOF + + # Install symlinks for triples with other vendor strings since some + # programs insist on mangling the triple. + local vendor + for vendor in gentoo pc unknown; do + local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}" + for tool in clang{,++,-cpp}; do + if [[ ! -f "${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then + dosym "${triple}-${tool}.cfg" "/etc/clang/${vendor_triple}-${tool}.cfg" + fi + done + done +} + +doclang_cfg() { + local triple="${1}" + + _doclang_cfg ${triple} + + # LLVM may have different arch names in some cases. For example in x86 + # profiles the triple uses i686, but llvm will prefer i386 if invoked + # with "clang" on x86 or "clang -m32" on x86_64. The gentoo triple will + # be used if invoked through ${CHOST}-clang{,++,-cpp} though. + # + # To make sure the correct triples are installed, + # see Triple::getArchTypeName() in llvm/lib/TargetParser/Triple.cpp + # and compare with CHOST values in profiles. + + local abi=${triple%%-*} + case ${abi} in + armv4l|armv4t|armv5tel|armv6j|armv7a) + _doclang_cfg ${triple/${abi}/arm} + ;; + i686) + _doclang_cfg ${triple/${abi}/i386} + ;; + sparc) + _doclang_cfg ${triple/${abi}/sparcel} + ;; + sparc64) + _doclang_cfg ${triple/${abi}/sparcv9} + ;; + esac +} + +src_install() { + newbashcomp bash-autocomplete.sh clang + + insinto /etc/clang + newins - gentoo-runtimes.cfg <<-EOF + # This file is initially generated by sys-devel/clang-runtime. + # It is used to control the default runtimes using by clang. + + --rtlib=$(usex default-compiler-rt compiler-rt libgcc) + --unwindlib=$(usex default-compiler-rt libunwind libgcc) + --stdlib=$(usex default-libcxx libc++ libstdc++) + -fuse-ld=$(usex default-lld lld bfd) + EOF + + newins - gentoo-gcc-install.cfg <<-EOF + # This file is maintained by gcc-config. + # It is used to specify the selected GCC installation. + EOF + + newins - gentoo-common.cfg <<-EOF + # This file contains flags common to clang, clang++ and clang-cpp. + @gentoo-runtimes.cfg + @gentoo-gcc-install.cfg + @gentoo-hardened.cfg + # bug #870001 + -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h" + EOF + + # clang-cpp does not like link args being passed to it when directly + # invoked, so use a separate configuration file. + newins - gentoo-common-ld.cfg <<-EOF + # This file contains flags common to clang and clang++ + @gentoo-hardened-ld.cfg + EOF + + # Baseline hardening (bug #851111) + newins - gentoo-hardened.cfg <<-EOF + # Some of these options are added unconditionally, regardless of + # USE=hardened, for parity with sys-devel/gcc. + -Xarch_host -fstack-clash-protection + -Xarch_host -fstack-protector-strong + -fPIE + -include "${EPREFIX}/usr/include/gentoo/fortify.h" + EOF + + if use amd64; then + cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die + -Xarch_host -fcf-protection=$(usex cet full none) + EOF + fi + + if use kernel_Darwin; then + newins - gentoo-hardened-ld.cfg <<-EOF + # There was -Wl,-z,relro here, but it's not supported on Mac + # TODO: investigate whether -bind_at_load or -read_only_stubs will do the job + EOF + else + newins - gentoo-hardened-ld.cfg <<-EOF + # Some of these options are added unconditionally, regardless of + # USE=hardened, for parity with sys-devel/gcc. + -Wl,-z,relro + -Wl,-z,now + EOF + fi + + dodir /usr/include/gentoo + + cat >> "${ED}/usr/include/gentoo/maybe-stddefs.h" <<-EOF || die + /* __has_include is an extension, but it's fine, because this is only + for Clang anyway. */ + #if defined __has_include && __has_include () && !defined(__GLIBC__) + # include + #endif + EOF + + local fortify_level=$(usex hardened 3 2) + # We have to do this because glibc's headers warn if F_S is set + # without optimization and that would at the very least be very noisy + # during builds and at worst trigger many -Werror builds. + cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die + #ifdef __clang__ + # pragma clang system_header + #endif + #ifndef _FORTIFY_SOURCE + # if defined(__has_feature) + # define __GENTOO_HAS_FEATURE(x) __has_feature(x) + # else + # define __GENTOO_HAS_FEATURE(x) 0 + # endif + # + # if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1 + # define __GENTOO_NOT_FREESTANDING 1 + # else + # define __GENTOO_NOT_FREESTANDING 0 + # endif + # + # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && __GENTOO_NOT_FREESTANDING > 0 + # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) + # define _FORTIFY_SOURCE ${fortify_level} + # endif + # endif + # undef __GENTOO_HAS_FEATURE + # undef __GENTOO_NOT_FREESTANDING + #endif + EOF + + # TODO: Maybe -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST for + # non-hardened? + if use hardened ; then + cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die + # Options below are conditional on USE=hardened. + -D_GLIBCXX_ASSERTIONS + + # Analogue to GLIBCXX_ASSERTIONS + # https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode + # https://libcxx.llvm.org/Hardening.html#using-hardened-mode + -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE + EOF + + cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die + # Options below are conditional on USE=hardened. + EOF + fi + + # We only install config files for supported ABIs because unprefixed tools + # might be used for crosscompilation where e.g. PIE may not be supported. + # See bug #912237 and bug #901247. Just ${CHOST} won't do due to bug #912685. + local abi + for abi in $(get_all_abis); do + local abi_chost=$(get_abi_CHOST "${abi}") + doclang_cfg "${abi_chost}" + done + + if use kernel_Darwin; then + cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die + # Gentoo Prefix on Darwin + -Wl,-search_paths_first + -Wl,-rpath,${EPREFIX}/usr/lib + -L ${EPREFIX}/usr/lib + -isystem ${EPREFIX}/usr/include + -isysroot ${EPREFIX}/MacOSX.sdk + EOF + if use bootstrap-prefix ; then + # bootstrap-prefix is only set during stage2 of bootstrapping + # Prefix, where EPREFIX is set to EPREFIX/tmp. + # Here we need to point it at the future lib dir of the stage3's + # EPREFIX. + cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die + -Wl,-rpath,${EPREFIX}/../usr/lib + EOF + fi + fi +} + +pkg_preinst() { + if has_version -b sys-devel/gcc-config && has_version sys-devel/gcc + then + local gcc_path=$(gcc-config --get-lib-path 2>/dev/null) + if [[ -n ${gcc_path} ]]; then + cat >> "${ED}/etc/clang/gentoo-gcc-install.cfg" <<-EOF + --gcc-install-dir="${gcc_path%%:*}" + EOF + fi + fi +} diff --git a/sys-devel/clang-common/clang-common-19.0.0.9999.ebuild b/sys-devel/clang-common/clang-common-19.0.0.9999.ebuild index 290d4ee063fe..4cc526c1c3d1 100644 --- a/sys-devel/clang-common/clang-common-19.0.0.9999.ebuild +++ b/sys-devel/clang-common/clang-common-19.0.0.9999.ebuild @@ -168,15 +168,15 @@ src_install() { newins - gentoo-hardened.cfg <<-EOF # Some of these options are added unconditionally, regardless of # USE=hardened, for parity with sys-devel/gcc. - -fstack-clash-protection - -fstack-protector-strong + -Xarch_host -fstack-clash-protection + -Xarch_host -fstack-protector-strong -fPIE -include "${EPREFIX}/usr/include/gentoo/fortify.h" EOF if use amd64; then cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die - -fcf-protection=$(usex cet full none) + -Xarch_host -fcf-protection=$(usex cet full none) EOF fi diff --git a/sys-devel/clang-common/clang-common-19.0.0_pre20240322-r1.ebuild b/sys-devel/clang-common/clang-common-19.0.0_pre20240322-r1.ebuild new file mode 100644 index 000000000000..4cc526c1c3d1 --- /dev/null +++ b/sys-devel/clang-common/clang-common-19.0.0_pre20240322-r1.ebuild @@ -0,0 +1,296 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit bash-completion-r1 llvm.org multilib + +DESCRIPTION="Common files shared between multiple slots of clang" +HOMEPAGE="https://llvm.org/" + +LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA" +SLOT="0" +IUSE=" + default-compiler-rt default-libcxx default-lld + bootstrap-prefix cet hardened llvm-libunwind +" + +PDEPEND=" + sys-devel/clang:* + default-compiler-rt? ( + sys-devel/clang-runtime[compiler-rt] + llvm-libunwind? ( sys-libs/llvm-libunwind[static-libs] ) + !llvm-libunwind? ( sys-libs/libunwind[static-libs] ) + ) + !default-compiler-rt? ( sys-devel/gcc ) + default-libcxx? ( >=sys-libs/libcxx-${PV}[static-libs] ) + !default-libcxx? ( sys-devel/gcc ) + default-lld? ( sys-devel/lld ) + !default-lld? ( sys-devel/binutils ) +" +IDEPEND=" + !default-compiler-rt? ( sys-devel/gcc-config ) + !default-libcxx? ( sys-devel/gcc-config ) +" + +LLVM_COMPONENTS=( clang/utils ) +llvm.org_set_globals + +pkg_pretend() { + [[ ${CLANG_IGNORE_DEFAULT_RUNTIMES} ]] && return + + local flag missing_flags=() + for flag in default-{compiler-rt,libcxx,lld}; do + if ! use "${flag}" && has_version "sys-devel/clang[${flag}]"; then + missing_flags+=( "${flag}" ) + fi + done + + if [[ ${missing_flags[@]} ]]; then + eerror "It seems that you have the following flags set on sys-devel/clang:" + eerror + eerror " ${missing_flags[*]}" + eerror + eerror "The default runtimes are now set via flags on sys-devel/clang-common." + eerror "The build is being aborted to prevent breakage. Please either set" + eerror "the respective flags on this ebuild, e.g.:" + eerror + eerror " sys-devel/clang-common ${missing_flags[*]}" + eerror + eerror "or build with CLANG_IGNORE_DEFAULT_RUNTIMES=1." + die "Mismatched defaults detected between sys-devel/clang and sys-devel/clang-common" + fi +} + +_doclang_cfg() { + local triple="${1}" + + local tool + for tool in ${triple}-clang{,++}; do + newins - "${tool}.cfg" <<-EOF + # This configuration file is used by ${tool} driver. + @gentoo-common.cfg + @gentoo-common-ld.cfg + EOF + done + + if use kernel_Darwin; then + cat >> "${ED}/etc/clang/${triple}-clang++.cfg" <<-EOF || die + -lc++abi + EOF + fi + + newins - "${triple}-clang-cpp.cfg" <<-EOF + # This configuration file is used by the ${triple}-clang-cpp driver. + @gentoo-common.cfg + EOF + + # Install symlinks for triples with other vendor strings since some + # programs insist on mangling the triple. + local vendor + for vendor in gentoo pc unknown; do + local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}" + for tool in clang{,++,-cpp}; do + if [[ ! -f "${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then + dosym "${triple}-${tool}.cfg" "/etc/clang/${vendor_triple}-${tool}.cfg" + fi + done + done +} + +doclang_cfg() { + local triple="${1}" + + _doclang_cfg ${triple} + + # LLVM may have different arch names in some cases. For example in x86 + # profiles the triple uses i686, but llvm will prefer i386 if invoked + # with "clang" on x86 or "clang -m32" on x86_64. The gentoo triple will + # be used if invoked through ${CHOST}-clang{,++,-cpp} though. + # + # To make sure the correct triples are installed, + # see Triple::getArchTypeName() in llvm/lib/TargetParser/Triple.cpp + # and compare with CHOST values in profiles. + + local abi=${triple%%-*} + case ${abi} in + armv4l|armv4t|armv5tel|armv6j|armv7a) + _doclang_cfg ${triple/${abi}/arm} + ;; + i686) + _doclang_cfg ${triple/${abi}/i386} + ;; + sparc) + _doclang_cfg ${triple/${abi}/sparcel} + ;; + sparc64) + _doclang_cfg ${triple/${abi}/sparcv9} + ;; + esac +} + +src_install() { + newbashcomp bash-autocomplete.sh clang + + insinto /etc/clang + newins - gentoo-runtimes.cfg <<-EOF + # This file is initially generated by sys-devel/clang-runtime. + # It is used to control the default runtimes using by clang. + + --rtlib=$(usex default-compiler-rt compiler-rt libgcc) + --unwindlib=$(usex default-compiler-rt libunwind libgcc) + --stdlib=$(usex default-libcxx libc++ libstdc++) + -fuse-ld=$(usex default-lld lld bfd) + EOF + + newins - gentoo-gcc-install.cfg <<-EOF + # This file is maintained by gcc-config. + # It is used to specify the selected GCC installation. + EOF + + newins - gentoo-common.cfg <<-EOF + # This file contains flags common to clang, clang++ and clang-cpp. + @gentoo-runtimes.cfg + @gentoo-gcc-install.cfg + @gentoo-hardened.cfg + # bug #870001 + -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h" + EOF + + # clang-cpp does not like link args being passed to it when directly + # invoked, so use a separate configuration file. + newins - gentoo-common-ld.cfg <<-EOF + # This file contains flags common to clang and clang++ + @gentoo-hardened-ld.cfg + EOF + + # Baseline hardening (bug #851111) + newins - gentoo-hardened.cfg <<-EOF + # Some of these options are added unconditionally, regardless of + # USE=hardened, for parity with sys-devel/gcc. + -Xarch_host -fstack-clash-protection + -Xarch_host -fstack-protector-strong + -fPIE + -include "${EPREFIX}/usr/include/gentoo/fortify.h" + EOF + + if use amd64; then + cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die + -Xarch_host -fcf-protection=$(usex cet full none) + EOF + fi + + if use kernel_Darwin; then + newins - gentoo-hardened-ld.cfg <<-EOF + # There was -Wl,-z,relro here, but it's not supported on Mac + # TODO: investigate whether -bind_at_load or -read_only_stubs will do the job + EOF + else + newins - gentoo-hardened-ld.cfg <<-EOF + # Some of these options are added unconditionally, regardless of + # USE=hardened, for parity with sys-devel/gcc. + -Wl,-z,relro + -Wl,-z,now + EOF + fi + + dodir /usr/include/gentoo + + cat >> "${ED}/usr/include/gentoo/maybe-stddefs.h" <<-EOF || die + /* __has_include is an extension, but it's fine, because this is only + for Clang anyway. */ + #if defined __has_include && __has_include () && !defined(__GLIBC__) + # include + #endif + EOF + + local fortify_level=$(usex hardened 3 2) + # We have to do this because glibc's headers warn if F_S is set + # without optimization and that would at the very least be very noisy + # during builds and at worst trigger many -Werror builds. + cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die + #ifdef __clang__ + # pragma clang system_header + #endif + #ifndef _FORTIFY_SOURCE + # if defined(__has_feature) + # define __GENTOO_HAS_FEATURE(x) __has_feature(x) + # else + # define __GENTOO_HAS_FEATURE(x) 0 + # endif + # + # if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1 + # define __GENTOO_NOT_FREESTANDING 1 + # else + # define __GENTOO_NOT_FREESTANDING 0 + # endif + # + # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && __GENTOO_NOT_FREESTANDING > 0 + # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) + # define _FORTIFY_SOURCE ${fortify_level} + # endif + # endif + # undef __GENTOO_HAS_FEATURE + # undef __GENTOO_NOT_FREESTANDING + #endif + EOF + + # TODO: Maybe -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST for + # non-hardened? + if use hardened ; then + cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die + # Options below are conditional on USE=hardened. + -D_GLIBCXX_ASSERTIONS + + # Analogue to GLIBCXX_ASSERTIONS + # https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode + # https://libcxx.llvm.org/Hardening.html#using-hardened-mode + -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE + EOF + + cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die + # Options below are conditional on USE=hardened. + EOF + fi + + # We only install config files for supported ABIs because unprefixed tools + # might be used for crosscompilation where e.g. PIE may not be supported. + # See bug #912237 and bug #901247. Just ${CHOST} won't do due to bug #912685. + local abi + for abi in $(get_all_abis); do + local abi_chost=$(get_abi_CHOST "${abi}") + doclang_cfg "${abi_chost}" + done + + if use kernel_Darwin; then + cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die + # Gentoo Prefix on Darwin + -Wl,-search_paths_first + -Wl,-rpath,${EPREFIX}/usr/lib + -L ${EPREFIX}/usr/lib + -isystem ${EPREFIX}/usr/include + -isysroot ${EPREFIX}/MacOSX.sdk + EOF + if use bootstrap-prefix ; then + # bootstrap-prefix is only set during stage2 of bootstrapping + # Prefix, where EPREFIX is set to EPREFIX/tmp. + # Here we need to point it at the future lib dir of the stage3's + # EPREFIX. + cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die + -Wl,-rpath,${EPREFIX}/../usr/lib + EOF + fi + fi +} + +pkg_preinst() { + if has_version -b sys-devel/gcc-config && has_version sys-devel/gcc + then + local gcc_path=$(gcc-config --get-lib-path 2>/dev/null) + if [[ -n ${gcc_path} ]]; then + cat >> "${ED}/etc/clang/gentoo-gcc-install.cfg" <<-EOF + --gcc-install-dir="${gcc_path%%:*}" + EOF + fi + fi +} diff --git a/sys-devel/clang-common/clang-common-19.0.0_pre20240322.ebuild b/sys-devel/clang-common/clang-common-19.0.0_pre20240322.ebuild deleted file mode 100644 index 290d4ee063fe..000000000000 --- a/sys-devel/clang-common/clang-common-19.0.0_pre20240322.ebuild +++ /dev/null @@ -1,296 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -inherit bash-completion-r1 llvm.org multilib - -DESCRIPTION="Common files shared between multiple slots of clang" -HOMEPAGE="https://llvm.org/" - -LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA" -SLOT="0" -IUSE=" - default-compiler-rt default-libcxx default-lld - bootstrap-prefix cet hardened llvm-libunwind -" - -PDEPEND=" - sys-devel/clang:* - default-compiler-rt? ( - sys-devel/clang-runtime[compiler-rt] - llvm-libunwind? ( sys-libs/llvm-libunwind[static-libs] ) - !llvm-libunwind? ( sys-libs/libunwind[static-libs] ) - ) - !default-compiler-rt? ( sys-devel/gcc ) - default-libcxx? ( >=sys-libs/libcxx-${PV}[static-libs] ) - !default-libcxx? ( sys-devel/gcc ) - default-lld? ( sys-devel/lld ) - !default-lld? ( sys-devel/binutils ) -" -IDEPEND=" - !default-compiler-rt? ( sys-devel/gcc-config ) - !default-libcxx? ( sys-devel/gcc-config ) -" - -LLVM_COMPONENTS=( clang/utils ) -llvm.org_set_globals - -pkg_pretend() { - [[ ${CLANG_IGNORE_DEFAULT_RUNTIMES} ]] && return - - local flag missing_flags=() - for flag in default-{compiler-rt,libcxx,lld}; do - if ! use "${flag}" && has_version "sys-devel/clang[${flag}]"; then - missing_flags+=( "${flag}" ) - fi - done - - if [[ ${missing_flags[@]} ]]; then - eerror "It seems that you have the following flags set on sys-devel/clang:" - eerror - eerror " ${missing_flags[*]}" - eerror - eerror "The default runtimes are now set via flags on sys-devel/clang-common." - eerror "The build is being aborted to prevent breakage. Please either set" - eerror "the respective flags on this ebuild, e.g.:" - eerror - eerror " sys-devel/clang-common ${missing_flags[*]}" - eerror - eerror "or build with CLANG_IGNORE_DEFAULT_RUNTIMES=1." - die "Mismatched defaults detected between sys-devel/clang and sys-devel/clang-common" - fi -} - -_doclang_cfg() { - local triple="${1}" - - local tool - for tool in ${triple}-clang{,++}; do - newins - "${tool}.cfg" <<-EOF - # This configuration file is used by ${tool} driver. - @gentoo-common.cfg - @gentoo-common-ld.cfg - EOF - done - - if use kernel_Darwin; then - cat >> "${ED}/etc/clang/${triple}-clang++.cfg" <<-EOF || die - -lc++abi - EOF - fi - - newins - "${triple}-clang-cpp.cfg" <<-EOF - # This configuration file is used by the ${triple}-clang-cpp driver. - @gentoo-common.cfg - EOF - - # Install symlinks for triples with other vendor strings since some - # programs insist on mangling the triple. - local vendor - for vendor in gentoo pc unknown; do - local vendor_triple="${triple%%-*}-${vendor}-${triple#*-*-}" - for tool in clang{,++,-cpp}; do - if [[ ! -f "${ED}/etc/clang/${vendor_triple}-${tool}.cfg" ]]; then - dosym "${triple}-${tool}.cfg" "/etc/clang/${vendor_triple}-${tool}.cfg" - fi - done - done -} - -doclang_cfg() { - local triple="${1}" - - _doclang_cfg ${triple} - - # LLVM may have different arch names in some cases. For example in x86 - # profiles the triple uses i686, but llvm will prefer i386 if invoked - # with "clang" on x86 or "clang -m32" on x86_64. The gentoo triple will - # be used if invoked through ${CHOST}-clang{,++,-cpp} though. - # - # To make sure the correct triples are installed, - # see Triple::getArchTypeName() in llvm/lib/TargetParser/Triple.cpp - # and compare with CHOST values in profiles. - - local abi=${triple%%-*} - case ${abi} in - armv4l|armv4t|armv5tel|armv6j|armv7a) - _doclang_cfg ${triple/${abi}/arm} - ;; - i686) - _doclang_cfg ${triple/${abi}/i386} - ;; - sparc) - _doclang_cfg ${triple/${abi}/sparcel} - ;; - sparc64) - _doclang_cfg ${triple/${abi}/sparcv9} - ;; - esac -} - -src_install() { - newbashcomp bash-autocomplete.sh clang - - insinto /etc/clang - newins - gentoo-runtimes.cfg <<-EOF - # This file is initially generated by sys-devel/clang-runtime. - # It is used to control the default runtimes using by clang. - - --rtlib=$(usex default-compiler-rt compiler-rt libgcc) - --unwindlib=$(usex default-compiler-rt libunwind libgcc) - --stdlib=$(usex default-libcxx libc++ libstdc++) - -fuse-ld=$(usex default-lld lld bfd) - EOF - - newins - gentoo-gcc-install.cfg <<-EOF - # This file is maintained by gcc-config. - # It is used to specify the selected GCC installation. - EOF - - newins - gentoo-common.cfg <<-EOF - # This file contains flags common to clang, clang++ and clang-cpp. - @gentoo-runtimes.cfg - @gentoo-gcc-install.cfg - @gentoo-hardened.cfg - # bug #870001 - -include "${EPREFIX}/usr/include/gentoo/maybe-stddefs.h" - EOF - - # clang-cpp does not like link args being passed to it when directly - # invoked, so use a separate configuration file. - newins - gentoo-common-ld.cfg <<-EOF - # This file contains flags common to clang and clang++ - @gentoo-hardened-ld.cfg - EOF - - # Baseline hardening (bug #851111) - newins - gentoo-hardened.cfg <<-EOF - # Some of these options are added unconditionally, regardless of - # USE=hardened, for parity with sys-devel/gcc. - -fstack-clash-protection - -fstack-protector-strong - -fPIE - -include "${EPREFIX}/usr/include/gentoo/fortify.h" - EOF - - if use amd64; then - cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die - -fcf-protection=$(usex cet full none) - EOF - fi - - if use kernel_Darwin; then - newins - gentoo-hardened-ld.cfg <<-EOF - # There was -Wl,-z,relro here, but it's not supported on Mac - # TODO: investigate whether -bind_at_load or -read_only_stubs will do the job - EOF - else - newins - gentoo-hardened-ld.cfg <<-EOF - # Some of these options are added unconditionally, regardless of - # USE=hardened, for parity with sys-devel/gcc. - -Wl,-z,relro - -Wl,-z,now - EOF - fi - - dodir /usr/include/gentoo - - cat >> "${ED}/usr/include/gentoo/maybe-stddefs.h" <<-EOF || die - /* __has_include is an extension, but it's fine, because this is only - for Clang anyway. */ - #if defined __has_include && __has_include () && !defined(__GLIBC__) - # include - #endif - EOF - - local fortify_level=$(usex hardened 3 2) - # We have to do this because glibc's headers warn if F_S is set - # without optimization and that would at the very least be very noisy - # during builds and at worst trigger many -Werror builds. - cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die - #ifdef __clang__ - # pragma clang system_header - #endif - #ifndef _FORTIFY_SOURCE - # if defined(__has_feature) - # define __GENTOO_HAS_FEATURE(x) __has_feature(x) - # else - # define __GENTOO_HAS_FEATURE(x) 0 - # endif - # - # if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1 - # define __GENTOO_NOT_FREESTANDING 1 - # else - # define __GENTOO_NOT_FREESTANDING 0 - # endif - # - # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && __GENTOO_NOT_FREESTANDING > 0 - # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) - # define _FORTIFY_SOURCE ${fortify_level} - # endif - # endif - # undef __GENTOO_HAS_FEATURE - # undef __GENTOO_NOT_FREESTANDING - #endif - EOF - - # TODO: Maybe -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST for - # non-hardened? - if use hardened ; then - cat >> "${ED}/etc/clang/gentoo-hardened.cfg" <<-EOF || die - # Options below are conditional on USE=hardened. - -D_GLIBCXX_ASSERTIONS - - # Analogue to GLIBCXX_ASSERTIONS - # https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode - # https://libcxx.llvm.org/Hardening.html#using-hardened-mode - -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE - EOF - - cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die - # Options below are conditional on USE=hardened. - EOF - fi - - # We only install config files for supported ABIs because unprefixed tools - # might be used for crosscompilation where e.g. PIE may not be supported. - # See bug #912237 and bug #901247. Just ${CHOST} won't do due to bug #912685. - local abi - for abi in $(get_all_abis); do - local abi_chost=$(get_abi_CHOST "${abi}") - doclang_cfg "${abi_chost}" - done - - if use kernel_Darwin; then - cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die - # Gentoo Prefix on Darwin - -Wl,-search_paths_first - -Wl,-rpath,${EPREFIX}/usr/lib - -L ${EPREFIX}/usr/lib - -isystem ${EPREFIX}/usr/include - -isysroot ${EPREFIX}/MacOSX.sdk - EOF - if use bootstrap-prefix ; then - # bootstrap-prefix is only set during stage2 of bootstrapping - # Prefix, where EPREFIX is set to EPREFIX/tmp. - # Here we need to point it at the future lib dir of the stage3's - # EPREFIX. - cat >> "${ED}/etc/clang/gentoo-common.cfg" <<-EOF || die - -Wl,-rpath,${EPREFIX}/../usr/lib - EOF - fi - fi -} - -pkg_preinst() { - if has_version -b sys-devel/gcc-config && has_version sys-devel/gcc - then - local gcc_path=$(gcc-config --get-lib-path 2>/dev/null) - if [[ -n ${gcc_path} ]]; then - cat >> "${ED}/etc/clang/gentoo-gcc-install.cfg" <<-EOF - --gcc-install-dir="${gcc_path%%:*}" - EOF - fi - fi -} -- cgit v1.2.3