From 69b12371c5e9842d258788412bd90bcb9d0fce26 Mon Sep 17 00:00:00 2001 From: Flatcar Buildbot Date: Mon, 2 Mar 2026 07:27:50 +0000 Subject: [PATCH] eclass/toolchain: Sync with Gentoo It's from Gentoo commit 41d623234817c221bacab5dff211a696d202af8f. Signed-off-by: Flatcar Buildbot --- .../portage-stable/eclass/toolchain.eclass | 72 +++++++++++-------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/toolchain.eclass b/sdk_container/src/third_party/portage-stable/eclass/toolchain.eclass index 0c62e34a5c..d051ef4dc2 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/toolchain.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/toolchain.eclass @@ -900,6 +900,7 @@ setup_multilib_osdirnames() { # @FUNCTION: _get_bootstrap_gcc_info # @USAGE: [gcc_pkg|gcc_bin_base]... +# @INTERNAL # @DESCRIPTION: # Get some information about the gcc that would be used to build this package. # All the variables that are passed as arguments will be set to their apropriate @@ -1416,17 +1417,19 @@ toolchain_src_configure() { confgcc+=( --disable-libstdcxx-pch ) fi - # build-id was disabled for file collisions: bug #526144 - # - # # Turn on the -Wl,--build-id flag by default for ELF targets. bug #525942 - # # This helps with locating debug files. - # case ${CTARGET} in - # *-linux-*|*-elf|*-eabi) - # tc_version_is_at_least 4.5 && confgcc+=( - # --enable-linker-build-id - # ) - # ;; - # esac + # Turn on the -Wl,--build-id flag by default for ELF targets. bug #953869 + # This helps with locating debug files. + case ${CTARGET} in + *-linux-*|*-elf|*-eabi) + tc_version_is_at_least 4.5 && confgcc+=( + --enable-linker-build-id + ) + ;; + esac + + if in_iuse ada ; then + confgcc+=( $(use_enable ada libada) ) + fi ### Cross-compiler option # @@ -1449,11 +1452,15 @@ toolchain_src_configure() { ;; *-elf|*-eabi) needed_libc=newlib - # Bare-metal targets don't have access to clock_gettime() - # arm-none-eabi example: bug #589672 - # But we explicitly do --enable-libstdcxx-time above. - # Undoing it here. - confgcc+=( --disable-libstdcxx-time ) + confgcc+=( + # Bare-metal targets don't have access to clock_gettime() + # arm-none-eabi example: bug #589672 + # But we explicitly do --enable-libstdcxx-time above. + # Undoing it here. + --disable-libstdcxx-time + # bug #970098 + --disable-libada + ) ;; *-gnu*) needed_libc=glibc @@ -1778,10 +1785,6 @@ toolchain_src_configure() { fi fi - if in_iuse ada ; then - confgcc+=( $(use_enable ada libada) ) - fi - if in_iuse cet ; then # Usage: triple_arch triple_env cet_name enable_cet_for() { @@ -1809,7 +1812,7 @@ toolchain_src_configure() { # We patch this in w/ PR66487-object-lifetime-instrumentation-for-Valgrind.patch, # so it may not always be available. if grep -q -- '--enable-valgrind-interop' "${S}"/libgcc/configure.ac ; then - if ! is_crosscompile || $(unset CC; unset CPP; tc-getCPP ${CTARGET#accel-}) -E - <<<"#include " >& /dev/null ; then + if ! is_crosscompile && $(unset CC; unset CPP; tc-getCPP ${CTARGET#accel-}) -E - <<<"#include " >& /dev/null ; then confgcc+=( $(use_enable valgrind valgrind-interop) ) else confgcc+=( --disable-valgrind-interop ) @@ -1846,19 +1849,27 @@ toolchain_src_configure() { fi if in_iuse pie ; then - confgcc+=( $(use_enable pie default-pie) ) + # Workaround for broken configure logic (bug #970413) + if use pie ; then + confgcc+=( --enable-default-pie ) + fi if tc_version_is_at_least 14.1 ${PV} || tc_version_is_at_least 13.4.1_p20250814 ${PV} ; then - confgcc+=( --enable-host-pie ) + # Workaround for broken configure logic (bug #970413) + if use pie ; then + confgcc+=( --enable-host-pie ) + fi fi fi if in_iuse default-znow && { tc_version_is_at_least 14.1 ${PV} || tc_version_is_at_least 13.4.1_p20250814 ${PV} ; } ; then # See https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=33ebb0dff9bb022f1e0709e0e73faabfc3df7931. # TODO: Add to LDFLAGS_FOR_TARGET? - confgcc+=( - $(use_enable default-znow host-bind-now) - ) + # + # Workaround for broken configure logic (bug #970413) + if use default-znow ; then + confgcc+=( --enable-host-bind-now ) + fi fi if in_iuse ssp ; then @@ -2835,9 +2846,14 @@ gcc_movelibs() { # Without this, we end up either unable to find the libgomp spec/archive, or # we underlink and can't find gomp_nvptx_main (presumably because we can't find the plugin) # https://src.fedoraproject.org/rpms/gcc/blob/02c34dfa3627ef05d676d30e152a66e77b58529b/f/gcc.spec#_1445 - if [[ ${CATEGORY} == cross-accel-nvptx* ]] && is_fortran ; then + # + # openmp/fortran check is needed here to know if we're in the stage1 + # build or not. + if [[ ${CATEGORY} == cross-accel-nvptx* ]] && { _tc_use_if_iuse openmp || is_fortran ; } ; then rm -rf "${ED}"/usr/libexec/gcc/nvptx-none/${GCCMAJOR}/install-tools - rm -rf "${ED}"/usr/libexec/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/{install-tools,plugin,cc1,cc1plus,f951} + rm -rf "${ED}"/usr/libexec/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/{install-tools,plugin,cc1,cc1plus} + is_fortran && rm -rf "${ED}"/usr/libexec/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/f951 + rm -rf "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/{install-tools,plugin} rm -rf "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/{install-tools,plugin,include-fixed} mv "${ED}"/usr/nvptx-none/lib/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/