commit:     fb17598153fc2813a9d9af63d42324c91cab28a3
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 11 19:01:23 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Nov 11 20:23:35 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fb175981

sys-devel/clang-common: Add 18.0.0_pre20231111 snapshot

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 sys-devel/clang-common/Manifest                    |   1 +
 .../clang-common-18.0.0_pre20231111.ebuild         | 227 +++++++++++++++++++++
 2 files changed, 228 insertions(+)

diff --git a/sys-devel/clang-common/Manifest b/sys-devel/clang-common/Manifest
index db6bc21c0cb1..9b46ca981c1d 100644
--- a/sys-devel/clang-common/Manifest
+++ b/sys-devel/clang-common/Manifest
@@ -4,6 +4,7 @@ DIST llvm-project-15.0.7.src.tar.xz 110936452 BLAKE2B 
f3d277e2029157329e5be78b78
 DIST llvm-project-15.0.7.src.tar.xz.sig 566 BLAKE2B 
47dc8c82d86237b80c6d85f83a6c9a6e9e174cf8e7f367b071e0cd9481d7cd408e991337c5624e07f3f370f26387c814f212808575ed1c1b58404d3e3836b7df
 SHA512 
fc6891b440dd1175eb8df3790590af8d36bc92301660f84744ae15123475aeb900a151e6a8e7998ded27ec4d86871903ad0b89cd61164943054c2e3bc8d8beb2
 DIST llvm-project-16.0.6.src.tar.xz 118013488 BLAKE2B 
95192d39cbd2914e5609db365965f1c00bfea6c2d653b3996bd2acef8a2b37e37f6fc8a9d2b65711ad72657e0ef52c42f733053cf65051e7822f27396c30406d
 SHA512 
89a67ebfbbc764cc456e8825ecfa90707741f8835b1b2adffae0b227ab1fe5ca9cce75b0efaffc9ca8431cae528dc54fd838867a56a2b645344d9e82d19ab1b7
 DIST llvm-project-16.0.6.src.tar.xz.sig 566 BLAKE2B 
2060cebd5ed57cb8a86a44238c43dfd4b921649298b10c3d19da308374c1e49869174294e29943c2af459fe06428264e26881d6c1288ebbc48686cc2cf467c7a
 SHA512 
ca249262c7102e0889ec1bdc6f71a3a6f0e7e5d5fbab8abcd6fccd2871e7955eff7af5b055a76006097baf0dfaf2f5069eff3035b3107fc552abdb2481b21447
+DIST llvm-project-167b598648dfcee2f23426bfa972e53f8ac16722.tar.gz 201158314 
BLAKE2B 
908d42b0148f04eeab8d05d46736c570ffdea7d66273aa428375f944deaaf1c0ca885ef0fbe04588d838e4f831ff9823365f9df700f9e9de08c700f0135f2e59
 SHA512 
7da16df850245ba70e4ddf318a0e7322ed68b076337325c3d3702bb428358d11137b6254051cc6a34d047789f107fd96065cd169c9b2684f78b3a54c4f566a78
 DIST llvm-project-17.0.4.src.tar.xz 127828636 BLAKE2B 
bd91ef7f07e085b935500b056f75ab792d13e7f33825df36e85e7988f313a4f3fbb1b4c854615a5e437a97ad552838eb1be5098194f281ba1279330156dd6a38
 SHA512 
6703eede8013e7e5733fbd7b527757166d5698f52e239522fb320717430c88696309038501d22fe384b016b330bd92126a2c0ba88b0258c3f092801e3800b7a3
 DIST llvm-project-17.0.4.src.tar.xz.sig 438 BLAKE2B 
e417c14d0af8c2f13eccec7a42d0e4d5a6a834d7a3d31061b9f56f7e880cd982c2b1e84322bcf8f6a3d3167519c31f16c7acb8fc725ab5b453f467a196ca2688
 SHA512 
4e79bb1d2b41289c092d4ec2759d7cfd4f12df8d107f9510aa9e2354691e7f878e3929b2b50e29fd6c65bd5a3aa13baf6b791847c1cd99817adbf59700cf2bdd
 DIST llvm-project-83888a5404d46667647fe36d6fa510d075ed57ea.tar.gz 200867834 
BLAKE2B 
20f5afa071089852abfdcc316e5db77681afe0fdb189a515d7724a0abaf1c545f37ba4b946414c7b8afca62636107bd4e1c7c99d8ba6a514bb413b13f5f634b0
 SHA512 
4cd7680a227388382076d5735a97a379546f5bdde33272a5a3d317d98c2847e34917dd38a3cfb3f1f677f6d9a9b2163b29f89dd9c4b92506f5be34a3072e0509

diff --git a/sys-devel/clang-common/clang-common-18.0.0_pre20231111.ebuild 
b/sys-devel/clang-common/clang-common-18.0.0_pre20231111.ebuild
new file mode 100644
index 000000000000..b58ed6b486c2
--- /dev/null
+++ b/sys-devel/clang-common/clang-common-18.0.0_pre20231111.ebuild
@@ -0,0 +1,227 @@
+# Copyright 1999-2023 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 llvm-libunwind
+       hardened
+"
+
+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
+
+       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
+}
+
+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
+
+       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
+       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 (<stdc-predef.h>) && 
!defined(__GLIBC__)
+       # include <stdc-predef.h>
+       #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_HARDENED_MODE=1
+               EOF
+
+               cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die
+                       # Options below are conditional on USE=hardened.
+                       -Wl,-z,now
+               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.
+       doclang_cfg "${CHOST}"
+
+       # 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
+}
+
+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
+}

Reply via email to