mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-09-24 04:59:14 -07:00
sys-devel/clang-common: Remove old
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
@@ -4,10 +4,6 @@ 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-17.0.0rc3.src.tar.xz 127805656 BLAKE2B ecaead9f227b8357a5dc5ff21554d9b4f5aa036df1b88676fd8c3e16b438381db062872be396af5246e12cd71812a886016e0331a272dafc3508ecd0bfbb50ed SHA512 5f48b4af2e4f9bc470fcfd42fd48072b7bd442bc676d8401b04fbc6e9014a9a78e1bf524ba78f7ae8a1246222a6b03ca662721e3bf6e9eb03a015dd3306c7234
|
||||
DIST llvm-project-17.0.0rc3.src.tar.xz.sig 438 BLAKE2B 7b644cf501d17a6aef9b052e359ba06c1840a75e5263de46d938dbbdea07720b53d7ee6b5861ad641d0f7a7f75c6cc17717847b0ea9cf08873dbfacbe1c19074 SHA512 7059b1a90b7dd8cfa831f9e199a3a817358fd75d7c7d7e6de446d5443fce5831877a28e9b964ea238c1d803f9054bf4f53a97622d5f756f7f99aaa1c1a279f44
|
||||
DIST llvm-project-17.0.0rc4.src.tar.xz 127838724 BLAKE2B e3bf524e55db5e4305099ecdff09c0d3eab7957a5f8729eefe636e361460f405fbfd569af38aa39eea3b6c1e024feaa0400f8bc092194f2c3b54c695e7962591 SHA512 be7b5ad136d03864dbd11a589ca9e8b0b04a4226ebcffcc123b3ba72992f704bab4f9550d03eb2ac1d21fb8b73ac7824398b4cb4c9cec2118efb112babfe0f65
|
||||
DIST llvm-project-17.0.0rc4.src.tar.xz.sig 438 BLAKE2B 2cda35b4a3ebddfdbe6828459c8bd8fdfaa8e04d2d1c4f2faf16f5c66909186d2dd73e6a163cf733d8955c007249cf3f62f237855d5a76b1b61f3bfa30e4972d SHA512 5f713e05b7c58fab6e9cc43f2f3f69120482c9b60008146da0cddb266d1a5c9b9a77e1e338fce4e15624b332ac53a90c5c4a6f62c58a77f2122a015b4f0ebed2
|
||||
DIST llvm-project-7e5809e7e7bc9a828427b6540a51d45884d8bbbb.tar.gz 197275742 BLAKE2B 17df09155cf3451deffcdd71a4b0602211a4638ad961eb351802028f4fd1b8db870bef817430adb709ea7c1e85f545d7507c06d7fca26869f8a10e6ac6b03967 SHA512 e84aa041aadf3e50376cffd1e92c1447acdca0a2cf8e7df9cca9d0337dfeccb1d022da3a229bb0cfdc9c5fb87215682a1e4f474208b09b8800f30aa0c6e36c4b
|
||||
DIST llvm-project-e3373c6c83d3855adb78f1952a3bf0398baf359e.tar.gz 196926975 BLAKE2B 9da1052db0a6ff81a8b76cbf9cb2ab7eed5c8798dc5ae6887a4694de8b151c7a1282cfff2da2e8440b1a67d3d12c33db319fbbe6062761b6d5369e6b335821ae SHA512 8bb6d49ddb824e932f7bad3c51e4a6c2227139aaf19c02e9deb15657919bc12ea41844d8fe045061814aefb9031d82b167c7c0c20bedaa09aaffe164a2109f7d
|
||||
DIST llvm-project-f6259d9b9a546dbfa5bc2f29313c6edd6c701177.tar.gz 196957045 BLAKE2B c38b17f4e697c090b0b70385e45ca4ce97981746738e556154895d5b57cede90f6b8bdc5f41023bda6e942f07f572aa508cf0107fb81bee80a5ea9f13ac495fd SHA512 8394a42e1963618ed7f7cf7770acb72ae6bf84f3e2351218b5049ea2d76ff6ae768ad5588ffd1b2be1b5228a8fcb03663430814c409ceb9fa5735c891847f816
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
# 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"
|
||||
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}[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.
|
||||
-fstack-clash-protection
|
||||
-fstack-protector-strong
|
||||
-fPIE
|
||||
-include "${EPREFIX}/usr/include/gentoo/fortify.h"
|
||||
|
||||
-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(__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
|
||||
# https://libcxx.llvm.org/Hardening.html#using-hardened-mode
|
||||
-D_LIBCPP_ENABLE_HARDENED_MODE=1
|
||||
|
||||
-Wl,-z,now
|
||||
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
|
||||
|
||||
# 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}")
|
||||
|
||||
local tool
|
||||
for tool in ${abi_chost}-clang{,++,-cpp}; do
|
||||
newins - "${tool}.cfg" <<-EOF
|
||||
# This configuration file is used by ${tool} driver.
|
||||
@gentoo-common.cfg
|
||||
EOF
|
||||
done
|
||||
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
|
||||
}
|
||||
@@ -1,204 +0,0 @@
|
||||
# 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"
|
||||
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}[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.
|
||||
-fstack-clash-protection
|
||||
-fstack-protector-strong
|
||||
-fPIE
|
||||
-include "${EPREFIX}/usr/include/gentoo/fortify.h"
|
||||
|
||||
-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(__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
|
||||
# https://libcxx.llvm.org/Hardening.html#using-hardened-mode
|
||||
-D_LIBCPP_ENABLE_HARDENED_MODE=1
|
||||
|
||||
-Wl,-z,now
|
||||
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
|
||||
|
||||
# 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}")
|
||||
|
||||
local tool
|
||||
for tool in ${abi_chost}-clang{,++,-cpp}; do
|
||||
newins - "${tool}.cfg" <<-EOF
|
||||
# This configuration file is used by ${tool} driver.
|
||||
@gentoo-common.cfg
|
||||
EOF
|
||||
done
|
||||
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
|
||||
}
|
||||
@@ -1,204 +0,0 @@
|
||||
# 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"
|
||||
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}[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.
|
||||
-fstack-clash-protection
|
||||
-fstack-protector-strong
|
||||
-fPIE
|
||||
-include "${EPREFIX}/usr/include/gentoo/fortify.h"
|
||||
|
||||
-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(__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
|
||||
# https://libcxx.llvm.org/Hardening.html#using-hardened-mode
|
||||
-D_LIBCPP_ENABLE_HARDENED_MODE=1
|
||||
|
||||
-Wl,-z,now
|
||||
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
|
||||
|
||||
# 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}")
|
||||
|
||||
local tool
|
||||
for tool in ${abi_chost}-clang{,++,-cpp}; do
|
||||
newins - "${tool}.cfg" <<-EOF
|
||||
# This configuration file is used by ${tool} driver.
|
||||
@gentoo-common.cfg
|
||||
EOF
|
||||
done
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user