eclass/toolchain: Sync with Gentoo

It's from Gentoo commit bbb6ddebd2df8deb3d6f269663f04ee6720a1811.
This commit is contained in:
Flatcar Buildbot 2023-03-27 07:23:35 +00:00
parent b7fe8d3d35
commit 3028ca52b2

View File

@ -53,9 +53,9 @@ if [[ ${CTARGET} = ${CHOST} ]] ; then
export CTARGET=${CATEGORY#cross-} export CTARGET=${CATEGORY#cross-}
fi fi
fi fi
: ${TARGET_ABI:=${ABI}} : "${TARGET_ABI:=${ABI}}"
: ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}} : "${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}"
: ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}} : "${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}"
is_crosscompile() { is_crosscompile() {
[[ ${CHOST} != ${CTARGET} ]] [[ ${CHOST} != ${CTARGET} ]]
@ -400,17 +400,17 @@ PDEPEND=">=sys-devel/gcc-config-2.3"
# Used to override compression used for for patchsets. # Used to override compression used for for patchsets.
# Default is xz for EAPI 8+ and bz2 for older EAPIs. # Default is xz for EAPI 8+ and bz2 for older EAPIs.
if [[ ${EAPI} == 8 ]] ; then if [[ ${EAPI} == 8 ]] ; then
: ${TOOLCHAIN_PATCH_SUFFIX:=xz} : "${TOOLCHAIN_PATCH_SUFFIX:=xz}"
else else
# Older EAPIs # Older EAPIs
: ${TOOLCHAIN_PATCH_SUFFIX:=bz2} : "${TOOLCHAIN_PATCH_SUFFIX:=bz2}"
fi fi
# @ECLASS_VARIABLE: TOOLCHAIN_SET_S # @ECLASS_VARIABLE: TOOLCHAIN_SET_S
# @DESCRIPTION: # @DESCRIPTION:
# Used to override value of S for snapshots and such. Mainly useful # Used to override value of S for snapshots and such. Mainly useful
# if needing to set GCC_TARBALL_SRC_URI. # if needing to set GCC_TARBALL_SRC_URI.
: ${TOOLCHAIN_SET_S:=yes} : "${TOOLCHAIN_SET_S:=yes}"
# Set the source directory depending on whether we're using # Set the source directory depending on whether we're using
# a live git tree, snapshot, or release tarball. # a live git tree, snapshot, or release tarball.
@ -537,12 +537,18 @@ get_gcc_src_uri() {
# Pull gcc tarball from another location. Frequently used by gnat-gpl. # Pull gcc tarball from another location. Frequently used by gnat-gpl.
GCC_SRC_URI="${GCC_TARBALL_SRC_URI}" GCC_SRC_URI="${GCC_TARBALL_SRC_URI}"
elif [[ -n ${SNAPSHOT} ]] ; then elif [[ -n ${SNAPSHOT} ]] ; then
GCC_SRC_URI="https://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz" GCC_SRC_URI="mirror://gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz"
else else
if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 || tc_version_is_at_least 7.2 ; then if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 || tc_version_is_at_least 7.2 ; then
GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz" GCC_SRC_URI="
mirror://gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz
mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz
"
else else
GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2" GCC_SRC_URI="
mirror://gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2
mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2
"
fi fi
fi fi
@ -1090,6 +1096,14 @@ toolchain_src_configure() {
confgcc+=( --enable-libstdcxx-time ) confgcc+=( --enable-libstdcxx-time )
fi fi
# This only controls whether the compiler *supports* LTO, not whether
# it's *built using* LTO. Hence we do it without a USE flag.
if tc_version_is_at_least 4.6 ; then
confgcc+=( --enable-lto )
elif tc_version_is_at_least 4.5 ; then
confgcc+=( --disable-lto )
fi
# Build compiler itself using LTO # Build compiler itself using LTO
if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then
build_config_targets+=( bootstrap-lto ) build_config_targets+=( bootstrap-lto )
@ -1164,6 +1178,10 @@ toolchain_src_configure() {
avr) avr)
confgcc+=( --enable-shared --disable-threads ) confgcc+=( --enable-shared --disable-threads )
;; ;;
nvptx*)
# "LTO is not supported for this target"
confgcc+=( --disable-lto )
;;
esac esac
if [[ -n ${needed_libc} ]] ; then if [[ -n ${needed_libc} ]] ; then
@ -1293,7 +1311,7 @@ toolchain_src_configure() {
[[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-} [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
# See if this is a valid --with-arch flag # See if this is a valid --with-arch flag
if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch}; if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
. "${srcdir}"/config.gcc) &>/dev/null . "${srcdir}"/config.gcc) &>/dev/null
then then
confgcc+=( --with-arch=${arm_arch} ) confgcc+=( --with-arch=${arm_arch} )
fi fi
@ -1331,7 +1349,7 @@ toolchain_src_configure() {
;; ;;
amd64) amd64)
# drop the older/ABI checks once this get's merged into some # drop the older/ABI checks once this gets merged into some
# version of gcc upstream # version of gcc upstream
if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) ) confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
@ -1485,14 +1503,6 @@ toolchain_src_configure() {
confgcc+=( $(use_with zstd) ) confgcc+=( $(use_with zstd) )
fi fi
# This only controls whether the compiler *supports* LTO, not whether
# it's *built using* LTO. Hence we do it without a USE flag.
if tc_version_is_at_least 4.6 ; then
confgcc+=( --enable-lto )
elif tc_version_is_at_least 4.5 ; then
confgcc+=( --disable-lto )
fi
# graphite was added in 4.4 but we only support it in 6.5+ due to external # graphite was added in 4.4 but we only support it in 6.5+ due to external
# library issues. bug #448024, bug #701270 # library issues. bug #448024, bug #701270
if tc_version_is_at_least 6.5 && in_iuse graphite ; then if tc_version_is_at_least 6.5 && in_iuse graphite ; then
@ -1954,7 +1964,7 @@ gcc_do_make() {
LIBPATH="${LIBPATH}" \ LIBPATH="${LIBPATH}" \
BOOT_CFLAGS="${BOOT_CFLAGS}" BOOT_CFLAGS="${BOOT_CFLAGS}"
popd > /dev/null || die popd > /dev/null || die
fi fi
einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..." einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
@ -2409,7 +2419,7 @@ create_gcc_env_entry() {
local gcc_envd_file="${ED}${gcc_envd_base}" local gcc_envd_file="${ED}${gcc_envd_base}"
if [[ -z $1 ]] ; then if [[ -z $1 ]] ; then
# I'm leaving the following commented out to remind me that it # I'm leaving the following commented out to remind me that it
# was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset # was an insanely -bad- idea. Stuff broke. GCC_SPECS isn't unset
# on chroot or in non-toolchain.eclass gcc ebuilds! # on chroot or in non-toolchain.eclass gcc ebuilds!
#gcc_specs_file="${LIBPATH}/specs" #gcc_specs_file="${LIBPATH}/specs"
gcc_specs_file="" gcc_specs_file=""
@ -2583,14 +2593,14 @@ do_gcc_config() {
ewarn "The currently selected specs-specific gcc config," ewarn "The currently selected specs-specific gcc config,"
ewarn "${current_specs}, doesn't exist anymore. This is usually" ewarn "${current_specs}, doesn't exist anymore. This is usually"
ewarn "due to enabling/disabling hardened or switching to a version" ewarn "due to enabling/disabling hardened or switching to a version"
ewarn "of gcc that doesnt create multiple specs files. The default" ewarn "of gcc that doesn't create multiple specs files. The default"
ewarn "config will be used, and the previous preference forgotten." ewarn "config will be used, and the previous preference forgotten."
use_specs="" use_specs=""
fi fi
target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}" target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
else else
# The curent target is invalid. Attempt to switch to a valid one. # The current target is invalid. Attempt to switch to a valid one.
# Blindly pick the latest version. bug #529608 # Blindly pick the latest version. bug #529608
# TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
# doing a partial grep like this. # doing a partial grep like this.
@ -2643,7 +2653,7 @@ should_we_gcc_config() {
#---->> support and misc functions <<---- #---->> support and misc functions <<----
# This is to make sure we don't accidentally try to enable support for a # This is to make sure we don't accidentally try to enable support for a
# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc. # language that doesn't exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
# #
# Also add a hook so special ebuilds (kgcc64) can control which languages # Also add a hook so special ebuilds (kgcc64) can control which languages
# exactly get enabled # exactly get enabled