commit:     ee6c164f40e7dbf3ce58c13fc16975b94844c0a4
Author:     Michal Rostecki <vadorovsky <AT> protonmail <DOT> com>
AuthorDate: Mon Aug  4 08:07:17 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Sep  2 13:59:07 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ee6c164f

llvm-runtimes/compiler-rt-sanitizers: Use the partial clang cofiguration files

Initial installation or upgrade of compiler-rt-sanitizers happens before
the main slotted clang configuration file is created by
llvm-core/clang-runtime. Building compiler-rt-sanitizers requires
only the linker (`-fuse-ld`), rtlib (`--rtlib`) and C++ standard library
(`--stdlib`) configuration to be present. To fix the initial builds, we
can use the partial configuration provided by:

* llvm-core/clang-linker-config
* llvm-runtimes/clang-rtlib-config
+ llvm-runtimes/clang-stdlib-config

Signed-off-by: Michal Rostecki <vadorovsky <AT> protonmail.com>
Closes: https://bugs.gentoo.org/951445
Part-of: https://github.com/gentoo/gentoo/pull/42663
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Part-of: https://github.com/gentoo/gentoo/pull/42663
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 ...ild => compiler-rt-sanitizers-20.1.8-r1.ebuild} | 37 +++++++++++++++-------
 ...ild => compiler-rt-sanitizers-21.1.0-r1.ebuild} | 25 +++++++++++----
 .../compiler-rt-sanitizers-22.0.0.9999.ebuild      | 17 ++++++++--
 ...ompiler-rt-sanitizers-22.0.0_pre20250831.ebuild | 17 ++++++++--
 4 files changed, 74 insertions(+), 22 deletions(-)

diff --git 
a/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
 b/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-20.1.8-r1.ebuild
similarity index 83%
copy from 
llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
copy to 
llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-20.1.8-r1.ebuild
index 333dd678b31e..e168e5638ab9 100644
--- 
a/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
+++ 
b/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-20.1.8-r1.ebuild
@@ -11,7 +11,8 @@ HOMEPAGE="https://llvm.org/";
 
 LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
 SLOT="${LLVM_MAJOR}"
-IUSE="+abi_x86_32 abi_x86_64 +clang +debug test"
+KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc64 ~riscv ~x86 ~amd64-linux 
~ppc-macos ~x64-macos"
+IUSE="+abi_x86_32 abi_x86_64 +clang debug test"
 # base targets
 IUSE+=" +ctx-profile +libfuzzer +memprof +orc +profile +xray"
 # sanitizer targets, keep in sync with config-ix.cmake
@@ -40,6 +41,9 @@ DEPEND="
 BDEPEND="
        clang? (
                llvm-core/clang:${LLVM_MAJOR}
+               llvm-core/clang-linker-config:${LLVM_MAJOR}
+               llvm-runtimes/clang-rtlib-config:${LLVM_MAJOR}
+               llvm-runtimes/clang-stdlib-config:${LLVM_MAJOR}
                llvm-runtimes/compiler-rt:${LLVM_MAJOR}
        )
        elibc_glibc? ( net-libs/libtirpc )
@@ -56,6 +60,7 @@ LLVM_COMPONENTS=( compiler-rt cmake llvm/cmake )
 LLVM_TEST_COMPONENTS=(
        llvm/include/llvm/ProfileData llvm/lib/Testing/Support third-party
 )
+LLVM_PATCHSET=${PV}
 llvm.org_set_globals
 
 python_check_deps() {
@@ -82,9 +87,6 @@ pkg_setup() {
 src_prepare() {
        sed -i -e 's:-Werror::' lib/tsan/go/buildgo.sh || die
 
-       # builds freestanding code
-       filter-flags -fstack-protector*
-
        local flag
        for flag in "${SANITIZER_FLAGS[@]}"; do
                if ! use "${flag}"; then
@@ -101,6 +103,8 @@ src_prepare() {
        if use ubsan && ! use cfi; then
                > test/cfi/CMakeLists.txt || die
        fi
+       # hangs, sigh
+       rm test/tsan/getline_nohang.cpp || die
 
        llvm.org_src_prepare
 }
@@ -115,9 +119,19 @@ src_configure() {
        BUILD_DIR=${WORKDIR}/compiler-rt_build
 
        if use clang; then
-               local -x CC=${CHOST}-clang
-               local -x CXX=${CHOST}-clang++
+               local -x CC=${CHOST}-clang-${LLVM_MAJOR}
+               local -x CXX=${CHOST}-clang++-${LLVM_MAJOR}
                strip-unsupported-flags
+
+               # The full clang configuration might not be ready yet. Use the 
partial
+               # configuration files that are guaranteed to exist even during 
initial
+               # installations and upgrades.
+               local flags=(
+                       
--config="${ESYSROOT}"/etc/clang/"${LLVM_MAJOR}"/gentoo-{rtlib,stdlib,linker}.cfg
+               )
+               local -x CFLAGS="${CFLAGS} ${flags[@]}"
+               local -x CXXFLAGS="${CXXFLAGS} ${flags[@]}"
+               local -x LDFLAGS="${LDFLAGS} ${flags[@]}"
        fi
 
        local flag want_sanitizer=OFF
@@ -190,11 +204,9 @@ src_configure() {
        cmake_src_configure
 
        if use test; then
-               local sys_dest=( "${BUILD_DIR}"/lib/clang/${LLVM_MAJOR}/lib/* )
-               [[ ! -e ${sys_dest} ]] && die "Unable to find ${sys_dest}"
-               [[ ${#sys_dest[@]} -ne 1 ]] && die "Non-deterministic 
compiler-rt install: ${sys_dest[*]}"
-               local sys_dir=( 
"${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}/lib/${sys_dest##*/}" )
-               [[ ! -e ${sys_dir} ]] && die "${sys_dir} is missing"
+               local sys_dir=( "${EPREFIX}"/usr/lib/clang/${LLVM_MAJOR}/lib/* )
+               [[ -e ${sys_dir} ]] || die "Unable to find ${sys_dir}"
+               [[ ${#sys_dir[@]} -eq 1 ]] || die "Non-deterministic 
compiler-rt install: ${sys_dir[*]}"
 
                # copy clang over since resource_dir is located relatively to 
binary
                # therefore, we can put our new libraries in it
@@ -203,7 +215,8 @@ src_configure() {
                        "${BUILD_DIR}"/lib/llvm/${LLVM_MAJOR}/bin/ || die
                cp "${EPREFIX}"/usr/lib/clang/${LLVM_MAJOR}/include/*.h \
                        "${BUILD_DIR}"/lib/clang/${LLVM_MAJOR}/include/ || die
-               cp "${sys_dir}"/*builtins*.a "${sys_dest}/" || die
+               cp "${sys_dir}"/*builtins*.a \
+                       
"${BUILD_DIR}/lib/clang/${LLVM_MAJOR}/lib/${sys_dir##*/}/" || die
                # we also need LLVMgold.so for gold-based tests
                if [[ -f 
${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/$(get_libdir)/LLVMgold.so ]]; then
                        ln -s 
"${EPREFIX}"/usr/lib/llvm/${LLVM_MAJOR}/$(get_libdir)/LLVMgold.so \

diff --git 
a/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
 b/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-21.1.0-r1.ebuild
similarity index 88%
copy from 
llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
copy to 
llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-21.1.0-r1.ebuild
index 333dd678b31e..bfe432ebdae7 100644
--- 
a/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
+++ 
b/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-21.1.0-r1.ebuild
@@ -11,7 +11,8 @@ HOMEPAGE="https://llvm.org/";
 
 LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
 SLOT="${LLVM_MAJOR}"
-IUSE="+abi_x86_32 abi_x86_64 +clang +debug test"
+KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc64 ~riscv ~x86 ~amd64-linux 
~ppc-macos ~x64-macos"
+IUSE="+abi_x86_32 abi_x86_64 +clang debug test"
 # base targets
 IUSE+=" +ctx-profile +libfuzzer +memprof +orc +profile +xray"
 # sanitizer targets, keep in sync with config-ix.cmake
@@ -40,6 +41,9 @@ DEPEND="
 BDEPEND="
        clang? (
                llvm-core/clang:${LLVM_MAJOR}
+               llvm-core/clang-linker-config:${LLVM_MAJOR}
+               llvm-runtimes/clang-rtlib-config:${LLVM_MAJOR}
+               llvm-runtimes/clang-stdlib-config:${LLVM_MAJOR}
                llvm-runtimes/compiler-rt:${LLVM_MAJOR}
        )
        elibc_glibc? ( net-libs/libtirpc )
@@ -82,9 +86,6 @@ pkg_setup() {
 src_prepare() {
        sed -i -e 's:-Werror::' lib/tsan/go/buildgo.sh || die
 
-       # builds freestanding code
-       filter-flags -fstack-protector*
-
        local flag
        for flag in "${SANITIZER_FLAGS[@]}"; do
                if ! use "${flag}"; then
@@ -101,6 +102,8 @@ src_prepare() {
        if use ubsan && ! use cfi; then
                > test/cfi/CMakeLists.txt || die
        fi
+       # hangs, sigh
+       rm test/tsan/getline_nohang.cpp || die
 
        llvm.org_src_prepare
 }
@@ -115,9 +118,19 @@ src_configure() {
        BUILD_DIR=${WORKDIR}/compiler-rt_build
 
        if use clang; then
-               local -x CC=${CHOST}-clang
-               local -x CXX=${CHOST}-clang++
+               local -x CC=${CHOST}-clang-${LLVM_MAJOR}
+               local -x CXX=${CHOST}-clang++-${LLVM_MAJOR}
                strip-unsupported-flags
+
+               # The full clang configuration might not be ready yet. Use the 
partial
+               # configuration files that are guaranteed to exist even during 
initial
+               # installations and upgrades.
+               local flags=(
+                       
--config="${ESYSROOT}"/etc/clang/"${LLVM_MAJOR}"/gentoo-{rtlib,stdlib,linker}.cfg
+               )
+               local -x CFLAGS="${CFLAGS} ${flags[@]}"
+               local -x CXXFLAGS="${CXXFLAGS} ${flags[@]}"
+               local -x LDFLAGS="${LDFLAGS} ${flags[@]}"
        fi
 
        local flag want_sanitizer=OFF

diff --git 
a/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
 
b/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
index 333dd678b31e..fa3b0d22fd43 100644
--- 
a/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
+++ 
b/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0.9999.ebuild
@@ -40,6 +40,9 @@ DEPEND="
 BDEPEND="
        clang? (
                llvm-core/clang:${LLVM_MAJOR}
+               llvm-core/clang-linker-config:${LLVM_MAJOR}
+               llvm-runtimes/clang-rtlib-config:${LLVM_MAJOR}
+               llvm-runtimes/clang-stdlib-config:${LLVM_MAJOR}
                llvm-runtimes/compiler-rt:${LLVM_MAJOR}
        )
        elibc_glibc? ( net-libs/libtirpc )
@@ -115,9 +118,19 @@ src_configure() {
        BUILD_DIR=${WORKDIR}/compiler-rt_build
 
        if use clang; then
-               local -x CC=${CHOST}-clang
-               local -x CXX=${CHOST}-clang++
+               local -x CC=${CHOST}-clang-${LLVM_MAJOR}
+               local -x CXX=${CHOST}-clang++-${LLVM_MAJOR}
                strip-unsupported-flags
+
+               # The full clang configuration might not be ready yet. Use the 
partial
+               # configuration files that are guaranteed to exist even during 
initial
+               # installations and upgrades.
+               local flags=(
+                       
--config="${ESYSROOT}"/etc/clang/"${LLVM_MAJOR}"/gentoo-{rtlib,stdlib,linker}.cfg
+               )
+               local -x CFLAGS="${CFLAGS} ${flags[@]}"
+               local -x CXXFLAGS="${CXXFLAGS} ${flags[@]}"
+               local -x LDFLAGS="${LDFLAGS} ${flags[@]}"
        fi
 
        local flag want_sanitizer=OFF

diff --git 
a/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0_pre20250831.ebuild
 
b/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0_pre20250831.ebuild
index 333dd678b31e..fa3b0d22fd43 100644
--- 
a/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0_pre20250831.ebuild
+++ 
b/llvm-runtimes/compiler-rt-sanitizers/compiler-rt-sanitizers-22.0.0_pre20250831.ebuild
@@ -40,6 +40,9 @@ DEPEND="
 BDEPEND="
        clang? (
                llvm-core/clang:${LLVM_MAJOR}
+               llvm-core/clang-linker-config:${LLVM_MAJOR}
+               llvm-runtimes/clang-rtlib-config:${LLVM_MAJOR}
+               llvm-runtimes/clang-stdlib-config:${LLVM_MAJOR}
                llvm-runtimes/compiler-rt:${LLVM_MAJOR}
        )
        elibc_glibc? ( net-libs/libtirpc )
@@ -115,9 +118,19 @@ src_configure() {
        BUILD_DIR=${WORKDIR}/compiler-rt_build
 
        if use clang; then
-               local -x CC=${CHOST}-clang
-               local -x CXX=${CHOST}-clang++
+               local -x CC=${CHOST}-clang-${LLVM_MAJOR}
+               local -x CXX=${CHOST}-clang++-${LLVM_MAJOR}
                strip-unsupported-flags
+
+               # The full clang configuration might not be ready yet. Use the 
partial
+               # configuration files that are guaranteed to exist even during 
initial
+               # installations and upgrades.
+               local flags=(
+                       
--config="${ESYSROOT}"/etc/clang/"${LLVM_MAJOR}"/gentoo-{rtlib,stdlib,linker}.cfg
+               )
+               local -x CFLAGS="${CFLAGS} ${flags[@]}"
+               local -x CXXFLAGS="${CXXFLAGS} ${flags[@]}"
+               local -x LDFLAGS="${LDFLAGS} ${flags[@]}"
        fi
 
        local flag want_sanitizer=OFF

Reply via email to