commit:     95989aaa274f30e42d00828e16fbe5c4c73c9299
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  3 16:58:12 2025 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 21:51:41 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=95989aaa

sys-libs/glibc: Fix cross-compiling glibc when clang is selected

binutils-config returns the wrong binary path for cross-compilers unless you
specify both the CHOST (actually CBUILD in this case) and CTARGET.

Cross-compilers do not have the bare binary names (e.g. gcc) in the binary path
returned by gcc-config, but the tuple-prefixed names are always present.

Tested with a cross build and a native build.

Closes: https://github.com/gentoo/gentoo/pull/39966
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 sys-libs/glibc/glibc-2.40-r7.ebuild | 10 +++++-----
 sys-libs/glibc/glibc-9999.ebuild    | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys-libs/glibc/glibc-2.40-r7.ebuild 
b/sys-libs/glibc/glibc-2.40-r7.ebuild
index 66f7383c954d..e7b5d78134bb 100644
--- a/sys-libs/glibc/glibc-2.40-r7.ebuild
+++ b/sys-libs/glibc/glibc-2.40-r7.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -609,13 +609,13 @@ setup_env() {
                # Last, we need the settings of the *build* environment, not of 
the
                # target environment...
 
-               local current_binutils_path=$(env ROOT="${BROOT}" 
binutils-config -B)
+               local current_binutils_path=$(env CHOST="${CBUILD}" 
ROOT="${BROOT}" binutils-config -B "${CTARGET}")
                local current_gcc_path=$(env ROOT="${BROOT}" gcc-config -B)
                einfo "Overriding clang configuration, since it won't work here"
 
-               export CC="${current_gcc_path}/gcc"
-               export CPP="${current_gcc_path}/cpp"
-               export CXX="${current_gcc_path}/g++"
+               export CC="${current_gcc_path}/${CTARGET}-gcc"
+               export CPP="${current_gcc_path}/${CTARGET}-cpp"
+               export CXX="${current_gcc_path}/${CTARGET}-g++"
                export LD="${current_binutils_path}/ld.bfd"
                export AR="${current_binutils_path}/ar"
                export AS="${current_binutils_path}/as"

diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild
index 39f4cd3f2872..b331be70e2de 100644
--- a/sys-libs/glibc/glibc-9999.ebuild
+++ b/sys-libs/glibc/glibc-9999.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -615,13 +615,13 @@ setup_env() {
                # Last, we need the settings of the *build* environment, not of 
the
                # target environment...
 
-               local current_binutils_path=$(env ROOT="${BROOT}" 
binutils-config -B)
+               local current_binutils_path=$(env CHOST="${CBUILD}" 
ROOT="${BROOT}" binutils-config -B "${CTARGET}")
                local current_gcc_path=$(env ROOT="${BROOT}" gcc-config -B)
                einfo "Overriding clang configuration, since it won't work here"
 
-               export CC="${current_gcc_path}/gcc"
-               export CPP="${current_gcc_path}/cpp"
-               export CXX="${current_gcc_path}/g++"
+               export CC="${current_gcc_path}/${CTARGET}-gcc"
+               export CPP="${current_gcc_path}/${CTARGET}-cpp"
+               export CXX="${current_gcc_path}/${CTARGET}-g++"
                export LD="${current_binutils_path}/ld.bfd"
                export AR="${current_binutils_path}/ar"
                export AS="${current_binutils_path}/as"

Reply via email to