commit:     222a016638e0f63dac0bb2724cb9594abaaf0731
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 30 16:43:13 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 13:28:52 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=222a0166

sys-libs/glibc: Simplify and fix kernel header location logic

ALT_HEADERS dates back to 2004 [1] and ALT_BUILD_HEADERS back to 2007
[2], both before crossdev was born. ALT_BUILD_HEADERS was added to
crossdev in 2016 but then removed again in 2017. None of this seems
necessary anymore.

It's unclear exactly which scenario the linux/version.h logic was for, but this
also appears obsolete now. It was referred to as a "fallback case" at the time
it was added.

Now that we have ESYSROOT, we can simply rely on that instead. Tested with a
prefixed "Canadian Cross".

[1] 
https://gitweb.gentoo.org/archive/repo/gentoo-2.git/commit/?id=5d0403b9db95bfe58e9196c31997eedc97869881
[2] 
https://gitweb.gentoo.org/archive/repo/gentoo-2.git/commit/?id=b127166cfbce8930aac4ed893df23c3e28b24737

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

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

diff --git a/sys-libs/glibc/glibc-2.40-r7.ebuild 
b/sys-libs/glibc/glibc-2.40-r7.ebuild
index c24d663d40e0..66f7383c954d 100644
--- a/sys-libs/glibc/glibc-2.40-r7.ebuild
+++ b/sys-libs/glibc/glibc-2.40-r7.ebuild
@@ -248,29 +248,9 @@ build_eprefix() {
        is_crosscompile && echo "${EPREFIX}"
 }
 
-# We need to be able to set alternative headers for compiling for non-native
-# platform. Will also become useful for testing kernel-headers without screwing
-# up the whole system.
 alt_headers() {
-       echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
+       echo $(alt_prefix)/usr/include
 }
-
-alt_build_headers() {
-       if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
-               ALT_BUILD_HEADERS="$(host_eprefix)$(alt_headers)"
-               if tc-is-cross-compiler ; then
-                       ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
-                       if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; 
then
-                               local header_path=$(echo '#include 
<linux/version.h>' \
-                                       | $(tc-getCPP ${CTARGET}) ${CFLAGS} 
2>&1 \
-                                       | grep -o '[^"]*linux/version.h')
-                               
ALT_BUILD_HEADERS=${header_path%/linux/version.h}
-                       fi
-               fi
-       fi
-       echo "${ALT_BUILD_HEADERS}"
-}
-
 alt_libdir() {
        echo $(alt_prefix)/$(get_libdir)
 }
@@ -792,7 +772,7 @@ eend_KV() {
 
 get_kheader_version() {
        printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
-       $(tc-getCPP ${CTARGET}) -I "$(build_eprefix)$(alt_build_headers)" - | \
+       $(tc-getCPP ${CTARGET}) -I "${ESYSROOT}$(alt_headers)" - | \
        tail -n 1
 }
 
@@ -1065,7 +1045,7 @@ glibc_do_configure() {
                --host=${CTARGET_OPT:-${CTARGET}}
                $(use_enable profile)
                $(use_with gd)
-               --with-headers=$(build_eprefix)$(alt_build_headers)
+               --with-headers="${ESYSROOT}$(alt_headers)"
                --prefix="$(host_eprefix)/usr"
                --sysconfdir="$(host_eprefix)/etc"
                --localstatedir="$(host_eprefix)/var"
@@ -1228,7 +1208,7 @@ glibc_headers_configure() {
                --enable-bind-now
                --build=${CBUILD_OPT:-${CBUILD}}
                --host=${CTARGET_OPT:-${CTARGET}}
-               --with-headers=$(build_eprefix)$(alt_build_headers)
+               --with-headers="${ESYSROOT}$(alt_headers)"
                --prefix="$(host_eprefix)/usr"
                ${EXTRA_ECONF}
        )

diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild
index 68c5b9325049..39f4cd3f2872 100644
--- a/sys-libs/glibc/glibc-9999.ebuild
+++ b/sys-libs/glibc/glibc-9999.ebuild
@@ -250,29 +250,9 @@ build_eprefix() {
        is_crosscompile && echo "${EPREFIX}"
 }
 
-# We need to be able to set alternative headers for compiling for non-native
-# platform. Will also become useful for testing kernel-headers without screwing
-# up the whole system.
 alt_headers() {
-       echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
+       echo $(alt_prefix)/usr/include
 }
-
-alt_build_headers() {
-       if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
-               ALT_BUILD_HEADERS="$(host_eprefix)$(alt_headers)"
-               if tc-is-cross-compiler ; then
-                       ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
-                       if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; 
then
-                               local header_path=$(echo '#include 
<linux/version.h>' \
-                                       | $(tc-getCPP ${CTARGET}) ${CFLAGS} 
2>&1 \
-                                       | grep -o '[^"]*linux/version.h')
-                               
ALT_BUILD_HEADERS=${header_path%/linux/version.h}
-                       fi
-               fi
-       fi
-       echo "${ALT_BUILD_HEADERS}"
-}
-
 alt_libdir() {
        echo $(alt_prefix)/$(get_libdir)
 }
@@ -798,7 +778,7 @@ eend_KV() {
 
 get_kheader_version() {
        printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
-       $(tc-getCPP ${CTARGET}) -I "$(build_eprefix)$(alt_build_headers)" - | \
+       $(tc-getCPP ${CTARGET}) -I "${ESYSROOT}$(alt_headers)" - | \
        tail -n 1
 }
 
@@ -1077,7 +1057,7 @@ glibc_do_configure() {
                --host=${CTARGET_OPT:-${CTARGET}}
                $(use_enable profile)
                $(use_with gd)
-               --with-headers=$(build_eprefix)$(alt_build_headers)
+               --with-headers="${ESYSROOT}$(alt_headers)"
                --prefix="$(host_eprefix)/usr"
                --sysconfdir="$(host_eprefix)/etc"
                --localstatedir="$(host_eprefix)/var"
@@ -1240,7 +1220,7 @@ glibc_headers_configure() {
                --enable-bind-now
                --build=${CBUILD_OPT:-${CBUILD}}
                --host=${CTARGET_OPT:-${CTARGET}}
-               --with-headers=$(build_eprefix)$(alt_build_headers)
+               --with-headers="${ESYSROOT}$(alt_headers)"
                --prefix="$(host_eprefix)/usr"
                ${EXTRA_ECONF}
        )

Reply via email to