From 569deb0cacaf243d6f56e8c0eb5c2fb1fa1317b0 Mon Sep 17 00:00:00 2001 From: Violet Purcell Date: Sat, 17 Jan 2026 20:10:25 -0500 Subject: [PATCH] llvm-runtimes/libcxx: pass -DCMAKE_CXX_COMPILER_WORKS=1 with no GCC Since libc++ package is merged before llvm-runtimes/clang-stdlib-config during a LLVM version update, clang will attempt to use libstdc++ for the C++ compiler check, and will fail if it is missing. To mitigate this, pass -DCMAKE_CXX_COMPILER_WORKS=1 to cmake to skip the check if GCC is not installed on the system. libc++ still compiles as expected. [sam: Add -b to has_version.] Signed-off-by: Violet Purcell Part-of: https://github.com/gentoo/gentoo/pull/45422 Closes: https://github.com/gentoo/gentoo/pull/45422 Signed-off-by: Sam James --- llvm-runtimes/libcxx/libcxx-20.1.8-r1.ebuild | 6 ++++++ llvm-runtimes/libcxx/libcxx-22.1.0_rc1.ebuild | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/llvm-runtimes/libcxx/libcxx-20.1.8-r1.ebuild b/llvm-runtimes/libcxx/libcxx-20.1.8-r1.ebuild index e0e4478f8d0d2..40f9d39127684 100644 --- a/llvm-runtimes/libcxx/libcxx-20.1.8-r1.ebuild +++ b/llvm-runtimes/libcxx/libcxx-20.1.8-r1.ebuild @@ -145,6 +145,12 @@ multilib_src_configure() { # this is broken with standalone builds, and also meaningless -DLIBCXXABI_USE_LLVM_UNWINDER=OFF ) + if ! has_version -b sys-devel/gcc; then + # Since this package is merged before llvm-runtimes/clang-stdlib-config, + # clang will attempt to use libstdc++ for the C++ compiler check, and will + # fail if it is missing. + mycmakeargs+=( -DCMAKE_CXX_COMPILER_WORKS=1 ) + fi if is_crosspkg; then # Needed to target built libc headers local -x CFLAGS="${CFLAGS} -isystem ${ESYSROOT}/usr/${CTARGET}/usr/include" diff --git a/llvm-runtimes/libcxx/libcxx-22.1.0_rc1.ebuild b/llvm-runtimes/libcxx/libcxx-22.1.0_rc1.ebuild index 7d224001ae1b6..670bccda0c24a 100644 --- a/llvm-runtimes/libcxx/libcxx-22.1.0_rc1.ebuild +++ b/llvm-runtimes/libcxx/libcxx-22.1.0_rc1.ebuild @@ -144,6 +144,12 @@ multilib_src_configure() { # this is broken with standalone builds, and also meaningless -DLIBCXXABI_USE_LLVM_UNWINDER=OFF ) + if ! has_version -b sys-devel/gcc; then + # Since this package is merged before llvm-runtimes/clang-stdlib-config, + # clang will attempt to use libstdc++ for the C++ compiler check, and will + # fail if it is missing. + mycmakeargs+=( -DCMAKE_CXX_COMPILER_WORKS=1 ) + fi if is_crosspkg; then # Needed to target built libc headers local -x CFLAGS="${CFLAGS} -isystem ${ESYSROOT}/usr/${CTARGET}/usr/include"