public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/proj/prefix:master commit in: eclass/
Date: Mon,  6 Jun 2022 08:42:13 +0000 (UTC)	[thread overview]
Message-ID: <1654504897.5027081b510a47cbccec3cabd2dc6504b0484821.grobian@gentoo> (raw)

commit:     5027081b510a47cbccec3cabd2dc6504b0484821
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun  6 08:41:37 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun  6 08:41:37 2022 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=5027081b

toolchain.eclass: sync with gx86

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 eclass/toolchain.eclass | 1327 +++++++++++++++++++++++++++--------------------
 1 file changed, 751 insertions(+), 576 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index a07f9b680e..ed8c227c4a 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,23 +1,33 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
-# @SUPPORTED_EAPIS: 5 6 7
+# @ECLASS: toolchain.eclass
+# @MAINTAINER:
+# Toolchain Ninjas <toolchain@gentoo.org>
+# @SUPPORTED_EAPIS: 7 8
+# @BLURB: Common code for sys-devel/gcc ebuilds
+
+case ${EAPI} in
+	7) inherit eutils ;;
+	8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! ${_TOOLCHAIN_ECLASS} ]]; then
+_TOOLCHAIN_ECLASS=1
 
 DESCRIPTION="The GNU Compiler Collection"
 HOMEPAGE="https://gcc.gnu.org/"
 
-# TODO: Please audit this inherit list on future EAPI bumps and ideally
-# conditonalise them where possible.
-inherit eutils flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
+inherit edo flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
 
 tc_is_live() {
 	[[ ${PV} == *9999* ]]
 }
 
 if tc_is_live ; then
-	EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git"
-	# naming style:
+	EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git https://github.com/gcc-mirror/gcc"
+	# Naming style:
 	# gcc-10.1.0_pre9999 -> gcc-10-branch
 	#  Note that the micro version is required or lots of stuff will break.
 	#  To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before
@@ -25,20 +35,12 @@ if tc_is_live ; then
 	EGIT_BRANCH="releases/${PN}-${PV%.?.?_pre9999}"
 	EGIT_BRANCH=${EGIT_BRANCH//./_}
 	inherit git-r3
+elif [[ -n ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
+	inherit git-r3
 fi
 
 FEATURES=${FEATURES/multilib-strict/}
 
-case ${EAPI:-0} in
-	0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
-	5*|6) inherit eapi7-ver ;;
-	7) ;;
-	*) die "I don't speak EAPI ${EAPI}." ;;
-esac
-
-EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
-	src_compile src_test src_install pkg_postinst pkg_postrm
-
 #---->> globals <<----
 
 export CTARGET=${CTARGET:-${CHOST}}
@@ -58,50 +60,116 @@ is_crosscompile() {
 # The target prefix defaults to the host prefix, except for cross compilers, which targets the empty prefix by default.
 : ${TPREFIX:=$(is_crosscompile || echo "${EPREFIX}")}
 
-# General purpose version check.  Without a second arg matches up to minor version (x.x.x)
+# @FUNCTION: tc_version_is_at_least
+# @USAGE: ver1 [ver2]
+# @DESCRIPTION:
+# General purpose version check. Without a second argument, matches
+# up to minor version (x.x.x).
 tc_version_is_at_least() {
 	ver_test "${2:-${GCC_RELEASE_VER}}" -ge "$1"
 }
 
-# General purpose version range check
+# @FUNCTION: tc_version_is_between
+# @USAGE: ver1 ver2
+# @DESCRIPTION:
+# General purpose version range check.
 # Note that it matches up to but NOT including the second version
 tc_version_is_between() {
 	tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}"
 }
 
+# @ECLASS_VARIABLE: TOOLCHAIN_GCC_PV
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Used to override GCC version. Useful for e.g. live ebuilds or snapshots.
+# Defaults to ${PV}.
+
+# @ECLASS_VARIABLE: TOOLCHAIN_USE_GIT_PATCHES
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Used to force fetching patches from git. Useful for non-released versions
+# of GCC where we don't want to keep creating patchset tarballs for a new
+# release series (e.g. suppose 12.0 just got released, then adding snapshots
+# for 13.0, we don't want to create new patchsets for every single 13.0 snapshot,
+# so just grab patches from git each time if this variable is set).
+
+# @ECLASS_VARIABLE: TOOLCHAIN_PATCH_DEV
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Indicate the developer who hosts the patchset for an ebuild.
+
+# @ECLASS_VARIABLE: GCC_PV
+# @INTERNAL
+# @DESCRIPTION:
+# Internal variable representing (spoofed) GCC version.
 GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
+
+# @ECLASS_VARIABLE: GCC_PVR
+# @INTERNAL
+# @DESCRIPTION:
+# Full GCC version including revision.
 GCC_PVR=${GCC_PV}
 [[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
 
+# @ECLASS_VARIABLE: GCC_RELEASE_VER
+# @INTERNAL
+# @DESCRIPTION:
 # GCC_RELEASE_VER must always match 'gcc/BASE-VER' value.
 # It's an internal representation of gcc version used for:
 # - versioned paths on disk
 # - 'gcc -dumpversion' output. Must always match <digit>.<digit>.<digit>.
 GCC_RELEASE_VER=$(ver_cut 1-3 ${GCC_PV})
 
+# @ECLASS_VARIABLE: GCC_BRANCH_VER
+# @INTERNAL
+# @DESCRIPTION:
+# GCC branch version.
 GCC_BRANCH_VER=$(ver_cut 1-2 ${GCC_PV})
+# @ECLASS_VARIABLE: GCCMAJOR
+# @INTERNAL
+# @DESCRIPTION:
+# Major GCC version.
 GCCMAJOR=$(ver_cut 1 ${GCC_PV})
+# @ECLASS_VARIABLE: GCCMINOR
+# @INTERNAL
+# @DESCRIPTION:
+# Minor GCC version.
 GCCMINOR=$(ver_cut 2 ${GCC_PV})
+# @ECLASS_VARIABLE: GCCMICRO
+# @INTERNAL
+# @DESCRIPTION:
+# GCC micro version.
 GCCMICRO=$(ver_cut 3 ${GCC_PV})
 
+# @ECLASS_VARIABLE: GCC_CONFIG_VER
+# @INTERNAL
+# @DESCRIPTION:
 # Ideally this variable should allow for custom gentoo versioning
 # of binary and gcc-config names not directly tied to upstream
-# versioning. In practive it's hard to untangle from gcc/BASE-VER
+# versioning. In practice it's hard to untangle from gcc/BASE-VER
 # (GCC_RELEASE_VER) value.
 GCC_CONFIG_VER=${GCC_RELEASE_VER}
 
 # Pre-release support. Versioning schema:
 # 1.0.0_pre9999: live ebuild
-# 1.2.3_alphaYYYYMMDD: weekly snapshots
+# 1.2.3_pYYYYMMDD (or 1.2.3_preYYYYMMDD for unreleased major versions): weekly snapshots
 # 1.2.3_rcYYYYMMDD: release candidates
-if [[ ${GCC_PV} == *_alpha* ]] ; then
-	# weekly snapshots
-	SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_alpha}
+if [[ ${GCC_PV} == *_pre* ]] ; then
+	# Weekly snapshots
+	SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_pre}
+elif [[ ${GCC_PV} == *_p* ]] ; then
+	# Weekly snapshots
+	SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_p}
 elif [[ ${GCC_PV} == *_rc* ]] ; then
-	# release candidates
+	# Release candidates
 	SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
 fi
 
+# Require minimum gcc version to simplify assumptions.
+# Normally we would require gcc-6+ (based on sys-devel/gcc)
+# but we still have sys-devel/gcc-apple-4.2.1_p5666.
+tc_version_is_at_least 4.2.1 || die "${ECLASS}: ${GCC_RELEASE_VER} is too old."
+
 PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
 
 LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
@@ -116,7 +184,7 @@ fi
 
 DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
 
-# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
+# Don't install in /usr/include/g++-v3/, but instead to gcc's internal directory.
 # We will handle /usr/include/g++-v3/ with gcc-config ...
 STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
 
@@ -126,46 +194,33 @@ LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-excepti
 IUSE="test vanilla +nls"
 RESTRICT="!test? ( test )"
 
-tc_supports_dostrip() {
-	case ${EAPI:-0} in
-		5*|6) return 1 ;;
-		7) return 0 ;;
-		*) die "Update apply_patches() for ${EAPI}." ;;
-	esac
-}
-
-tc_supports_dostrip || RESTRICT+=" strip" # cross-compilers need controlled stripping
-
 TC_FEATURES=()
 
 tc_has_feature() {
 	has "$1" "${TC_FEATURES[@]}"
 }
 
-if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
-	# --enable-altivec was dropped before gcc-4. We don't set it.
-	# We drop USE=altivec for newer gccs only to avoid rebuilds
-	# for most stable users. Once gcc-10 is stable we can drop it.
-	if ! tc_version_is_at_least 10; then
-		IUSE+=" altivec"
-	fi
-	IUSE+=" debug +cxx +nptl" TC_FEATURES+=(nptl)
+# Prefix: allow gcc-apple post 4.2.1
+if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ||
+	[[ ${PN} == "gcc-apple" && tc_version_is_at_least 12.1 ]] ; then
+	IUSE+=" debug +cxx +nptl" TC_FEATURES+=( nptl )
 	[[ -n ${PIE_VER} ]] && IUSE+=" nopie"
 	[[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
-	# fortran support appeared in 4.1, but 4.1 needs outdated mpfr
-	tc_version_is_at_least 4.2 && IUSE+=" +fortran" TC_FEATURES+=(fortran)
-	tc_version_is_at_least 3 && IUSE+=" doc hardened multilib objc"
-	tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=(gcj)
-	tc_version_is_at_least 3.3 && IUSE+=" pgo"
-	tc_version_is_at_least 4.0 &&
-		IUSE+=" objc-gc" TC_FEATURES+=(objc-gc)
-	tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
-	tc_version_is_at_least 4.2 && IUSE+=" +openmp"
+	IUSE+=" +fortran" TC_FEATURES+=( fortran )
+	IUSE+=" doc hardened multilib objc"
+	tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=( gcj )
+	IUSE+=" pgo"
+	IUSE+=" objc-gc" TC_FEATURES+=( objc-gc )
+	IUSE+=" libssp objc++"
+	IUSE+=" +openmp"
+
 	tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
 	tc_version_is_at_least 4.7 && IUSE+=" go"
+
 	# sanitizer support appeared in gcc-4.8, but <gcc-5 does not
 	# support modern glibc.
-	tc_version_is_at_least 5 && IUSE+=" +sanitize"
+	tc_version_is_at_least 5 && IUSE+=" +sanitize"  TC_FEATURES+=( sanitize )
+
 	# Note:
 	#   <gcc-4.8 supported graphite, it required forked ppl
 	#     versions which we dropped.  Since graphite was also experimental in
@@ -173,28 +228,24 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
 	#   <gcc-5 supported graphite, it required cloog
 	#   <gcc-6.5 supported graphite, it required old incompatible isl
 	tc_version_is_at_least 6.5 &&
-		IUSE+=" graphite" TC_FEATURES+=(graphite)
+		IUSE+=" graphite" TC_FEATURES+=( graphite )
+
 	tc_version_is_between 4.9 8 && IUSE+=" cilk"
 	tc_version_is_at_least 4.9 && IUSE+=" ada"
-
-	# Don't enable USE=vtv starting from gcc-10. Once gcc-10
-	# stable everywhere disable by default on older versions
-	# as well.
-	if tc_version_is_at_least 10; then
-		IUSE+=" vtv"
-	elif tc_version_is_at_least 4.9; then
-		IUSE+=" +vtv"
-	fi
+	tc_version_is_at_least 4.9 && IUSE+=" vtv"
 	tc_version_is_at_least 5.0 && IUSE+=" jit"
 	tc_version_is_between 5.0 9 && IUSE+=" mpx"
 	tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
+
 	# systemtap is a gentoo-specific switch: bug #654748
 	tc_version_is_at_least 8.0 &&
-		IUSE+=" systemtap" TC_FEATURES+=(systemtap)
+		IUSE+=" systemtap" TC_FEATURES+=( systemtap )
+
 	tc_version_is_at_least 9.0 && IUSE+=" d"
 	tc_version_is_at_least 9.1 && IUSE+=" lto"
-	tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=(zstd)
-	tc_version_is_at_least 11 && IUSE+=" valgrind" TC_FEATURES+=(valgrind)
+	tc_version_is_at_least 10 && IUSE+=" cet"
+	tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=( zstd )
+	tc_version_is_at_least 11 && IUSE+=" valgrind" TC_FEATURES+=( valgrind )
 	tc_version_is_at_least 11 && IUSE+=" custom-cflags"
 fi
 
@@ -209,17 +260,15 @@ fi
 #---->> DEPEND <<----
 
 RDEPEND="sys-libs/zlib
-	nls? ( virtual/libintl )"
-
-tc_version_is_at_least 3 && RDEPEND+=" virtual/libiconv"
-
-if tc_version_is_at_least 4 ; then
-	GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0= >=dev-libs/mpfr-2.4.2:0="
-	if tc_version_is_at_least 4.3 ; then
-		RDEPEND+=" ${GMP_MPFR_DEPS}"
-	elif tc_has_feature fortran ; then
-		RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
-	fi
+	virtual/libiconv
+	nls? ( virtual/libintl )
+"
+
+GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0= >=dev-libs/mpfr-2.4.2:0="
+if tc_version_is_at_least 4.3 ; then
+	RDEPEND+=" ${GMP_MPFR_DEPS}"
+elif tc_has_feature fortran ; then
+	RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
 fi
 
 tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
@@ -245,24 +294,28 @@ BDEPEND="
 DEPEND="${RDEPEND}"
 
 if tc_has_feature gcj ; then
-	GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
-	GCJ_GTK_DEPS="
-		x11-base/xorg-proto
-		x11-libs/libXt
-		x11-libs/libX11
-		x11-libs/libXtst
-		=x11-libs/gtk+-2*
-		virtual/pkgconfig
+	DEPEND+="
+		gcj? (
+			app-arch/zip
+			app-arch/unzip
+			>=media-libs/libart_lgpl-2.1
+			awt? (
+				x11-base/xorg-proto
+				x11-libs/libXt
+				x11-libs/libX11
+				x11-libs/libXtst
+				=x11-libs/gtk+-2*
+				x11-libs/pango
+				virtual/pkgconfig
+			)
+		)
 	"
-	tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
-	tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
-	DEPEND+=" gcj? ( awt? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
 fi
 
 if tc_has_feature sanitize ; then
 	# libsanitizer relies on 'crypt.h' to be present
-	# on target. glibc used to provide it unconditionally.
-	# Nowadays it's a standalone library: #802648
+	# on target. glibc user to provide it unconditionally.
+	# Nowadays it's a standalone library: bug #802648
 	DEPEND+=" sanitize? ( virtual/libcrypt )"
 fi
 
@@ -272,40 +325,86 @@ if tc_has_feature systemtap ; then
 fi
 
 if tc_has_feature zstd ; then
-	DEPEND+=" zstd? ( app-arch/zstd )"
+	DEPEND+=" zstd? ( app-arch/zstd:= )"
+	RDEPEND+=" zstd? ( app-arch/zstd:= )"
 fi
 
 if tc_has_feature valgrind; then
 	BDEPEND+=" valgrind? ( dev-util/valgrind )"
 fi
 
-case ${EAPI:-0} in
-	5*|6) DEPEND+=" ${BDEPEND}" ;;
-esac
-
 # Prefix: our version is 1.9, so can't go with gx86's 2.3
-PDEPEND=">=sys-devel/gcc-config-1.7"
+PDEPEND=">=sys-devel/gcc-config-1.9"
 
 #---->> S + SRC_URI essentials <<----
 
+# @ECLASS_VARIABLE: TOOLCHAIN_PATCH_SUFFIX
+# @DESCRIPTION:
+# Used to override compression used for for patchsets.
+# Default is xz for EAPI 8+ and bz2 for older EAPIs.
+if [[ ${EAPI} == 8 ]] ; then
+	: ${TOOLCHAIN_PATCH_SUFFIX:=xz}
+else
+	# Older EAPIs
+	: ${TOOLCHAIN_PATCH_SUFFIX:=bz2}
+fi
+
+# @ECLASS_VARIABLE: TOOLCHAIN_SET_S
+# @DESCRIPTION:
+# Used to override value of S for snapshots and such. Mainly useful
+# if needing to set GCC_TARBALL_SRC_URI.
+: ${TOOLCHAIN_SET_S:=yes}
+
 # Set the source directory depending on whether we're using
 # a live git tree, snapshot, or release tarball.
-S=$(
-	if tc_is_live ; then
-		echo ${EGIT_CHECKOUT_DIR}
-	elif [[ -n ${SNAPSHOT} ]] ; then
-		echo ${WORKDIR}/gcc-${SNAPSHOT}
-	else
-		echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
-	fi
-)
+if [[ ${TOOLCHAIN_SET_S} == yes ]] ; then
+	S=$(
+		if tc_is_live ; then
+			echo ${EGIT_CHECKOUT_DIR}
+		elif [[ -n ${SNAPSHOT} ]] ; then
+			echo ${WORKDIR}/gcc-${SNAPSHOT}
+		else
+			echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
+		fi
+	)
+fi
 
 gentoo_urls() {
-	local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
-	HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI
-	HTTP~tamiko/distfiles/URI HTTP~sam/distfiles/URI HTTP~slyfox/distfiles/URI"
+	# slyfox's distfiles are mirrored to sam's devspace
+	declare -A devspace_urls=(
+		[soap]=HTTP~soap/distfiles/URI
+		[sam]=HTTP~sam/distfiles/sys-devel/gcc/URI
+		[slyfox]=HTTP~sam/distfiles/URI
+		[tamiko]=HTTP~tamiko/distfiles/URI
+		[zorry]=HTTP~zorry/patches/gcc/URI
+		[vapier]=HTTP~vapier/dist/URI
+		[blueness]=HTTP~blueness/dist/URI
+	)
+
+	# Newer ebuilds should set TOOLCHAIN_PATCH_DEV and we'll just
+	# return the full URL from the array.
+	if [[ -n ${TOOLCHAIN_PATCH_DEV} ]] ; then
+		local devspace_url=${devspace_urls[${TOOLCHAIN_PATCH_DEV}]}
+		if [[ -n ${devspace_url} ]] ; then
+			local devspace_url_exp=${devspace_url//HTTP/https:\/\/dev.gentoo.org\/}
+			devspace_url_exp=${devspace_url_exp//URI/$1}
+			echo ${devspace_url_exp}
+			return
+		fi
+	fi
+
+	# But we keep the old fallback list for compatibility with
+	# older ebuilds (overlays etc).
+	local devspace="
+		HTTP~soap/distfiles/URI
+		HTTP~sam/distfiles/URI
+		HTTP~sam/distfiles/sys-devel/gcc/URI
+		HTTP~tamiko/distfiles/URI
+		HTTP~zorry/patches/gcc/URI
+		HTTP~vapier/dist/URI
+		HTTP~blueness/dist/URI"
 	devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
-	echo mirror://gentoo/$1 ${devspace//URI/$1}
+	echo ${devspace//URI/$1} mirror://gentoo/$1
 }
 
 # This function handles the basics of setting the SRC_URI for a gcc ebuild.
@@ -330,19 +429,19 @@ gentoo_urls() {
 #	PATCH_GCC_VER
 #			This should be set to the version of the gentoo patch tarball.
 #			The resulting filename of this tarball will be:
-#			gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+#			gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.xz
 #
 #	PIE_VER
 #	PIE_GCC_VER
 #			These variables control patching in various updates for the logic
-#			controlling Position Independant Executables. PIE_VER is expected
+#			controlling Position Independent Executables. PIE_VER is expected
 #			to be the version of this patch, and PIE_GCC_VER the gcc version of
 #			the patch:
 #			An example:
 #					PIE_VER="8.7.6.5"
 #					PIE_GCC_VER="3.4.0"
 #			The resulting filename of this tarball will be:
-#			gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
+#			gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.xz
 #
 #	SPECS_VER
 #	SPECS_GCC_VER
@@ -354,7 +453,7 @@ gentoo_urls() {
 #					SPECS_VER="8.7.6.5"
 #					SPECS_GCC_VER="3.4.0"
 #			The resulting filename of this tarball will be:
-#			gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
+#			gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.xz
 #
 #	CYGWINPORTS_GITREV
 #			If set, this variable signals that we should apply additional patches
@@ -365,7 +464,7 @@ gentoo_urls() {
 #			with a Cygwin target.
 get_gcc_src_uri() {
 	export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
-	export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
+	export MUSL_GCC_VER=${MUSL_GCC_VER:-${PATCH_GCC_VER}}
 	export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
 	export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
 	export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
@@ -375,10 +474,10 @@ get_gcc_src_uri() {
 	if tc_is_live ; then
 		: # Nothing to do w/git snapshots.
 	elif [[ -n ${GCC_TARBALL_SRC_URI} ]] ; then
-		# 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}"
 	elif [[ -n ${SNAPSHOT} ]] ; then
-		GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz"
+		GCC_SRC_URI="https://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz"
 	else
 		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"
@@ -387,18 +486,18 @@ get_gcc_src_uri() {
 		fi
 	fi
 
-	[[ -n ${UCLIBC_VER} ]] && \
-		GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
 	[[ -n ${PATCH_VER} ]] && \
-		GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
+		GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
+	[[ -n ${MUSL_VER} ]] && \
+		GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
 
 	[[ -n ${PIE_VER} ]] && \
-		PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
+		PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX}} && \
 		GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
 
 	# gcc minispec for the hardened gcc 4 compiler
 	[[ -n ${SPECS_VER} ]] && \
-		GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
+		GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
 
 	if tc_has_feature gcj ; then
 		if tc_version_is_at_least 4.5 ; then
@@ -436,9 +535,40 @@ toolchain_pkg_pretend() {
 #---->> pkg_setup <<----
 
 toolchain_pkg_setup() {
-	# we dont want to use the installed compiler's specs to build gcc
+	# We don't want to use the installed compiler's specs to build gcc
 	unset GCC_SPECS
-	unset LANGUAGES #265283
+
+	# bug #265283
+	unset LANGUAGES
+
+	# See https://www.gnu.org/software/make/manual/html_node/Parallel-Output.html
+	# Avoid really confusing logs from subconfigure spam, makes logs far
+	# more legible.
+	MAKEOPTS="--output-sync=line ${MAKEOPTS}"
+}
+
+#---->> src_unpack <<----
+
+# @FUNCTION: toolchain_fetch_git_patches
+# @INTERNAL
+# @DESCRIPTION:
+# Fetch patches from Gentoo's gcc-patches repository.
+toolchain_fetch_git_patches() {
+	local gcc_patches_repo="https://anongit.gentoo.org/git/proj/gcc-patches.git https://github.com/gentoo/gcc-patches"
+
+	# If we weren't given a patchset number, pull it from git too.
+	einfo "Fetching patchset from git as PATCH_VER is unset"
+	EGIT_REPO_URI=${gcc_patches_repo} EGIT_BRANCH="master" \
+		EGIT_CHECKOUT_DIR="${WORKDIR}"/patch.tmp \
+		git-r3_src_unpack
+
+	mkdir "${WORKDIR}"/patch || die
+	mv "${WORKDIR}"/patch.tmp/${PATCH_GCC_VER}/gentoo/* "${WORKDIR}"/patch || die
+
+	if [[ -n ${MUSL_VER} || -d "${WORKDIR}"/musl ]] && [[ ${CTARGET} == *musl* ]] ; then
+		mkdir "${WORKDIR}"/musl || die
+		mv "${WORKDIR}"/patch.tmp/${PATCH_GCC_VER}/musl/* "${WORKDIR}"/musl || die
+	fi
 
 	# yuck, but how else to do it portable?
 	local realEPREFIX=$(python -c 'import os; print(os.path.realpath("'"${EPREFIX}"'"))')
@@ -450,37 +580,25 @@ toolchain_pkg_setup() {
 	fi
 }
 
-#---->> src_unpack <<----
-
 toolchain_src_unpack() {
 	if tc_is_live ; then
 		git-r3_src_unpack
+
+		if [[ -z ${PATCH_VER} ]] && ! use vanilla ; then
+			toolchain_fetch_git_patches
+		fi
+	elif [[ -z ${PATCH_VER} && -n ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
+		toolchain_fetch_git_patches
 	fi
 
-	default_src_unpack
+	default
 }
 
 #---->> src_prepare <<----
 
-# 'epatch' is not available in EAPI=7. Abstract away patchset application
-# until we eventually get all gcc ebuilds on EAPI=7 or later.
-tc_apply_patches() {
-	[[ ${#@} -lt 2 ]] && die "usage: tc_apply_patches <message> <patches...>"
-
-	einfo "$1"; shift
-
-	case ${EAPI:-0} in
-		# Note: even for EAPI=6 we used 'epatch' semantics. To avoid
-		# breaking existing ebuilds use 'eapply' only in EAPI=7 or later.
-		5*|6) epatch "$@" ;;
-		7) eapply "$@" ;;
-		*) die "Update apply_patches() for ${EAPI}." ;;
-	esac
-}
-
 toolchain_src_prepare() {
 	export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
-	cd "${S}"
+	cd "${S}" || die
 
 	do_gcc_gentoo_patches
 	do_gcc_PIE_patches
@@ -490,11 +608,7 @@ toolchain_src_prepare() {
 		BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, commit ${EGIT_VERSION}"
 	fi
 
-	case ${EAPI:-0} in
-		5*) epatch_user;;
-		6|7) eapply_user ;;
-		*) die "Update toolchain_src_prepare() for ${EAPI}." ;;
-	esac
+	eapply_user
 
 	if ( tc_version_is_at_least 4.8.2 || _tc_use_if_iuse hardened ) \
 		   && ! use vanilla ; then
@@ -509,11 +623,11 @@ toolchain_src_prepare() {
 	sed -i -e "/\"\/System\/Library\/Frameworks\"\,/i\ \   \"${EPREFIX}/MacOSX.sdk/System/Library/Frameworks\"\, \"${EPREFIX}/Frameworks\"\, " \
 		"${S}"/gcc/config/darwin-c.c || die "sed gcc/config/darwin-c.c failed"
 
-	# make sure the pkg config files install into multilib dirs.
-	# since we configure with just one --libdir, we can't use that
-	# (as gcc itself takes care of building multilibs).  #435728
+	# Make sure the pkg-config files install into multilib dirs.
+	# Since we configure with just one --libdir, we can't use that
+	# (as gcc itself takes care of building multilibs). bug #435728
 	find "${S}" -name Makefile.in \
-		-exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
+		-exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} + || die
 
 	setup_multilib_osdirnames
 	gcc_version_patch
@@ -546,7 +660,7 @@ toolchain_src_prepare() {
 
 	gnuconfig_update
 
-	# update configure files
+	# Update configure files
 	local f
 	einfo "Fixing misc issues in configure files"
 	for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
@@ -555,12 +669,12 @@ toolchain_src_prepare() {
 			|| eerror "Please file a bug about this"
 		eend $?
 	done
-	sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
+	# bug #215828
+	sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die
 
-	# Prevent new texinfo from breaking old versions (see #198182, #464008)
-	if tc_version_is_at_least 4.1; then
-		tc_apply_patches "Remove texinfo (bug #198182, bug #464008)" "${FILESDIR}"/gcc-configure-texinfo.patch
-	fi
+	# Prevent new texinfo from breaking old versions (see #198182, bug #464008)
+	einfo "Remove texinfo (bug #198182, bug #464008)"
+	eapply "${FILESDIR}"/gcc-configure-texinfo.patch
 
 	# >=gcc-4
 	if [[ -x contrib/gcc_update ]] ; then
@@ -574,12 +688,28 @@ toolchain_src_prepare() {
 
 do_gcc_gentoo_patches() {
 	if ! use vanilla ; then
-		if [[ -n ${PATCH_VER} ]] ; then
-			tc_apply_patches "Applying Gentoo patches ..." "${WORKDIR}"/patch/*.patch
+		if [[ -n ${PATCH_VER} || -d "${WORKDIR}"/patch ]] ; then
+			einfo "Applying Gentoo patches ..."
+			eapply "${WORKDIR}"/patch/*.patch
 			BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
 		fi
-		if [[ -n ${UCLIBC_VER} ]] ; then
-			tc_apply_patches "Applying uClibc patches ..." "${WORKDIR}"/uclibc/*.patch
+
+		if [[ -n ${MUSL_VER} || -d "${WORKDIR}"/musl ]] && [[ ${CTARGET} == *musl* ]] ; then
+			if [[ ${CATEGORY} == cross-* ]] ; then
+				# We don't want to apply some patches when cross-compiling.
+				if [[ -d "${WORKDIR}"/musl/nocross ]] ; then
+					rm -fv "${WORKDIR}"/musl/nocross/*.patch || die
+				else
+					# Just make an empty directory to make the glob below easier.
+					mkdir -p "${WORKDIR}"/musl/nocross || die
+				fi
+			fi
+
+			local shopt_save=$(shopt -p nullglob)
+			shopt -s nullglob
+			einfo "Applying musl patches ..."
+			eapply "${WORKDIR}"/musl/{,nocross/}*.patch
+			${shopt_save}
 		fi
 	fi
 }
@@ -588,7 +718,8 @@ do_gcc_PIE_patches() {
 	want_pie || return 0
 	use vanilla && return 0
 
-	tc_apply_patches "Applying pie patches ..." "${WORKDIR}"/piepatch/*.patch
+	einfo "Applying PIE patches ..."
+	eapply "${WORKDIR}"/piepatch/*.patch
 
 	BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
 }
@@ -598,7 +729,7 @@ do_gcc_CYGWINPORTS_patches() {
 	use elibc_Cygwin || return 0
 
 	local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
-	# readarray -t is available since bash-4.4 only, #690686
+	# readarray -t is available since bash-4.4 only, bug #690686
 	local patches=( $(
 		for p in $(
 			sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport
@@ -606,21 +737,23 @@ do_gcc_CYGWINPORTS_patches() {
 			echo "${d}/${p}"
 		done
 	) )
-	tc_apply_patches "Applying cygwin port patches ..." ${patches[*]}
+	einfo "Applying cygwin port patches ..."
+	eapply -- "${patches[@]}"
 }
 
 # configure to build with the hardened GCC specs as the default
 make_gcc_hard() {
 	local gcc_hard_flags=""
 
-	# If we use gcc-6 or newer with pie enable to compile older gcc we need to pass -no-pie
-	# to stage1; bug #618908
+	# If we use gcc-6 or newer with PIE enabled to compile older gcc,
+	# we need to pass -no-pie to stage1; bug #618908
 	if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
 		einfo "Disabling PIE in stage1 (only) ..."
 		sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
 	fi
 
-	# Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
+	# For gcc >= 6.x, we can use configuration options to turn PIE/SSP
+	# on as default
 	if tc_version_is_at_least 6.0 ; then
 		if _tc_use_if_iuse pie ; then
 			einfo "Updating gcc to use automatic PIE building ..."
@@ -630,16 +763,21 @@ make_gcc_hard() {
 		fi
 		if _tc_use_if_iuse hardened ; then
 			# Will add some hardened options as default, like:
-			# -fstack-clash-protection
-			# -z now
-			# see *_all_extra-options.patch gcc patches.
+			# * -fstack-clash-protection
+			# * -z now
+			# See gcc *_all_extra-options.patch patches.
 			gcc_hard_flags+=" -DEXTRA_OPTIONS"
-			# rebrand to make bug reports easier
+
+			if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux* ]] ; then
+				gcc_hard_flags+=" -DEXTRA_OPTIONS_CF"
+			fi
+
+			# Rebrand to make bug reports easier
 			BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
 		fi
 	else
 		if _tc_use_if_iuse hardened ; then
-			# rebrand to make bug reports easier
+			# Rebrand to make bug reports easier
 			BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
 			if hardened_gcc_works ; then
 				einfo "Updating gcc to use automatic PIE + SSP building ..."
@@ -653,7 +791,7 @@ make_gcc_hard() {
 				ewarn "PIE has not been enabled by default"
 				gcc_hard_flags+=" -DEFAULT_SSP"
 			else
-				# do nothing if hardened isn't supported, but don't die either
+				# Do nothing if hardened isn't supported, but don't die either
 				ewarn "hardened is not supported for this arch in this gcc version"
 				return 0
 			fi
@@ -665,16 +803,16 @@ make_gcc_hard() {
 		fi
 	fi
 
-	# we want to be able to control the pie patch logic via something other
+	# We want to be able to control the PIE patch logic via something other
 	# than ALL_CFLAGS...
 	sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
 		-e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
-		-i "${S}"/gcc/Makefile.in
+		-i "${S}"/gcc/Makefile.in || die
 	# Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
 	if tc_version_is_at_least 4.7 ; then
 		sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
 			-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
-			-i "${S}"/gcc/Makefile.in
+			-i "${S}"/gcc/Makefile.in || die
 	fi
 
 	sed -i \
@@ -703,13 +841,13 @@ setup_multilib_osdirnames() {
 	local config
 	local libdirs="../lib64 ../lib32"
 
-	# this only makes sense for some Linux targets
+	# This only makes sense for some Linux targets
 	case ${CTARGET} in
-	x86_64*-linux*)    config="i386" ;;
-	powerpc64*-linux*) config="rs6000" ;;
-	sparc64*-linux*)   config="sparc" ;;
-	s390x*-linux*)     config="s390" ;;
-	*)	               return 0 ;;
+		x86_64*-linux*)    config="i386" ;;
+		powerpc64*-linux*) config="rs6000" ;;
+		sparc64*-linux*)   config="sparc" ;;
+		s390x*-linux*)     config="s390" ;;
+		*)	               return 0 ;;
 	esac
 	config+="/t-linux64"
 
@@ -718,14 +856,14 @@ setup_multilib_osdirnames() {
 		sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
 	fi
 	if [[ ${SYMLINK_LIB} == "yes" ]] ; then
-		einfo "updating multilib directories to be: ${libdirs}"
+		einfo "Updating multilib directories to be: ${libdirs}"
 		if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
 			sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
 		else
 			sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
 		fi
 	else
-		einfo "using upstream multilib; disabling lib32 autodetection"
+		einfo "Using upstream multilib; disabling lib32 autodetection"
 		sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
 	fi
 	sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
@@ -737,7 +875,7 @@ gcc_version_patch() {
 
 	local version_string=${GCC_RELEASE_VER}
 
-	einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
+	einfo "Patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
 
 	local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
 	if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
@@ -760,10 +898,10 @@ toolchain_src_configure() {
 	einfo "LDFLAGS=\"${LDFLAGS}\""
 
 	# Force internal zip based jar script to avoid random
-	# issues with 3rd party jar implementations.  #384291
+	# issues with 3rd party jar implementations. bug #384291
 	export JAR=no
 
-	# For hardened gcc 4.3 piepatchset to build the hardened specs
+	# For hardened gcc 4.3: add the pie patchset to build the hardened specs
 	# file (build.specs) to use when building gcc.
 	if ! tc_version_is_at_least 4.4 && want_minispecs ; then
 		setup_minispecs_gcc_build_specs
@@ -771,6 +909,8 @@ toolchain_src_configure() {
 
 	local confgcc=( --host=${CHOST} )
 
+	local build_config_targets=()
+
 	if is_crosscompile || tc-is-cross-compiler ; then
 		# Straight from the GCC install doc:
 		# "GCC has code to correctly determine the correct value for target
@@ -810,16 +950,13 @@ toolchain_src_configure() {
 	is_d   && GCC_LANG+=",d"
 	is_gcj && GCC_LANG+=",java"
 	is_go  && GCC_LANG+=",go"
-	is_jit && GCC_LANG+=",jit"
 	if is_objc || is_objcxx ; then
 		GCC_LANG+=",objc"
-		if tc_version_is_at_least 4 ; then
-			use objc-gc && confgcc+=( --enable-objc-gc )
-		fi
+		use objc-gc && confgcc+=( --enable-objc-gc )
 		is_objcxx && GCC_LANG+=",obj-c++"
 	fi
 
-	# fortran support just got sillier! the lang value can be f77 for
+	# Fortran support just got sillier! The lang value can be f77 for
 	# fortran77, f95 for fortran95, or just plain old fortran for the
 	# currently supported standard depending on gcc version.
 	is_fortran && GCC_LANG+=",fortran"
@@ -845,11 +982,11 @@ toolchain_src_configure() {
 		confgcc+=( --disable-nls )
 	fi
 
-	tc_version_is_at_least 3.4 || confgcc+=( --disable-libunwind-exceptions )
+	confgcc+=( --disable-libunwind-exceptions )
 
 	# Use the default ("release") checking because upstream usually neglects
 	# to test "disabled" so it has a history of breaking. bug #317217
-	if tc_version_is_at_least 3.4 && in_iuse debug ; then
+	if in_iuse debug ; then
 		# The "release" keyword is new to 4.0. bug #551636
 		local off=$(tc_version_is_at_least 4.0 && echo release || echo no)
 		confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes ${off})}" )
@@ -861,12 +998,12 @@ toolchain_src_configure() {
 		--with-pkgversion="${BRANDING_GCC_PKGVERSION}"
 	)
 
-	# If we want hardened support with the newer piepatchset for >=gcc 4.4
+	# If we want hardened support with the newer PIE patchset for >=gcc 4.4
 	if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then
 		confgcc+=( $(use_enable hardened esp) )
 	fi
 
-	# allow gcc to search for clock funcs in the main C lib.
+	# Allow gcc to search for clock funcs in the main C lib.
 	# if it can't find them, then tough cookies -- we aren't
 	# going to link in -lrt to all C++ apps. bug #411681
 	if tc_version_is_at_least 4.4 && is_cxx ; then
@@ -875,17 +1012,18 @@ toolchain_src_configure() {
 
 	# Build compiler itself using LTO
 	if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then
-		confgcc+=( --with-build-config=bootstrap-lto )
+		build_config_targets+=( bootstrap-lto )
+	fi
+
+	if tc_version_is_at_least 12 && _tc_use_if_iuse cet ; then
+		build_config_targets+=( bootstrap-cet )
 	fi
 
-	# Support to disable pch when building libstdcxx
+	# Support to disable PCH when building libstdcxx
 	if tc_version_is_at_least 6.0 && ! _tc_use_if_iuse pch ; then
 		confgcc+=( --disable-libstdcxx-pch )
 	fi
 
-	# The jit language requires this.
-	is_jit && confgcc+=( --enable-host-shared )
-
 	# build-id was disabled for file collisions: bug #526144
 	#
 	# # Turn on the -Wl,--build-id flag by default for ELF targets. bug #525942
@@ -898,7 +1036,7 @@ toolchain_src_configure() {
 	# 	;;
 	# esac
 
-	# newer gcc versions like to bootstrap themselves with C++,
+	# Newer gcc versions like to bootstrap themselves with C++,
 	# so we need to manually disable it ourselves
 	if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
 		confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
@@ -914,55 +1052,65 @@ toolchain_src_configure() {
 		# disable a bunch of features or gcc goes boom
 		local needed_libc=""
 		case ${CTARGET} in
-		*-linux)		 needed_libc=error-unknown-libc;;
-		*-dietlibc)		 needed_libc=dietlibc;;
-		*-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 )
-			;;
-		*-gentoo-freebsd*) needed_libc=freebsd-lib;;
-		*-gnu*)			 needed_libc=glibc;;
-		*-klibc)		 needed_libc=klibc;;
-		*-musl*)		 needed_libc=musl;;
-		*-uclibc*)
-			# Enable shared library support only on targets
-			# that support it: bug #291870
-			if ! echo '#include <features.h>' | \
-			   $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
-			   grep -q __HAVE_SHARED__
-			then
-				confgcc+=( --disable-shared )
-			fi
-			needed_libc=uclibc-ng
-			;;
-		*-cygwin)		 needed_libc=cygwin;;
-		x86_64-*-mingw*|\
-		*-w64-mingw*)	 needed_libc=mingw64-runtime;;
-		mingw*|*-mingw*) needed_libc=mingw-runtime;;
-		avr)			 confgcc+=( --enable-shared --disable-threads );;
-		*-apple-darwin*) confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}" );;
-		*-solaris*)      confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}"
-			);;
-		*-freebsd*)      confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}"
-		);;
+			*-linux)
+				needed_libc=error-unknown-libc
+				;;
+			*-dietlibc)
+				needed_libc=dietlibc
+				;;
+			*-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 )
+				;;
+			*-gnu*)
+				needed_libc=glibc
+				;;
+			*-klibc)
+				needed_libc=klibc
+				;;
+			*-musl*)
+				needed_libc=musl
+				;;
+			*-cygwin)
+				needed_libc=cygwin
+				;;
+			x86_64-*-mingw*|*-w64-mingw*)
+				needed_libc=mingw64-runtime
+				;;
+			avr)
+				confgcc+=( --enable-shared --disable-threads )
+				;;
+			# Prefix targets
+			*-apple-darwin*)
+				confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}" )
+				;;
+			*-solaris*)
+				confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}" )
+				;;
+			*-freebsd*)
+				confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}" )
+				;;
 		esac
+
 		if [[ -n ${needed_libc} ]] ; then
 			local confgcc_no_libc=( --disable-shared )
 			# requires libc: bug #734820
 			tc_version_is_at_least 4.6 && confgcc_no_libc+=( --disable-libquadmath )
 			# requires libc
 			tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
+
 			if ! has_version ${CATEGORY}/${needed_libc} ; then
 				confgcc+=(
 					"${confgcc_no_libc[@]}"
 					--disable-threads
 					--without-headers
 				)
-				if [[ $needed_libc == glibc ]]; then
+
+				if [[ ${needed_libc} == glibc ]] ; then
 					# By default gcc looks at glibc's headers
 					# to detect long double support. This does
 					# not work for --disable-headers mode.
@@ -980,7 +1128,7 @@ toolchain_src_configure() {
 			fi
 		fi
 
-		tc_version_is_at_least 4.2 && confgcc+=( --disable-bootstrap )
+		confgcc+=( --disable-bootstrap )
 	else
 		if tc-is-static-only ; then
 			confgcc+=( --disable-shared )
@@ -988,10 +1136,12 @@ toolchain_src_configure() {
 			confgcc+=( --enable-shared )
 		fi
 		case ${CHOST} in
-		mingw*|*-mingw*)
-			confgcc+=( --enable-threads=win32 ) ;;
-		*)
-			confgcc+=( --enable-threads=posix ) ;;
+			mingw*|*-mingw*)
+				confgcc+=( --enable-threads=win32 )
+				;;
+			*)
+				confgcc+=( --enable-threads=posix )
+				;;
 		esac
 
 		if use prefix ; then
@@ -1012,39 +1162,21 @@ toolchain_src_configure() {
 	# __cxa_atexit is "essential for fully standards-compliant handling of
 	# destructors", but apparently requires glibc.
 	case ${CTARGET} in
-	*-uclibc*)
-		if tc_has_feature nptl ; then
+		*-elf|*-eabi)
+			confgcc+=( --with-newlib )
+			;;
+		*-musl*)
+			confgcc+=( --enable-__cxa_atexit )
+			;;
+		*-gnu*)
 			confgcc+=(
-				--disable-__cxa_atexit
-				$(use_enable nptl tls)
+				--enable-__cxa_atexit
+				--enable-clocale=gnu
 			)
-		fi
-		tc_version_is_between 3.3 3.4 && confgcc+=( --enable-sjlj-exceptions )
-		if tc_version_is_between 3.4 4.3 ; then
-			confgcc+=( --enable-clocale=uclibc )
-		fi
-		;;
-	*-elf|*-eabi)
-		confgcc+=( --with-newlib )
-		;;
-	*-musl*)
-		confgcc+=( --enable-__cxa_atexit )
-		;;
-	*-gnu*)
-		confgcc+=(
-			--enable-__cxa_atexit
-			--enable-clocale=gnu
-		)
-		;;
-	*-freebsd*)
-		confgcc+=( --enable-__cxa_atexit )
-		;;
-	*-openbsd*)
-		confgcc+=( --enable-__cxa_atexit )
-		;;
-	*-solaris*)
-		confgcc+=( --enable-__cxa_atexit )
-		;;
+			;;
+		*-solaris*)
+			confgcc+=( --enable-__cxa_atexit )
+			;;
 	esac
 
 	### arch options
@@ -1057,102 +1189,117 @@ toolchain_src_configure() {
 	tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
 
 	case $(tc-is-softfloat) in
-	yes)    confgcc+=( --with-float=soft ) ;;
-	softfp) confgcc+=( --with-float=softfp ) ;;
-	*)
-		# If they've explicitly opt-ed in, do hardfloat,
-		# otherwise let the gcc default kick in.
-		case ${CTARGET//_/-} in
-		*-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
-		esac
+		yes)
+			confgcc+=( --with-float=soft )
+			;;
+		softfp)
+			confgcc+=( --with-float=softfp )
+			;;
+		*)
+			# If they've explicitly opt-ed in, do hardfloat,
+			# otherwise let the gcc default kick in.
+			case ${CTARGET//_/-} in
+				*-hardfloat-*|*eabihf)
+					confgcc+=( --with-float=hard )
+				;;
+			esac
 	esac
 
 	local with_abi_map=()
 	case $(tc-arch) in
-	arm)	#264534 #414395
-		local a arm_arch=${CTARGET%%-*}
-		# Remove trailing endian variations first: eb el be bl b l
-		for a in e{b,l} {b,l}e b l ; do
-			if [[ ${arm_arch} == *${a} ]] ; then
-				arm_arch=${arm_arch%${a}}
-				break
+		arm)
+			# bug 264534, bug #414395
+			local a arm_arch=${CTARGET%%-*}
+			# Remove trailing endian variations first: eb el be bl b l
+			for a in e{b,l} {b,l}e b l ; do
+				if [[ ${arm_arch} == *${a} ]] ; then
+					arm_arch=${arm_arch%${a}}
+					break
+				fi
+			done
+
+			# Convert armv6m to armv6-m
+			[[ ${arm_arch} == armv6m ]] && arm_arch=armv6-m
+			# Convert armv7{a,r,m} to armv7-{a,r,m}
+			[[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
+			# See if this is a valid --with-arch flag
+			if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
+			    . "${srcdir}"/config.gcc) &>/dev/null
+			then
+				confgcc+=( --with-arch=${arm_arch} )
 			fi
-		done
-		# Convert armv7{a,r,m} to armv7-{a,r,m}
-		[[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
-		# See if this is a valid --with-arch flag
-		if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
-		    . "${srcdir}"/config.gcc) &>/dev/null
-		then
-			confgcc+=( --with-arch=${arm_arch} )
-		fi
 
-		# Make default mode thumb for microcontroller classes #418209
-		[[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
+			# Make default mode thumb for microcontroller classes #418209
+			[[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
 
-		# Enable hardvfp
-		if [[ $(tc-is-softfloat) == "no" ]] && \
-		   [[ ${CTARGET} == armv[67]* ]] && \
-		   tc_version_is_at_least 4.5
-		then
-			# Follow the new arm hardfp distro standard by default
-			confgcc+=( --with-float=hard )
-			case ${CTARGET} in
-			armv6*) confgcc+=( --with-fpu=vfp ) ;;
-			armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
-			esac
-		fi
-		;;
-	mips)
-		# Add --with-abi flags to set default ABI
-		confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
-		;;
-	amd64)
-		# drop the older/ABI checks once this get's merged into some
-		# version of gcc upstream
-		if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
+			# Enable hardvfp
+			if [[ $(tc-is-softfloat) == "no" ]] && \
+			   [[ ${CTARGET} == armv[67]* ]] && \
+			   tc_version_is_at_least 4.5
+			then
+				# Follow the new arm hardfp distro standard by default
+				confgcc+=( --with-float=hard )
+				case ${CTARGET} in
+					armv6*) confgcc+=( --with-fpu=vfp ) ;;
+					armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
+				esac
+			fi
+			;;
+		mips)
+			# Add --with-abi flags to set default ABI
 			confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
-		fi
-		;;
-	x86)
-		# Default arch for x86 is normally i386, lets give it a bump
-		# since glibc will do so based on CTARGET anyways
-		confgcc+=( --with-arch=${CTARGET%%-*} )
-		;;
-	hppa)
-		# Enable sjlj exceptions for backward compatibility on hppa
-		[[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
-		;;
-	ppc)
-		# Set up defaults based on current CFLAGS
-		is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
-		[[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
-		;;
-	ppc64)
-		# On ppc64 big endian target gcc assumes elfv1 by default,
-		# and elfv2 on little endian
-		# but musl does not support elfv1 at all on any endian ppc64
-		# see https://git.musl-libc.org/cgit/musl/tree/INSTALL
-		# https://bugs.gentoo.org/704784
-		# https://gcc.gnu.org/PR93157
-		[[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
-		;;
-	riscv)
-		# Add --with-abi flags to set default ABI
-		confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
-		;;
+			;;
+
+		amd64)
+			# drop the older/ABI checks once this get's merged into some
+			# version of gcc upstream
+			if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
+				confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
+			fi
+			;;
+		x86)
+			# Default arch for x86 is normally i386, lets give it a bump
+			# since glibc will do so based on CTARGET anyways
+			confgcc+=( --with-arch=${CTARGET%%-*} )
+			;;
+		hppa)
+			# Enable sjlj exceptions for backward compatibility on hppa
+			[[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
+			;;
+		ppc)
+			# Set up defaults based on current CFLAGS
+			is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
+			[[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
+			;;
+		ppc64)
+			# On ppc64 big endian target gcc assumes elfv1 by default,
+			# and elfv2 on little endian
+			# but musl does not support elfv1 at all on any endian ppc64
+			# see https://git.musl-libc.org/cgit/musl/tree/INSTALL
+			# bug #704784
+			# https://gcc.gnu.org/PR93157
+			[[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
+			;;
+		riscv)
+			# Add --with-abi flags to set default ABI
+			confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
+			;;
 	esac
 
 	# if the target can do biarch (-m32/-m64), enable it.  overhead should
 	# be small, and should simplify building of 64bit kernels in a 32bit
-	# userland by not needing sys-devel/kgcc64.  #349405
-	if use !prefix ; then #406689
+	# userland by not needing sys-devel/kgcc64. bug #349405
 	case $(tc-arch) in
-	ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=( --enable-targets=all ) ;;
-	sparc)     tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
-	amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
+		ppc|ppc64)
+			confgcc+=( --enable-targets=all )
+			;;
+		sparc)
+			tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all )
+			;;
+		amd64|x86)
+			tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all )
+			;;
 	esac
-	fi
 
 	# On Darwin we need libdir to be set in order to get correct install names
 	# for things like libobjc-gnu, libgcj and libfortran.  If we enable it on
@@ -1172,47 +1319,44 @@ toolchain_src_configure() {
 		fi
 	fi
 
-	if tc_version_is_at_least 4.2 ; then
-		if in_iuse openmp ; then
-			# Make sure target has pthreads support. #326757 #335883
-			# There shouldn't be a chicken & egg problem here as openmp won't
-			# build without a C library, and you can't build that w/out
-			# already having a compiler ...
-			if ! is_crosscompile || \
-			   $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
-			then
-				confgcc+=( $(use_enable openmp libgomp) )
-			else
-				# Force disable as the configure script can be dumb #359855
-				confgcc+=( --disable-libgomp )
-			fi
+	if in_iuse openmp ; then
+		# Make sure target has pthreads support: bug #326757, bug #335883
+		# There shouldn't be a chicken & egg problem here as openmp won't
+		# build without a C library, and you can't build that w/out
+		# already having a compiler ...
+		if ! is_crosscompile || \
+		   $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
+		then
+			confgcc+=( $(use_enable openmp libgomp) )
 		else
-			# For gcc variants where we don't want openmp (e.g. kgcc)
+			# Force disable as the configure script can be dumb #359855
 			confgcc+=( --disable-libgomp )
 		fi
+	else
+		# For gcc variants where we don't want openmp (e.g. kgcc)
+		confgcc+=( --disable-libgomp )
 	fi
 
-	if tc_version_is_at_least 4.0 ; then
-		if _tc_use_if_iuse libssp ; then
-			confgcc+=( --enable-libssp )
+	if _tc_use_if_iuse libssp ; then
+		confgcc+=( --enable-libssp )
+	else
+		if hardened_gcc_is_stable ssp; then
+			export gcc_cv_libc_provides_ssp=yes
+		fi
+		if _tc_use_if_iuse ssp; then
+			# On some targets USE="ssp -libssp" is an invalid
+			# configuration as target libc does not provide
+			# stack_chk_* functions. Do not disable libssp there.
+			case ${CTARGET} in
+				mingw*|*-mingw*)
+					ewarn "Not disabling libssp"
+					;;
+				*)
+					confgcc+=( --disable-libssp )
+					;;
+			esac
 		else
-			# Not all libcs have ssp built in.  I assume only glibc has
-			# this for now.
-			use elibc_glibc &&
-			if hardened_gcc_is_stable ssp; then
-				export gcc_cv_libc_provides_ssp=yes
-			fi
-			if _tc_use_if_iuse ssp; then
-				# On some targets USE="ssp -libssp" is an invalid
-				# configuration as target libc does not provide
-				# stack_chk_* functions. Do not disable libssp there.
-				case ${CTARGET} in
-					mingw*|*-mingw*) ewarn "Not disabling libssp" ;;
-					*) confgcc+=( --disable-libssp ) ;;
-				esac
-			else
-				confgcc+=( --disable-libssp )
-			fi
+			confgcc+=( --disable-libssp )
 		fi
 	fi
 
@@ -1220,6 +1364,10 @@ toolchain_src_configure() {
 		confgcc+=( --disable-libada )
 	fi
 
+	if in_iuse cet ; then
+		confgcc+=( $(use_enable cet) )
+	fi
+
 	if in_iuse cilk ; then
 		confgcc+=( $(use_enable cilk libcilkrts) )
 	fi
@@ -1248,6 +1396,8 @@ toolchain_src_configure() {
 		confgcc+=( $(use_with zstd) )
 	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
@@ -1255,7 +1405,7 @@ toolchain_src_configure() {
 	fi
 
 	# graphite was added in 4.4 but we only support it in 6.5+ due to external
-	# library issues.  #448024, #701270
+	# library issues. bug #448024, bug #701270
 	if tc_version_is_at_least 6.5 && in_iuse graphite ; then
 		confgcc+=( $(use_with graphite isl) )
 		use graphite && confgcc+=( --disable-isl-version-check )
@@ -1288,7 +1438,7 @@ toolchain_src_configure() {
 	fi
 
 	# Disable gcc info regeneration -- it ships with generated info pages
-	# already.  Our custom version/urls/etc... trigger it.  #464008
+	# already.  Our custom version/urls/etc... trigger it. bug #464008
 	export gcc_cv_prog_makeinfo_modern=no
 
 	# Do not let the X detection get in our way.  We know things can be found
@@ -1299,6 +1449,11 @@ toolchain_src_configure() {
 
 	confgcc+=( "$@" ${EXTRA_ECONF} )
 
+	if [[ -n ${build_config_targets} ]] ; then
+		# ./configure --with-build-config='bootstrap-lto bootstrap-cet'
+		confgcc+=( --with-build-config="${build_config_targets[*]}" )
+	fi
+
 	# Nothing wrong with a good dose of verbosity
 	echo
 	einfo "PREFIX:          ${PREFIX}"
@@ -1309,23 +1464,45 @@ toolchain_src_configure() {
 	echo
 	einfo "Languages:       ${GCC_LANG}"
 	echo
-	einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}"
-	echo
 
 	# Build in a separate build tree
-	mkdir -p "${WORKDIR}"/build
+	mkdir -p "${WORKDIR}"/build || die
 	pushd "${WORKDIR}"/build > /dev/null
 
-	# and now to do the actual configuration
+	# ...and now to do the actual configuration
 	addwrite /dev/zero
-	echo "${S}"/configure "${confgcc[@]}"
+
+	local gcc_shell="${BROOT}"/bin/bash
 	# Older gcc versions did not detect bash and re-exec itself, so force the
-	# use of bash.  Newer ones will auto-detect, but this is not harmful.
-	CONFIG_SHELL="${EPREFIX}/bin/bash" \
-	bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
+	# use of bash for them.
+	if tc_version_is_at_least 11.2 ; then
+		gcc_shell="${BROOT}"/bin/sh
+	fi
 
-	# return to whatever directory we were in before
-	popd > /dev/null
+	if is_jit ; then
+		einfo "Configuring JIT gcc"
+
+		mkdir -p "${WORKDIR}"/build-jit || die
+		pushd "${WORKDIR}"/build-jit > /dev/null || die
+		CONFIG_SHELL="${gcc_shell}" edo "${gcc_shell}" "${S}"/configure \
+				"${confgcc[@]}" \
+				--disable-libada \
+				--disable-libsanitizer \
+				--disable-libvtv \
+				--disable-libgomp \
+				--disable-libquadmath \
+				--disable-libatomic \
+				--disable-lto \
+				--disable-bootstrap \
+				--enable-host-shared \
+				--enable-languages=jit
+		popd > /dev/null || die
+	fi
+
+	CONFIG_SHELL="${gcc_shell}" edo "${gcc_shell}" "${S}"/configure "${confgcc[@]}"
+
+	# Return to whatever directory we were in before
+	popd > /dev/null || die
 }
 
 # Replace -m flags unsupported by the version being built with the best
@@ -1341,20 +1518,9 @@ downgrade_arch_flags() {
 	myarch=$(get-flag march)
 	mytune=$(get-flag mtune)
 
-	# If -march=native isn't supported we have to tease out the actual arch
-	if [[ ${myarch} == native || ${mytune} == native ]] ; then
-		if ! tc_version_is_at_least 4.2 ${bver}; then
-			arch=$($(tc-getCC) -march=native -v -E -P - </dev/null 2>&1 \
-				| sed -rn "/cc1.*-march/s:.*-march=([^ ']*).*:\1:p")
-			replace-cpu-flags native ${arch}
-		fi
-	fi
-
 	# Handle special -mtune flags
 	[[ ${mytune} == intel ]] && ! tc_version_is_at_least 4.9 ${bver} && replace-cpu-flags intel generic
-	[[ ${mytune} == generic ]] && ! tc_version_is_at_least 4.2 ${bver} && filter-flags '-mtune=*'
 	[[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
-	tc_version_is_at_least 3.4 ${bver} || filter-flags '-mtune=*'
 
 	# "added" "arch" "replacement"
 	local archlist=(
@@ -1386,14 +1552,6 @@ downgrade_arch_flags() {
 		4.3 geode k6-2 # gcc.gnu.org/PR41989#c22
 		4.3 k8-sse3 k8
 		4.3 opteron-sse3 k8
-		3.4 athlon-fx x86-64
-		3.4 athlon64 x86-64
-		3.4 c3-2 c3
-		3.4 k8 x86-64
-		3.4 opteron x86-64
-		3.4 pentium-m pentium3
-		3.4 pentium3m pentium3
-		3.4 pentium4m pentium4
 	)
 
 	for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do
@@ -1416,7 +1574,7 @@ downgrade_arch_flags() {
 		fi
 	done
 
-	# we only check -mno* here since -m* get removed by strip-flags later on
+	# We only check -mno* here since -m* get removed by strip-flags later on
 	local isalist=(
 		4.9 -mno-sha
 		4.9 -mno-avx512pf
@@ -1468,35 +1626,21 @@ gcc_do_filter_flags() {
 		# relating to failed builds, we strip most CFLAGS out to ensure as few
 		# problems as possible.
 		strip-flags
+
 		# Lock gcc at -O2; we want to be conservative here.
 		filter-flags '-O?'
 		append-flags -O2
 	fi
 
-	# dont want to funk ourselves
+	# Don't want to funk ourselves
 	filter-flags '-mabi*' -m31 -m32 -m64
 
-	filter-flags -frecord-gcc-switches # 490738
-	filter-flags -mno-rtm -mno-htm # 506202
+	# bug #490738
+	filter-flags -frecord-gcc-switches
+	# bug #506202
+	filter-flags -mno-rtm -mno-htm
 
-	if tc_version_is_between 3.2 3.4 ; then
-		# XXX: this is so outdated it's barely useful, but it don't hurt...
-		replace-cpu-flags G3 750
-		replace-cpu-flags G4 7400
-		replace-cpu-flags G5 7400
-
-		# XXX: should add a sed or something to query all supported flags
-		#      from the gcc source and trim everything else ...
-		filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
-		filter-flags -f{no-,}stack-protector{,-all}
-		filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
-		# and warning options
-		filter-flags -Wextra -Wstack-protector
-	fi
-	if ! tc_version_is_at_least 4.1 ; then
-		filter-flags -fdiagnostics-show-option
-		filter-flags -Wstack-protector
-	fi
+	filter-flags '-fsanitize=*'
 
 	if tc_version_is_between 6 8 ; then
 		# -mstackrealign triggers crashes in exception throwing
@@ -1505,40 +1649,37 @@ gcc_do_filter_flags() {
 		filter-flags -mstackrealign
 	fi
 
-	if tc_version_is_at_least 3.4 ; then
-		case $(tc-arch) in
-			amd64|x86)
-				filter-flags '-mcpu=*'
+	case $(tc-arch) in
+		amd64|x86)
+			filter-flags '-mcpu=*'
 
-				tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287
+			# bug #357287
+			tc_version_is_between 4.4 4.5 && append-flags -mno-avx
 
-				if tc_version_is_between 4.6 4.7 ; then
-					# https://bugs.gentoo.org/411333
-					# https://bugs.gentoo.org/466454
-					replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
-				fi
-				;;
-			alpha)
-				# https://bugs.gentoo.org/454426
-				append-ldflags -Wl,--no-relax
-				;;
-			sparc)
-				# temporary workaround for random ICEs reproduced by multiple users
-				# https://bugs.gentoo.org/457062
-				tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
-				;;
-			*-macos)
-				# http://gcc.gnu.org/PR25127
-				# used to break on 4.1 4.2 now breaks on 10 too, so
-				# filter everywhere
+			if tc_version_is_between 4.6 4.7 ; then
+				# bug #411333, bug #466454
+				replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
+			fi
+			;;
+		alpha)
+			# bug #454426
+			append-ldflags -Wl,--no-relax
+			;;
+		sparc)
+			# Temporary workaround for random ICEs reproduced by multiple users
+			# bug #457062
+			tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
+			;;
+		*-macos)
+			# https://gcc.gnu.org/PR25127
+			tc_version_is_between 4.0 4.2 && \
 				filter-flags '-mcpu=*' '-march=*' '-mtune=*'
-				;;
-		esac
-	fi
+			;;
+	esac
 
 	strip-unsupported-flags
 
-	# these are set here so we have something sane at configure time
+	# These are set here so we have something sane at configure time
 	if is_crosscompile ; then
 		# Set this to something sane for both native and target
 		CFLAGS="-O2 -pipe"
@@ -1580,7 +1721,7 @@ gcc-multilib-configure() {
 		confgcc+=( --enable-multilib )
 	fi
 
-	# translate our notion of multilibs into gcc's
+	# Translate our notion of multilibs into gcc's
 	local abi list
 	for abi in $(get_all_abis TARGET) ; do
 		local l=$(gcc-abi-map ${abi})
@@ -1599,9 +1740,15 @@ gcc-abi-map() {
 	# Convert the ABI name we use in Gentoo to what gcc uses
 	local map=()
 	case ${CTARGET} in
-	mips*)   map=("o32 32" "n32 n32" "n64 64") ;;
-	riscv*)  map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32") ;;
-	x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
+		mips*)
+			map=("o32 32" "n32 n32" "n64 64")
+			;;
+		riscv*)
+			map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32")
+			;;
+		x86_64*)
+			map=("amd64 m64" "x86 m32" "x32 mx32")
+			;;
 	esac
 
 	local m
@@ -1628,9 +1775,9 @@ toolchain_src_compile() {
 	# Older gcc versions did not detect bash and re-exec itself, so force the
 	# use of bash.  Newer ones will auto-detect, but this is not harmful.
 	# This needs to be set for compile as well, as it's used in libtool
-	# generation, which will break install otherwise (at least in 3.3.6): #664486
-	CONFIG_SHELL="${EPREFIX}/bin/bash" \
-	gcc_do_make ${GCC_MAKE_TARGET}
+	# generation, which will break install otherwise (at least in 3.3.6): bug #664486
+	CONFIG_SHELL="${BROOT}/bin/bash" \
+		gcc_do_make ${GCC_MAKE_TARGET}
 }
 
 gcc_do_make() {
@@ -1645,11 +1792,11 @@ gcc_do_make() {
 
 	# default target
 	if is_crosscompile || tc-is-cross-compiler ; then
-		# 3 stage bootstrapping doesnt quite work when you cant run the
-		# resulting binaries natively ^^;
+		# 3 stage bootstrapping doesn't quite work when you can't run the
+		# resulting binaries natively
 		GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
 	else
-		if tc_version_is_at_least 3.3 && _tc_use_if_iuse pgo; then
+		if _tc_use_if_iuse pgo; then
 			GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
 		else
 			GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
@@ -1680,6 +1827,19 @@ gcc_do_make() {
 		BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
 	fi
 
+	if is_jit ; then
+		# TODO: docs for jit?
+		pushd "${WORKDIR}"/build-jit > /dev/null || die
+
+		einfo "Building JIT"
+		emake \
+			LDFLAGS="${LDFLAGS}" \
+			STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
+			LIBPATH="${LIBPATH}" \
+			BOOT_CFLAGS="${BOOT_CFLAGS}"
+		popd > /dev/null || die
+        fi
+
 	einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
 
 	pushd "${WORKDIR}"/build >/dev/null
@@ -1692,8 +1852,7 @@ gcc_do_make() {
 		STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
 		LIBPATH="${LIBPATH}" \
 		BOOT_CFLAGS="${BOOT_CFLAGS}" \
-		${GCC_MAKE_TARGET} \
-		|| die "emake failed with ${GCC_MAKE_TARGET}"
+		${GCC_MAKE_TARGET}
 
 	if is_ada; then
 		# Without these links it is not getting the good compiler
@@ -1710,16 +1869,17 @@ gcc_do_make() {
 		if type -p doxygen > /dev/null ; then
 			if tc_version_is_at_least 4.3 ; then
 				cd "${CTARGET}"/libstdc++-v3/doc
-				emake doc-man-doxygen || ewarn "failed to make docs"
-			elif tc_version_is_at_least 3.0 ; then
+				emake doc-man-doxygen
+			else
 				cd "${CTARGET}"/libstdc++-v3
-				emake doxygen-man || ewarn "failed to make docs"
+				emake doxygen-man
 			fi
-			# Clean bogus manpages.  #113902
+			# Clean bogus manpages. bug #113902
 			find -name '*_build_*' -delete
-			# Blow away generated directory references.  Newer versions of gcc
-			# have gotten better at this, but not perfect.  This is easier than
-			# backporting all of the various doxygen patches.  #486754
+
+			# Blow away generated directory references. Newer versions of gcc
+			# have gotten better at this, but not perfect. This is easier than
+			# backporting all of the various doxygen patches. bug #486754
 			find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
 				xargs rm -f
 		else
@@ -1734,6 +1894,7 @@ gcc_do_make() {
 
 toolchain_src_test() {
 	cd "${WORKDIR}"/build
+
 	# 'asan' wants to be preloaded first, so does 'sandbox'.
 	# To make asan tests work disable sandbox for all of test suite.
 	# 'backtrace' tests also does not like 'libsandbox.so' presence.
@@ -1746,12 +1907,10 @@ toolchain_src_install() {
 	cd "${WORKDIR}"/build
 
 	# Don't allow symlinks in private gcc include dir as this can break the build
-	# Keep them in prefix for things like 'machine->ia64' #gcc PR26189
-	use prefix ||
 	find gcc/include*/ -type l -delete
 
 	# Copy over the info pages.  We disabled their generation earlier, but the
-	# build system only expects to install out of the build dir, not the source.  #464008
+	# build system only expects to install out of the build dir, not the source. bug #464008
 	mkdir -p gcc/doc
 	local x=
 	for x in "${S}"/gcc/doc/*.info* ; do
@@ -1771,8 +1930,32 @@ toolchain_src_install() {
 			&& use !prefix && rm -f "${x}"
 	done < <(find gcc/include*/ -name '*.h')
 
+	if is_jit ; then
+		# See https://gcc.gnu.org/onlinedocs/gcc-11.3.0/jit/internals/index.html#packaging-notes
+		# and bug #843341.
+		#
+		# Both of the non-JIT and JIT builds  are configured to install to $(DESTDIR)
+		# Install the configuration with --enable-host-shared first
+		# *then* the one without, so that the faster build
+		# of "cc1" et al overwrites the slower build.
+		#
+		# Do the 'make install' from the build directory
+		pushd "${WORKDIR}"/build-jit > /dev/null || die
+		S="${WORKDIR}"/build-jit emake DESTDIR="${D}" install
+
+		# Punt some tools which are really only useful while building gcc
+		find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
+		# This one comes with binutils
+		find "${ED}" -name libiberty.a -delete
+
+		# Move the libraries to the proper location
+		gcc_movelibs
+
+		popd > /dev/null || die
+	fi
+
 	# Do the 'make install' from the build directory
-	S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
+	S="${WORKDIR}"/build emake DESTDIR="${D}" install
 
 	# Punt some tools which are really only useful while building gcc
 	find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
@@ -1796,7 +1979,7 @@ toolchain_src_install() {
 	# Setup the gcc_env_entry for hardened gcc 4 with minispecs
 	want_minispecs && copy_minispecs_gcc_specs
 
-	# Make sure we dont have stuff lying around that
+	# Make sure we don't have stuff lying around that
 	# can nuke multiple versions of gcc
 	gcc_slot_java
 
@@ -1835,7 +2018,7 @@ toolchain_src_install() {
 	# When cross-building gcc does install native tools.
 	if ! is_crosscompile; then
 		# Rename the main go binaries as we don't want to clobber dev-lang/go
-		# when gcc-config runs. #567806
+		# when gcc-config runs. bug #567806
 		if tc_version_is_at_least 5 && is_go ; then
 			for x in go gofmt; do
 				mv ${x} ${x}-${GCCMAJOR} || die
@@ -1843,7 +2026,7 @@ toolchain_src_install() {
 		fi
 	fi
 
-	# As gcc installs object files built against bost ${CHOST} and ${CTARGET}
+	# As gcc installs object files built against both ${CHOST} and ${CTARGET}
 	# ideally we will need to strip them using different tools:
 	# Using ${CHOST} tools:
 	#  - "${D}${BINPATH}"
@@ -1853,29 +2036,27 @@ toolchain_src_install() {
 	#  - "${D}${LIBPATH}"
 	# As dostrip does not specify host to override ${CHOST} tools just skip
 	# non-native binary stripping.
-	is_crosscompile && tc_supports_dostrip && dostrip -x "${LIBPATH}"
+	is_crosscompile && dostrip -x "${LIBPATH}"
 
-	cd "${S}"
+	cd "${S}" || die
 	if is_crosscompile; then
 		rm -rf "${ED}"/usr/share/{man,info}
 		rm -rf "${D}"${DATAPATH}/{man,info}
 	else
-		if tc_version_is_at_least 3.0 ; then
-			local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
-			if [[ -d ${cxx_mandir} ]] ; then
-				cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
-			fi
+		local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
+		if [[ -d ${cxx_mandir} ]] ; then
+			cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
 		fi
 	fi
 
-	# portage regenerates 'dir' files on it's own: bug #672408
+	# Portage regenerates 'dir' files on its own: bug #672408
 	# Drop 'dir' files to avoid collisions.
 	if [[ -f "${D}${DATAPATH}"/info/dir ]]; then
 		einfo "Deleting '${D}${DATAPATH}/info/dir'"
 		rm "${D}${DATAPATH}"/info/dir || die
 	fi
 
-	# prune empty dirs left behind
+	# Prune empty dirs left behind
 	find "${ED}" -depth -type d -delete 2>/dev/null
 
 	# libstdc++.la: Delete as it doesn't add anything useful: g++ itself
@@ -1891,14 +2072,14 @@ toolchain_src_install() {
 	# libgomp-plugin-*.la: Same as above, and it's an internal plugin only
 	# loaded via dlopen.
 	# libgfortran.la: gfortran itself handles linkage correctly in the
-	# dynamic & static case (libgfortran.spec). #573302
+	# dynamic & static case (libgfortran.spec). bug #573302
 	# libgfortranbegin.la: Same as above, and it's an internal lib.
 	# libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
 	# libmpxwrappers.la: See above.
 	# libitm.la: gcc itself handles linkage correctly (libitm.spec).
 	# libvtv.la: gcc itself handles linkage correctly.
 	# lib*san.la: Sanitizer linkage is handled internally by gcc, and they
-	# do not support static linking. #487550 #546700
+	# do not support static linking. bug #487550, bug #546700
 	find "${D}${LIBPATH}" \
 		'(' \
 			-name libstdc++.la -o \
@@ -1928,9 +2109,12 @@ toolchain_src_install() {
 	pushd "${D}${LIBPATH}" >/dev/null
 	for py in $(find . -name '*-gdb.py') ; do
 		local multidir=${py%/*}
+
 		insinto "${gdbdir}/${multidir}"
-		sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
-		doins "${py}" || die
+		# bug #348128
+		sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die
+		doins "${py}"
+
 		rm "${py}" || die
 	done
 	popd >/dev/null
@@ -1939,13 +2123,13 @@ toolchain_src_install() {
 	export QA_EXECSTACK="usr/lib*/go/*/*.gox"
 	export QA_WX_LOAD="usr/lib*/go/*/*.gox"
 
-	# Disable RANDMMAP so PCH works. #301299
+	# Disable RANDMMAP so PCH works, bug #301299
 	if tc_version_is_at_least 4.3 ; then
 		pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
 		pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
 	fi
 
-	# Disable MPROTECT so java works. #574808
+	# Disable MPROTECT so java works, bug #574808
 	if is_gcj ; then
 		pax-mark -m "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
 		pax-mark -m "${D}${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
@@ -1956,9 +2140,6 @@ toolchain_src_install() {
 # when installing gcc, it dumps internal libraries into /usr/lib
 # instead of the private gcc lib path
 gcc_movelibs() {
-	# older versions of gcc did not support --print-multi-os-directory
-	tc_version_is_at_least 3.2 || return 0
-
 	# For non-target libs which are for CHOST and not CTARGET, we want to
 	# move them to the compiler-specific CHOST internal dir.  This is stuff
 	# that you want to link against when building tools rather than building
@@ -1967,9 +2148,10 @@ gcc_movelibs() {
 		dodir "${HOSTLIBPATH#${EPREFIX}}"
 		mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
 	fi
+
 	# libgccjit gets installed to /usr/lib, not /usr/$(get_libdir). Probably
 	# due to a bug in gcc build system.
-	if is_jit ; then
+	if [[ ${PWD} == "${WORKDIR}"/build-jit ]] && is_jit ; then
 		dodir "${LIBPATH#${EPREFIX}}"
 		mv "${ED}"/usr/lib/libgccjit* "${D}${LIBPATH}" || die
 	fi
@@ -2024,8 +2206,8 @@ gcc_movelibs() {
 	find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
 }
 
-# make sure the libtool archives have libdir set to where they actually
-# -are-, and not where they -used- to be.  also, any dependencies we have
+# Make sure the libtool archives have libdir set to where they actually
+# -are-, and not where they -used- to be. Also, any dependencies we have
 # on our own .la files need to be updated.
 fix_libtool_libdir_paths() {
 	local libpath="$1"
@@ -2038,7 +2220,7 @@ fix_libtool_libdir_paths() {
 	allarchives="\(${allarchives// /\\|}\)"
 	popd >/dev/null
 
-	# The libdir might not have any .la files. #548782
+	# The libdir might not have any .la files. bug #548782
 	find "./${dir}" -maxdepth 1 -name '*.la' \
 		-exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
 	# Would be nice to combine these, but -maxdepth can not be specified
@@ -2073,21 +2255,16 @@ create_gcc_env_entry() {
 	# workaround for libtool being stupid and using .la's from
 	# conflicting ABIs by using the first one in the search path
 	local ldpaths mosdirs
-	if tc_version_is_at_least 3.2 ; then
-		local mdir mosdir abi ldpath
-		for abi in $(get_all_abis TARGET) ; do
-			mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
-			ldpath=${LIBPATH}
-			[[ ${mdir} != "." ]] && ldpath+="/${mdir}"
-			ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
-
-			mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
-			mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
-		done
-	else
-		# Older gcc's didn't do multilib, so logic is simple.
-		ldpaths=${LIBPATH}
-	fi
+	local mdir mosdir abi ldpath
+	for abi in $(get_all_abis TARGET) ; do
+		mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
+		ldpath=${LIBPATH}
+		[[ ${mdir} != "." ]] && ldpath+="/${mdir}"
+		ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
+
+		mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
+		mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
+	done
 
 	cat <<-EOF > ${gcc_envd_file}
 	GCC_PATH="${BINPATH}"
@@ -2129,12 +2306,12 @@ create_revdep_rebuild_entry() {
 }
 
 copy_minispecs_gcc_specs() {
-	# on gcc 6 we don't need minispecs
+	# On gcc 6, we don't need minispecs
 	if tc_version_is_at_least 6.0 ; then
 		return 0
 	fi
 
-	# setup the hardenedno* specs files and the vanilla specs file.
+	# Setup the hardenedno* specs files and the vanilla specs file.
 	if hardened_gcc_works ; then
 		create_gcc_env_entry hardenednopiessp
 	fi
@@ -2184,7 +2361,7 @@ gcc_slot_java() {
 	done
 
 	# Rename jar because it could clash with Kaffe's jar if this gcc is
-	# primary compiler (aka don't have the -<version> extension)
+	# primary compiler (aka doesn't have the -<version> extension)
 	cd "${D}${BINPATH}"
 	[[ -f jar ]] && mv -f jar gcj-jar
 }
@@ -2193,40 +2370,40 @@ gcc_slot_java() {
 
 toolchain_pkg_postinst() {
 	do_gcc_config
-	if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
+	if [[ ! ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
 		eselect compiler-shadow update all
 	fi
 
 	if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
 		# gcc stopped installing .la files fixer in June 2020.
 		# Cleaning can be removed in June 2022.
-		rm -f "${EROOT%/}"/sbin/fix_libtool_files.sh
-		rm -f "${EROOT%/}"/usr/sbin/fix_libtool_files.sh
-		rm -f "${EROOT%/}"/usr/share/gcc-data/fixlafiles.awk
+		rm -f "${EROOT}"/sbin/fix_libtool_files.sh
+		rm -f "${EROOT}"/usr/sbin/fix_libtool_files.sh
+		rm -f "${EROOT}"/usr/share/gcc-data/fixlafiles.awk
 	fi
 }
 
 toolchain_pkg_postrm() {
 	do_gcc_config
-	if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
+	if [[ ! ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
 		eselect compiler-shadow clean all
 	fi
 
-	# clean up the cruft left behind by cross-compilers
+	# Clean up the cruft left behind by cross-compilers
 	if is_crosscompile ; then
-		if [[ -z $(ls "${EROOT%/}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
+		if [[ -z $(ls "${EROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
 			einfo "Removing last cross-compiler instance. Deleting dangling symlinks."
-			rm -f "${EROOT%/}"/etc/env.d/gcc/config-${CTARGET}
-			rm -f "${EROOT%/}"/etc/env.d/??gcc-${CTARGET}
-			rm -f "${EROOT%/}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
+			rm -f "${EROOT}"/etc/env.d/gcc/config-${CTARGET}
+			rm -f "${EROOT}"/etc/env.d/??gcc-${CTARGET}
+			rm -f "${EROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
 		fi
 		return 0
 	fi
 
 	# gcc stopped installing .la files fixer in June 2020.
 	# Cleaning can be removed in June 2022.
-	rm -f "${EROOT%/}"/sbin/fix_libtool_files.sh
-	rm -f "${EROOT%/}"/usr/share/gcc-data/fixlafiles.awk
+	rm -f "${EROOT}"/sbin/fix_libtool_files.sh
+	rm -f "${EROOT}"/usr/share/gcc-data/fixlafiles.awk
 }
 
 do_gcc_config() {
@@ -2240,12 +2417,12 @@ do_gcc_config() {
 	current_gcc_config=$(env -i ROOT="${ROOT}" "${EPREFIX}"/usr/bin/gcc-config -c ${CTARGET} 2>/dev/null)
 	if [[ -n ${current_gcc_config} ]] ; then
 		local current_specs use_specs
-		# figure out which specs-specific config is active
+		# Figure out which specs-specific config is active
 		current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
 		[[ -n ${current_specs} ]] && use_specs=-${current_specs}
 
 		if [[ -n ${use_specs} ]] && \
-		   [[ ! -e ${EROOT%/}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
+		   [[ ! -e ${EROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
 		then
 			ewarn "The currently selected specs-specific gcc config,"
 			ewarn "${current_specs}, doesn't exist anymore. This is usually"
@@ -2258,7 +2435,7 @@ do_gcc_config() {
 		target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
 	else
 		# The curent target is invalid.  Attempt to switch to a valid one.
-		# Blindly pick the latest version.  #529608
+		# Blindly pick the latest version. bug #529608
 		# TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
 		# doing a partial grep like this.
 		target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
@@ -2273,9 +2450,9 @@ should_we_gcc_config() {
 	local curr_config
 	curr_config=$(env -i ROOT="${ROOT}" "${EPREFIX}"/usr/bin/gcc-config -c ${CTARGET} 2>&1) || return 0
 
-	# if the previously selected config has the same major.minor (branch) as
+	# If the previously selected config has the same major.minor (branch) as
 	# the version we are installing, then it will probably be uninstalled
-	# for being in the same SLOT, make sure we run gcc-config.
+	# for being in the same SLOT, so make sure we run gcc-config.
 	local curr_config_ver=$(env -i ROOT="${ROOT}" "${EPREFIX}"/usr/bin/gcc-config -S ${curr_config} | awk '{print $2}')
 
 	local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver})
@@ -2283,12 +2460,14 @@ should_we_gcc_config() {
 	if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
 		return 0
 	else
-		# if we're installing a genuinely different compiler version,
+		# If we're installing a genuinely different compiler version,
 		# we should probably tell the user -how- to switch to the new
-		# gcc version, since we're not going to do it for him/her.
+		# gcc version, since we're not going to do it for them.
+		#
 		# We don't want to switch from say gcc-3.3 to gcc-3.4 right in
 		# the middle of an emerge operation (like an 'emerge -e world'
 		# which could install multiple gcc versions).
+		#
 		# Only warn if we're installing a pkg as we might be called from
 		# the pkg_{pre,post}rm steps.  #446830
 		if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
@@ -2364,15 +2543,16 @@ is_go() {
 
 is_jit() {
 	gcc-lang-supported jit || return 1
+
 	# cross-compiler does not really support jit as it has
-	# to generate code for a target. On target like avr
+	# to generate code for a target. On targets like avr,
 	# libgcclit.so can't link at all: bug #594572
 	is_crosscompile && return 1
+
 	_tc_use_if_iuse jit
 }
 
 is_multilib() {
-	tc_version_is_at_least 3 || return 1
 	_tc_use_if_iuse multilib
 }
 
@@ -2395,7 +2575,7 @@ get_make_var() {
 
 XGCC() { get_make_var GCC_FOR_TARGET ; }
 
-# The gentoo piessp patches allow for 3 configurations:
+# The gentoo pie-ssp patches allow for 3 configurations:
 # 1) PIE+SSP by default
 # 2) PIE by default
 # 3) SSP by default
@@ -2404,8 +2584,6 @@ hardened_gcc_works() {
 		# $gcc_cv_ld_pie is unreliable as it simply take the output of
 		# `ld --help | grep -- -pie`, that reports the option in all cases, also if
 		# the loader doesn't actually load the resulting executables.
-		# To avoid breakage, blacklist FreeBSD here at least
-		[[ ${CTARGET} == *-freebsd* ]] && return 1
 
 		want_pie || return 1
 		_tc_use_if_iuse nopie && return 1
@@ -2427,17 +2605,9 @@ hardened_gcc_works() {
 hardened_gcc_is_stable() {
 	local tocheck
 	if [[ $1 == "pie" ]] ; then
-		if [[ ${CTARGET} == *-uclibc* ]] ; then
-			tocheck=${PIE_UCLIBC_STABLE}
-		else
-			tocheck=${PIE_GLIBC_STABLE}
-		fi
+		tocheck=${PIE_GLIBC_STABLE}
 	elif [[ $1 == "ssp" ]] ; then
-		if [[ ${CTARGET} == *-uclibc* ]] ; then
-			tocheck=${SSP_UCLIBC_STABLE}
-		elif  [[ ${CTARGET} == *-gnu* ]] ; then
-			tocheck=${SSP_STABLE}
-		fi
+		tocheck=${SSP_STABLE}
 	else
 		die "hardened_gcc_stable needs to be called with pie or ssp"
 	fi
@@ -2447,7 +2617,7 @@ hardened_gcc_is_stable() {
 }
 
 want_minispecs() {
-	# on gcc 6 we don't need minispecs
+	# On gcc 6, we don't need minispecs
 	if tc_version_is_at_least 6.0 ; then
 		return 0
 	fi
@@ -2495,6 +2665,11 @@ toolchain_death_notice() {
 	fi
 }
 
+fi
+
+EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
+	src_compile src_test src_install pkg_postinst pkg_postrm
+
 # Note [implicitly enabled flags]
 # -------------------------------
 # Usually configure-based packages handle explicit feature requests


             reply	other threads:[~2022-06-06  8:42 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06  8:42 Fabian Groffen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-30  9:08 [gentoo-commits] repo/proj/prefix:master commit in: eclass/ Fabian Groffen
2024-09-23 18:25 Fabian Groffen
2024-08-11 16:19 Fabian Groffen
2024-08-10 14:43 Fabian Groffen
2024-08-10 14:24 Fabian Groffen
2024-08-10 14:24 Fabian Groffen
2024-08-10 10:48 Fabian Groffen
2024-08-09  9:25 Fabian Groffen
2024-08-07 17:08 Fabian Groffen
2024-08-07 17:03 Fabian Groffen
2024-07-25  6:25 Fabian Groffen
2024-07-17 12:01 Fabian Groffen
2024-05-09  7:14 Fabian Groffen
2024-01-21 13:47 Fabian Groffen
2024-01-21 13:43 Fabian Groffen
2024-01-21 13:40 Fabian Groffen
2023-12-16 15:36 Fabian Groffen
2023-09-11 23:33 Sam James
2023-09-04  6:36 Fabian Groffen
2023-09-03 19:39 Fabian Groffen
2023-05-24  7:55 Fabian Groffen
2023-05-24  6:19 Fabian Groffen
2022-06-29 14:53 Sam James
2022-06-29 14:05 Sam James
2022-06-07 17:01 Fabian Groffen
2022-06-07 12:35 Fabian Groffen
2022-06-06 16:51 Fabian Groffen
2022-06-06  9:07 Fabian Groffen
2022-05-10  6:22 Fabian Groffen
2022-02-17  0:12 Sam James
2022-02-10  8:54 Fabian Groffen
2022-01-31  1:07 Sam James
2022-01-23  2:27 Sam James
2022-01-23  1:21 Sam James
2021-12-03 10:03 Fabian Groffen
2021-10-21  6:39 Fabian Groffen
2021-10-14  6:15 Sam James
2021-10-14  6:15 Sam James
2021-10-13  4:05 Sam James
2021-07-13  9:02 Fabian Groffen
2021-06-29  6:48 Fabian Groffen
2021-06-29  6:23 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:09 Fabian Groffen
2021-04-10  7:15 Sam James
2021-04-10  7:15 Sam James
2021-04-10  7:15 Sam James
2021-04-10  7:09 Sam James
2021-03-13  9:54 Fabian Groffen
2021-02-07 19:23 Fabian Groffen
2021-01-24  9:47 Fabian Groffen
2021-01-14  8:02 Fabian Groffen
2021-01-12 13:32 Fabian Groffen
2021-01-11 19:53 Fabian Groffen
2020-12-15  7:48 Fabian Groffen
2020-11-29 14:24 Fabian Groffen
2020-11-29 13:41 Fabian Groffen
2020-08-09  8:14 Fabian Groffen
2020-06-22 18:28 Fabian Groffen
2020-06-22 13:56 Fabian Groffen
2020-05-26  6:44 Fabian Groffen
2020-03-26  7:56 Fabian Groffen
2020-03-22  9:25 Fabian Groffen
2020-03-16 17:23 Michael Haubenwallner
2020-03-13  7:51 Fabian Groffen
2019-12-11  9:47 Fabian Groffen
2019-11-14  6:36 Fabian Groffen
2019-05-30  8:25 Fabian Groffen
2019-03-25 14:20 Michael Haubenwallner
2018-12-17  9:55 Fabian Groffen
2018-07-17  8:45 Fabian Groffen
2018-07-03  8:52 Michael Haubenwallner
2018-06-22 13:16 Michael Haubenwallner
2018-06-20  7:32 Fabian Groffen
2018-06-06 12:48 Fabian Groffen
2017-12-12 18:53 Fabian Groffen
2017-12-12 18:53 Fabian Groffen
2017-10-17  8:39 Fabian Groffen
2017-10-16 13:54 Fabian Groffen
2017-10-03  7:38 Michael Haubenwallner
2016-07-08 11:17 Fabian Groffen
2016-06-15 11:32 [gentoo-commits] repo/proj/prefix:rap0 " Benda XU
2016-06-15 11:05 ` [gentoo-commits] repo/proj/prefix:master " Benda XU
2016-04-18  8:07 Michael Haubenwallner
2016-03-20 18:22 Fabian Groffen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1654504897.5027081b510a47cbccec3cabd2dc6504b0484821.grobian@gentoo \
    --to=grobian@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox