commit:     ed23e0de0526af9a3d1c4214508ea014bb44def6
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat May 20 19:20:13 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun May 21 04:02:59 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ed23e0de

sys-devel/clang-common: Add 17.0.0_pre20230520 snapshot

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

 sys-devel/clang-common/Manifest                    |   1 +
 .../clang-common-17.0.0_pre20230520.ebuild         | 190 +++++++++++++++++++++
 2 files changed, 191 insertions(+)

diff --git a/sys-devel/clang-common/Manifest b/sys-devel/clang-common/Manifest
index 613e780805df..8526c1e2e3e1 100644
--- a/sys-devel/clang-common/Manifest
+++ b/sys-devel/clang-common/Manifest
@@ -8,3 +8,4 @@ DIST llvm-project-16.0.4.src.tar.xz 117996332 BLAKE2B 
2ea3ef25290ce6180d271e42fb
 DIST llvm-project-16.0.4.src.tar.xz.sig 566 BLAKE2B 
43cb2147f12f98f864797158e8efcfed9c6780fae3b5c71c0f1aea19a4131ee91c36bdf5b10e44f478f2370c8d22a9038038ecd607f25a95f2d3e33628eb9ac0
 SHA512 
c902d1b652e6e144fcf74f550539f56665475b6bdf673ba5bf2f1731c3bb8f5717ed56433d488c54bbf2f429b432da84e0bfb4b5fb5f2b7fa208b4f24f682be7
 DIST llvm-project-52882de0e641487329c9e093a90ea3dad01842c8.tar.gz 182953335 
BLAKE2B 
98682729992d73202e35b540d5d0d87e2acf44e4ab6896a0b6f9ac4a7423f55ad370ae1d7e919a6c86dc7f138a66890ac89b852b03305612d248ab567833f8be
 SHA512 
3685aff0f648e9b477e1e01edebe4799498c21587e2ed5577e2fdef98bb21ea215e206606a11692fbb93a0989fd59fd324faff2c4d97b7afca0851b53f123f05
 DIST llvm-project-7d436d56b60b36508b94e39d08761f1405a9c770.tar.gz 183363091 
BLAKE2B 
e0d3520814b3455e33107715697f00d653ad46bb8d8200caf42c42743520f389217ea2e57449bbc2e98126b602b2aa344e4125e4b1f92152f7957a11a9b9a150
 SHA512 
65a8e30702217e5e1309efe3daeda5115eeb2e8d25238db1fa4e8dcfc729d75655a10b3394f2f70b7e7efb8ea33a31b6e2482065cc81805023101da00584a81e
+DIST llvm-project-abbb22cc0c9c33dedb8d53c2bd3e703f92baace7.tar.gz 183193919 
BLAKE2B 
75c63d39918f7ec0faca0b1d03ba17dbd7d39a6f1d3a031dcb005ae1729933d8481f0bd745ec029ab21779525b2ddaf2989eaca2aed2b0e9b60c50ef71c7fc11
 SHA512 
f0c1b6fe2e087db202d32de05613b7570bd9a82dfef2e464014c9d4c9ba02c20d423cb783aa40ce5e9c9e074288efb2e5b6d70d55913bd285108e747400f55e7

diff --git a/sys-devel/clang-common/clang-common-17.0.0_pre20230520.ebuild 
b/sys-devel/clang-common/clang-common-17.0.0_pre20230520.ebuild
new file mode 100644
index 000000000000..51e0f70c6470
--- /dev/null
+++ b/sys-devel/clang-common/clang-common-17.0.0_pre20230520.ebuild
@@ -0,0 +1,190 @@
+# Copyright 1999-2023 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=""
+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} )
+       !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.
+               -fstack-clash-protection
+               -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 (<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(__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
+
+                       # constructs banned by C2x
+                       -Werror=deprecated-non-prototype
+
+                       # deprecated but large blast radius
+                       #-Werror=strict-prototypes
+               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
+}

Reply via email to