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: Sun,  3 Sep 2023 19:39:49 +0000 (UTC)	[thread overview]
Message-ID: <1693769968.cbcf8a9a914d88f8c61f27e1343776159a97d218.grobian@gentoo> (raw)

commit:     cbcf8a9a914d88f8c61f27e1343776159a97d218
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Sep  3 19:39:28 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Sep  3 19:39:28 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=cbcf8a9a

toolchain.eclass: sync from gx86

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

 eclass/toolchain.eclass | 1075 ++++++++++++++++++-----------------------------
 1 file changed, 410 insertions(+), 665 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 642bf54a89..ce62b7b81d 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: toolchain.eclass
@@ -6,14 +6,17 @@
 # Toolchain Ninjas <toolchain@gentoo.org>
 # @SUPPORTED_EAPIS: 7 8
 # @BLURB: Common code for sys-devel/gcc ebuilds
+# @DESCRIPTION:
+# Common code for sys-devel/gcc ebuilds (and occasionally GCC forks, like
+# GNAT for Ada). If not building GCC itself, please use toolchain-funcs.eclass
+# instead.
 
 case ${EAPI} in
-	7) inherit eutils ;;
-	8) ;;
+	7|8) ;;
 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
-if [[ ! ${_TOOLCHAIN_ECLASS} ]]; then
+if [[ -z ${_TOOLCHAIN_ECLASS} ]]; then
 _TOOLCHAIN_ECLASS=1
 
 DESCRIPTION="The GNU Compiler Collection"
@@ -49,9 +52,9 @@ if [[ ${CTARGET} = ${CHOST} ]] ; then
 		export CTARGET=${CATEGORY#cross-}
 	fi
 fi
-: ${TARGET_ABI:=${ABI}}
-: ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
-: ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
+: "${TARGET_ABI:=${ABI}}"
+: "${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}"
+: "${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}"
 
 is_crosscompile() {
 	[[ ${CHOST} != ${CTARGET} ]]
@@ -141,6 +144,32 @@ GCCMINOR=$(ver_cut 2 ${GCC_PV})
 # GCC micro version.
 GCCMICRO=$(ver_cut 3 ${GCC_PV})
 
+tc_use_major_version_only() {
+	local use_major_version_only=0
+
+	if ! tc_version_is_at_least 10 ; then
+		return 1
+	fi
+
+	if [[ ${GCCMAJOR} -eq 10 ]] && ver_test ${PV} -ge 10.4.1_p20220929 ; then
+		use_major_version_only=1
+	elif [[ ${GCCMAJOR} -eq 11 ]] && ver_test ${PV} -ge 11.3.1_p20220930 ; then
+		use_major_version_only=1
+	elif [[ ${GCCMAJOR} -eq 12 ]] && ver_test ${PV} -ge 12.2.1_p20221001 ; then
+		use_major_version_only=1
+	elif [[ ${GCCMAJOR} -eq 13 ]] && ver_test ${PV} -ge 13.0.0_pre20221002 ; then
+		use_major_version_only=1
+	elif [[ ${GCCMAJOR} -gt 13 ]] ; then
+		use_major_version_only=1
+	fi
+
+	if [[ ${use_major_version_only} -eq 1 ]] ; then
+		return 0
+	fi
+
+	return 1
+}
+
 # @ECLASS_VARIABLE: GCC_CONFIG_VER
 # @INTERNAL
 # @DESCRIPTION:
@@ -148,7 +177,11 @@ GCCMICRO=$(ver_cut 3 ${GCC_PV})
 # of binary and gcc-config names not directly tied to upstream
 # versioning. In practice it's hard to untangle from gcc/BASE-VER
 # (GCC_RELEASE_VER) value.
-GCC_CONFIG_VER=${GCC_RELEASE_VER}
+if tc_use_major_version_only ; then
+	GCC_CONFIG_VER=${GCCMAJOR}
+else
+	GCC_CONFIG_VER=${GCC_RELEASE_VER}
+fi
 
 # Pre-release support. Versioning schema:
 # 1.0.0_pre9999: live ebuild
@@ -168,7 +201,7 @@ 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."
+tc_version_is_at_least 8 || die "${ECLASS}: ${GCC_RELEASE_VER} is too old."
 
 PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
 
@@ -204,49 +237,46 @@ tc_has_feature() {
 if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ||
 	[[ ${PN} == "gcc-apple" && $(tc_version_is_at_least 12.1) == 0 ]] ; then
 	IUSE+=" debug +cxx +nptl" TC_FEATURES+=( nptl )
-	[[ -n ${PIE_VER} ]] && IUSE+=" nopie"
-	[[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
 	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_FEATURES+=( sanitize )
-
-	# Note:
-	#   <gcc-4.8 supported graphite, it required forked ppl
-	#     versions which we dropped.  Since graphite was also experimental in
-	#     the older versions, we don't want to bother supporting it.  #448024
-	#   <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 )
-
-	tc_version_is_between 4.9 8 && IUSE+=" cilk"
-	tc_version_is_at_least 4.9 && IUSE+=" ada"
-	tc_version_is_at_least 4.9 && IUSE+=" vtv"
-	tc_version_is_at_least 5.0 && IUSE+=" jit"
+
+	# Stop forcing openmp on by default in the eclass. Gradually phase it out.
+	# See bug #890999.
+	if tc_version_is_at_least 13.0.0_pre20221218 ; then
+		IUSE+=" openmp"
+	else
+		IUSE+=" +openmp"
+	fi
+
+	IUSE+=" fixed-point"
+	IUSE+=" go"
+	IUSE+=" +sanitize"  TC_FEATURES+=( sanitize )
+	IUSE+=" graphite" TC_FEATURES+=( graphite )
+	IUSE+=" ada"
+	IUSE+=" vtv"
+	IUSE+=" jit"
 	tc_version_is_between 5.0 9 && IUSE+=" mpx"
-	tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
+	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.0 && IUSE+=" d" TC_FEATURES+=( d )
 	tc_version_is_at_least 9.1 && IUSE+=" lto"
 	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"
+	tc_version_is_at_least 12 && IUSE+=" ieee-long-double"
+	tc_version_is_at_least 12.2.1_p20221203 ${PV} && IUSE+=" default-znow"
+	tc_version_is_at_least 12.2.1_p20221203 ${PV} && IUSE+=" default-stack-clash-protection"
+	tc_version_is_at_least 13.0.0_pre20221218 ${PV} && IUSE+=" modula2"
+	# See https://gcc.gnu.org/pipermail/gcc-patches/2023-April/615944.html
+	# and https://rust-gcc.github.io/2023/04/24/gccrs-and-gcc13-release.html for why
+	# it was disabled in 13.
+	tc_version_is_at_least 14.0.0_pre20230423 ${PV} && IUSE+=" rust"
 fi
 
 if tc_version_is_at_least 10; then
@@ -259,24 +289,18 @@ fi
 
 #---->> DEPEND <<----
 
-RDEPEND="sys-libs/zlib
+RDEPEND="
+	sys-libs/zlib
 	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="
+RDEPEND+=" ${GMP_MPFR_DEPS}"
+RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
 
 if tc_has_feature objc-gc ; then
-	if tc_version_is_at_least 7 ; then
-		RDEPEND+=" objc-gc? ( >=dev-libs/boehm-gc-7.4.2 )"
-	fi
+	RDEPEND+=" objc-gc? ( >=dev-libs/boehm-gc-7.4.2 )"
 fi
 
 if tc_has_feature graphite ; then
@@ -290,26 +314,15 @@ BDEPEND="
 	test? (
 		>=dev-util/dejagnu-1.4.4
 		>=sys-devel/autogen-5.5.4
-	)"
+	)
+"
 DEPEND="${RDEPEND}"
 
-if tc_has_feature gcj ; then
-	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
-			)
-		)
-	"
+if [[ ${PN} == gcc && ${PV} == *_p* ]] ; then
+	# Snapshots don't contain info pages.
+	# If they start to, adjust gcc_cv_prog_makeinfo_modern logic in toolchain_src_configure.
+	# Needed unless/until https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106899 is fixed
+	BDEPEND+=" sys-apps/texinfo"
 fi
 
 if tc_has_feature sanitize ; then
@@ -329,12 +342,26 @@ if tc_has_feature zstd ; then
 	RDEPEND+=" zstd? ( app-arch/zstd:= )"
 fi
 
-if tc_has_feature valgrind; then
+if tc_has_feature valgrind ; then
 	BDEPEND+=" valgrind? ( dev-util/valgrind )"
 fi
 
-# Prefix: our version is 1.9, so can't go with gx86's 2.3
-PDEPEND=">=sys-devel/gcc-config-1.9"
+# TODO: Add a pkg_setup & pkg_pretend check for whether the active compiler
+# supports Ada.
+if tc_has_feature ada ; then
+	BDEPEND+=" ada? ( || ( sys-devel/gcc[ada] dev-lang/gnat-gpl[ada] ) )"
+fi
+
+# TODO: Add a pkg_setup & pkg_pretend check for whether the active compiler
+# supports D.
+if tc_has_feature d && tc_version_is_at_least 12.0 ; then
+	# D in 12+ is self-hosting and needs D to bootstrap.
+	# TODO: package some binary we can use, like for Ada
+	# bug #840182
+	BDEPEND+=" d? ( || ( sys-devel/gcc[d(-)] <sys-devel/gcc-12[d(-)] ) )"
+fi
+
+PDEPEND=">=sys-devel/gcc-config-2.3"
 
 #---->> S + SRC_URI essentials <<----
 
@@ -343,38 +370,39 @@ PDEPEND=">=sys-devel/gcc-config-1.9"
 # 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}
+	: "${TOOLCHAIN_PATCH_SUFFIX:=xz}"
 else
 	# Older EAPIs
-	: ${TOOLCHAIN_PATCH_SUFFIX:=bz2}
+	: "${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}
+: "${TOOLCHAIN_SET_S:=yes}"
 
 # Set the source directory depending on whether we're using
 # a live git tree, snapshot, or release tarball.
 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
-	)
+	if tc_is_live ; then
+		S=${EGIT_CHECKOUT_DIR}
+	elif [[ -n ${SNAPSHOT} ]] ; then
+		S=${WORKDIR}/gcc-${SNAPSHOT}
+	else
+		S=${WORKDIR}/gcc-${GCC_RELEASE_VER}
+	fi
 fi
 
 gentoo_urls() {
+	# the list is sorted by likelihood of getting the patches tarball from
+	# respective devspace
 	# 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
+		[xen0n]=HTTP~xen0n/distfiles/sys-devel/gcc/URI
 		[tamiko]=HTTP~tamiko/distfiles/URI
 		[zorry]=HTTP~zorry/patches/gcc/URI
 		[vapier]=HTTP~vapier/dist/URI
@@ -402,7 +430,8 @@ gentoo_urls() {
 		HTTP~tamiko/distfiles/URI
 		HTTP~zorry/patches/gcc/URI
 		HTTP~vapier/dist/URI
-		HTTP~blueness/dist/URI"
+		HTTP~blueness/dist/URI
+	"
 	devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
 	echo ${devspace//URI/$1} mirror://gentoo/$1
 }
@@ -431,43 +460,9 @@ gentoo_urls() {
 #			The resulting filename of this tarball will be:
 #			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 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.xz
-#
-#	SPECS_VER
-#	SPECS_GCC_VER
-#			This is for the minispecs files included in the hardened gcc-4.x
-#			The specs files for hardenedno*, vanilla and for building the "specs" file.
-#			SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
-#			the gcc version of the patch.
-#			An example:
-#					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.xz
-#
-#	CYGWINPORTS_GITREV
-#			If set, this variable signals that we should apply additional patches
-#			maintained by upstream Cygwin developers at github/cygwinports/gcc,
-#			using the specified git commit id there.  The list of patches to
-#			apply is extracted from gcc.cygport, maintained there as well.
-#			This is done for compilers running on Cygwin, not for cross compilers
-#			with a Cygwin target.
 get_gcc_src_uri() {
 	export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_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}}
 
 	# Set where to download gcc itself depending on whether we're using a
 	# live git tree, snapshot, or release tarball.
@@ -477,13 +472,12 @@ get_gcc_src_uri() {
 		# 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="https://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz"
+		GCC_SRC_URI="mirror://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"
-		else
-			GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
-		fi
+		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
+		"
 	fi
 
 	[[ -n ${PATCH_VER} ]] && \
@@ -491,27 +485,6 @@ get_gcc_src_uri() {
 	[[ -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.${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.${TOOLCHAIN_PATCH_SUFFIX})"
-
-	if tc_has_feature gcj ; then
-		if tc_version_is_at_least 4.5 ; then
-			GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
-		elif tc_version_is_at_least 4.3 ; then
-			GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
-		fi
-	fi
-
-	# Cygwin patches from https://github.com/cygwinports/gcc
-	[[ -n ${CYGWINPORTS_GITREV} ]] && \
-		GCC_SRC_URI+=" elibc_Cygwin? ( https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.tar.gz
-			-> gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz )"
-
 	echo "${GCC_SRC_URI}"
 }
 
@@ -525,11 +498,7 @@ toolchain_pkg_pretend() {
 			ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
 		_tc_use_if_iuse objc++ && \
 			ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
-		_tc_use_if_iuse gcj && \
-			ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
 	fi
-
-	want_minispecs
 }
 
 #---->> pkg_setup <<----
@@ -584,6 +553,11 @@ toolchain_src_unpack() {
 	if tc_is_live ; then
 		git-r3_src_unpack
 
+		# Needed for gcc --version to include the upstream commit used
+		# rather than only the commit after we apply our patches.
+		# It includes both with this.
+		echo "${EGIT_VERSION}" > "${S}"/gcc/REVISION || die
+
 		if [[ -z ${PATCH_VER} ]] && ! use vanilla ; then
 			toolchain_fetch_git_patches
 		fi
@@ -601,8 +575,6 @@ toolchain_src_prepare() {
 	cd "${S}" || die
 
 	do_gcc_gentoo_patches
-	do_gcc_PIE_patches
-	do_gcc_CYGWINPORTS_patches
 
 	if tc_is_live ; then
 		BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, commit ${EGIT_VERSION}"
@@ -610,9 +582,8 @@ toolchain_src_prepare() {
 
 	eapply_user
 
-	if ( tc_version_is_at_least 4.8.2 || _tc_use_if_iuse hardened ) \
-		   && ! use vanilla ; then
-		make_gcc_hard
+	if ! use vanilla ; then
+		tc_enable_hardened_gcc
 	fi
 
 	# we use our libtool on Darwin (no longer applies since 12)
@@ -634,7 +605,6 @@ toolchain_src_prepare() {
 		-exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} + || die
 
 	setup_multilib_osdirnames
-	gcc_version_patch
 
 	local actual_version=$(< "${S}"/gcc/BASE-VER)
 	if [[ "${GCC_RELEASE_VER}" != "${actual_version}" ]] ; then
@@ -642,23 +612,6 @@ toolchain_src_prepare() {
 		die "Please set 'TOOLCHAIN_GCC_PV' to '${actual_version}'"
 	fi
 
-	# >= gcc-4.3 doesn't bundle ecj.jar, so copy it
-	if tc_version_is_at_least 4.3 && _tc_use_if_iuse gcj ; then
-		if tc_version_is_at_least 4.5 ; then
-			einfo "Copying ecj-4.5.jar"
-			cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
-		else
-			einfo "Copying ecj-4.3.jar"
-			cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
-		fi
-	fi
-
-	# Prevent libffi from being installed
-	if tc_version_is_between 3.0 4.8 ; then
-		sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in || die
-		sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in || die
-	fi
-
 	# Fixup libtool to correctly generate .la files with portage
 	elibtoolize --portage --shallow --no-uclibc
 
@@ -673,21 +626,25 @@ toolchain_src_prepare() {
 			|| eerror "Please file a bug about this"
 		eend $?
 	done
-	# bug #215828
-	sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die
-
-	# 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
-		einfo "Touching generated files"
-		./contrib/gcc_update --touch | \
-			while read f ; do
-				einfo "  ${f%%...}"
-			done
+
+	if ! use prefix-guest && [[ -n ${EPREFIX} ]] ; then
+		einfo "Prefixifying dynamic linkers..."
+		for f in gcc/config/*/*linux*.h ; do
+			ebegin "  Updating ${f}"
+			if [[ ${f} == gcc/config/rs6000/linux*.h ]]; then
+				sed -i -r "s,(DYNAMIC_LINKER_PREFIX\s+)\"\",\1\"${EPREFIX}\",g" "${f}" || die
+			else
+				sed -i -r "/_DYNAMIC_LINKER/s,([\":])(/lib),\1${EPREFIX}\2,g" "${f}" || die
+			fi
+			eend $?
+		done
 	fi
+
+	einfo "Touching generated files"
+	./contrib/gcc_update --touch | \
+		while read f ; do
+			einfo "  ${f%%...}"
+		done
 }
 
 do_gcc_gentoo_patches() {
@@ -718,93 +675,47 @@ do_gcc_gentoo_patches() {
 	fi
 }
 
-do_gcc_PIE_patches() {
-	want_pie || return 0
-	use vanilla && return 0
-
-	einfo "Applying PIE patches ..."
-	eapply "${WORKDIR}"/piepatch/*.patch
+# configure to build with the hardened GCC specs as the default
+tc_enable_hardened_gcc() {
+	local hardened_gcc_flags=""
 
-	BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
-}
+	if _tc_use_if_iuse pie ; then
+		einfo "Updating gcc to use automatic PIE building ..."
+	fi
 
-do_gcc_CYGWINPORTS_patches() {
-	[[ -n ${CYGWINPORTS_GITREV} ]] || return 0
-	use elibc_Cygwin || return 0
-
-	local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
-	# 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
-		); do
-			echo "${d}/${p}"
-		done
-	) )
-	einfo "Applying cygwin port patches ..."
-	eapply -- "${patches[@]}"
-}
+	if _tc_use_if_iuse ssp ; then
+		einfo "Updating gcc to use automatic SSP building ..."
+	fi
 
-# configure to build with the hardened GCC specs as the default
-make_gcc_hard() {
-	local gcc_hard_flags=""
+	if _tc_use_if_iuse default-stack-clash-protection ; then
+		# The define DEF_GENTOO_SCP is checked in 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
+		einfo "Updating gcc to use automatic stack clash protection ..."
+		hardened_gcc_flags+=" -DDEF_GENTOO_SCP"
+	fi
 
-	# 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
+	if _tc_use_if_iuse default-znow ; then
+		# The define DEF_GENTOO_ZNOW is checked in 23_all_DEF_GENTOO_ZNOW-z-now.patch
+		einfo "Updating gcc to request symbol resolution at start (-z now) ..."
+		hardened_gcc_flags+=" -DDEF_GENTOO_ZNOW"
 	fi
 
-	# 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 ..."
-		fi
-		if _tc_use_if_iuse ssp ; then
-			einfo "Updating gcc to use automatic SSP building ..."
-		fi
-		if _tc_use_if_iuse hardened ; then
-			# Will add some hardened options as default, like:
-			# * -fstack-clash-protection
-			# * -z now
-			# See gcc *_all_extra-options.patch patches.
-			gcc_hard_flags+=" -DEXTRA_OPTIONS"
-
-			if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux* ]] ; then
-				gcc_hard_flags+=" -DEXTRA_OPTIONS_CF"
-			fi
+	if _tc_use_if_iuse hardened ; then
+		# Will add some hardened options as default, e.g. for gcc-12
+		# * -fstack-clash-protection
+		# * -z now
+		# See gcc *_all_extra-options.patch patches.
+		hardened_gcc_flags+=" -DEXTRA_OPTIONS"
+		# Default to -D_FORTIFY_SOURCE=3 instead of -D_FORTIFY_SOURCE=2
+		hardened_gcc_flags+=" -DGENTOO_FORTIFY_SOURCE_LEVEL=3"
+		# Add -D_GLIBCXX_ASSERTIONS
+		hardened_gcc_flags+=" -DDEF_GENTOO_GLIBCXX_ASSERTIONS"
 
-			# 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
-			BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
-			if hardened_gcc_works ; then
-				einfo "Updating gcc to use automatic PIE + SSP building ..."
-				gcc_hard_flags+=" -DEFAULT_PIE_SSP"
-			elif hardened_gcc_works pie ; then
-				einfo "Updating gcc to use automatic PIE building ..."
-				ewarn "SSP has not been enabled by default"
-				gcc_hard_flags+=" -DEFAULT_PIE"
-			elif hardened_gcc_works ssp ; then
-				einfo "Updating gcc to use automatic SSP building ..."
-				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
-				ewarn "hardened is not supported for this arch in this gcc version"
-				return 0
-			fi
-		else
-			if hardened_gcc_works ssp ; then
-				einfo "Updating gcc to use automatic SSP building ..."
-				gcc_hard_flags+=" -DEFAULT_SSP"
-			fi
+		if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux* ]] ; then
+			hardened_gcc_flags+=" -DEXTRA_OPTIONS_CF"
 		fi
+
+		# Rebrand to make bug reports easier
+		BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
 	fi
 
 	# We want to be able to control the PIE patch logic via something other
@@ -812,15 +723,13 @@ make_gcc_hard() {
 	sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
 		-e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
 		-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 || die
-	fi
+
+	sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
+		-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
+		-i "${S}"/gcc/Makefile.in || die
 
 	sed -i \
-		-e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
+		-e "/^HARD_CFLAGS = /s|=|= ${hardened_gcc_flags} |" \
 		"${S}"/gcc/Makefile.in || die
 
 }
@@ -832,7 +741,7 @@ make_gcc_hard() {
 # Most other distros use the logic (including mainline gcc):
 #    lib   - 32bit binaries (x86)
 #    lib64 - 64bit binaries (x86_64)
-# Over time, Gentoo is migrating to the latter form.
+# Over time, Gentoo is migrating to the latter form (17.1 profiles).
 #
 # Unfortunately, due to distros picking the lib32 behavior, newer gcc
 # versions will dynamically detect whether to use lib or lib32 for its
@@ -856,16 +765,10 @@ setup_multilib_osdirnames() {
 	config+="/t-linux64"
 
 	local sed_args=()
-	if tc_version_is_at_least 4.6 ; then
-		sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
-	fi
+	sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
 	if [[ ${SYMLINK_LIB} == "yes" ]] ; then
 		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
+		sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
 	else
 		einfo "Using upstream multilib; disabling lib32 autodetection"
 		sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
@@ -873,30 +776,18 @@ setup_multilib_osdirnames() {
 	sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
 }
 
-gcc_version_patch() {
-	# gcc-4.3+ has configure flags (whoo!)
-	tc_version_is_at_least 4.3 && return 0
-
-	local version_string=${GCC_RELEASE_VER}
-
-	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
-		gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
-	else
-		version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
-		gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
-	fi
-	sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
-}
-
 #---->> src_configure <<----
 
 toolchain_src_configure() {
 	downgrade_arch_flags
 	gcc_do_filter_flags
 
+	if ! tc_version_is_at_least 11 && [[ $(gcc-major-version) -ge 12 ]] ; then
+		# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105695
+		# bug #849359
+		export ac_cv_std_swap_in_utility=no
+	fi
+
 	einfo "CFLAGS=\"${CFLAGS}\""
 	einfo "CXXFLAGS=\"${CXXFLAGS}\""
 	einfo "LDFLAGS=\"${LDFLAGS}\""
@@ -905,12 +796,6 @@ toolchain_src_configure() {
 	# issues with 3rd party jar implementations. bug #384291
 	export JAR=no
 
-	# 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
-	fi
-
 	local confgcc=( --host=${CHOST} )
 
 	local build_config_targets=()
@@ -932,8 +817,19 @@ toolchain_src_configure() {
 		--mandir="${DATAPATH}/man"
 		--infodir="${DATAPATH}/info"
 		--with-gxx-include-dir="${STDCXX_INCDIR}"
+
+		# portage's econf() does not detect presence of --d-s-r
+		# because it greps only top-level ./configure. But not
+		# libiberty's or gcc's configure.
+		--disable-silent-rules
 	)
 
+	if tc_version_is_at_least 10 ; then
+		confgcc+=(
+			--disable-dependency-tracking
+		)
+	fi
+
 	# Stick the python scripts in their own slotted directory (bug #279252)
 	#
 	#  --with-python-dir=DIR
@@ -943,16 +839,13 @@ toolchain_src_configure() {
 	#  then --with-python-dir=/lib/python2.5/site-packages should be passed.
 	#
 	# This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
-	if tc_version_is_at_least 4.4 ; then
-		confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
-	fi
+	confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
 
 	### language options
 
 	local GCC_LANG="c"
 	is_cxx && GCC_LANG+=",c++"
 	is_d   && GCC_LANG+=",d"
-	is_gcj && GCC_LANG+=",java"
 	is_go  && GCC_LANG+=",go"
 	if is_objc || is_objcxx ; then
 		GCC_LANG+=",objc"
@@ -966,8 +859,9 @@ toolchain_src_configure() {
 	is_fortran && GCC_LANG+=",fortran"
 	is_f77 && GCC_LANG+=",f77"
 	is_f95 && GCC_LANG+=",f95"
-
 	is_ada && GCC_LANG+=",ada"
+	is_modula2 && GCC_LANG+=",m2"
+	is_rust && GCC_LANG+=",rust"
 
 	confgcc+=( --enable-languages=${GCC_LANG} )
 
@@ -988,32 +882,46 @@ toolchain_src_configure() {
 
 	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 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})}" )
+		# Non-released versions get extra checks, follow configure.ac's default to for those
+		# unless USE=debug. Note that snapshots on stable branches don't count as "non-released"
+		# for these purposes.
+		if grep -q "experimental" gcc/DEV-PHASE ; then
+			# - USE=debug for pre-releases: yes,extra,rtl
+			# - USE=-debug for pre-releases: yes,extra (following upstream default)
+			confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes,extra,rtl yes,extra)}" )
+		else
+			# - Use the default ("release") checking because upstream usually neglects
+			#   to test "disabled" so it has a history of breaking. bug #317217.
+			# - The "release" keyword is new to 4.0. bug #551636.
+			# - After discussing in #gcc, we concluded that =yes,extra,rtl makes
+			#   more sense when a user explicitly requests USE=debug. If rtl is too slow,
+			#   we can change this to yes,extra.
+			confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes,extra,rtl release)}" )
+		fi
 	fi
 
 	# Branding
-	tc_version_is_at_least 4.3 && confgcc+=(
+	confgcc+=(
 		--with-bugurl=https://bugs.gentoo.org/
 		--with-pkgversion="${BRANDING_GCC_PKGVERSION}"
 	)
 
-	# 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) )
+	if tc_use_major_version_only ; then
+		confgcc+=( --with-gcc-major-version-only )
 	fi
 
 	# 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
+	if is_cxx ; then
 		confgcc+=( --enable-libstdcxx-time )
 	fi
 
+	# This only controls whether the compiler *supports* LTO, not whether
+	# it's *built using* LTO. Hence we do it without a USE flag.
+	confgcc+=( --enable-lto )
+
 	# Build compiler itself using LTO
 	if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then
 		build_config_targets+=( bootstrap-lto )
@@ -1024,7 +932,7 @@ toolchain_src_configure() {
 	fi
 
 	# Support to disable PCH when building libstdcxx
-	if tc_version_is_at_least 6.0 && ! _tc_use_if_iuse pch ; then
+	if ! _tc_use_if_iuse pch ; then
 		confgcc+=( --disable-libstdcxx-pch )
 	fi
 
@@ -1040,12 +948,6 @@ toolchain_src_configure() {
 	# 	;;
 	# esac
 
-	# 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 )
-	fi
-
 	### Cross-compiler options
 	if is_crosscompile ; then
 		# Enable build warnings by default with cross-compilers when system
@@ -1079,15 +981,15 @@ toolchain_src_configure() {
 			*-musl*)
 				needed_libc=musl
 				;;
-			*-cygwin)
-				needed_libc=cygwin
-				;;
 			x86_64-*-mingw*|*-w64-mingw*)
 				needed_libc=mingw64-runtime
 				;;
 			avr)
 				confgcc+=( --enable-shared --disable-threads )
 				;;
+			nvptx*)
+				# "LTO is not supported for this target"
+				confgcc+=( --disable-lto )
 			# Prefix targets
 			*-apple-darwin*)
 				confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}" )
@@ -1095,17 +997,14 @@ toolchain_src_configure() {
 			*-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 )
+			confgcc_no_libc+=( --disable-libquadmath )
 			# requires libc
-			tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
+			confgcc_no_libc+=( --disable-libatomic )
 
 			if ! has_version ${CATEGORY}/${needed_libc} ; then
 				confgcc+=(
@@ -1132,7 +1031,13 @@ toolchain_src_configure() {
 			fi
 		fi
 
-		confgcc+=( --disable-bootstrap )
+		confgcc+=(
+			# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100289
+			# TOOD: Find a way to disable this just for stage1 cross?
+			--disable-gcov
+
+			--disable-bootstrap
+		)
 	else
 		if tc-is-static-only ; then
 			confgcc+=( --disable-shared )
@@ -1148,7 +1053,20 @@ toolchain_src_configure() {
 				;;
 		esac
 
-		if use prefix ; then
+		if ! use prefix-guest ; then
+			# GNU ld scripts, such as those in glibc, reference unprefixed paths
+			# as the sysroot given here is automatically prepended. For
+			# prefix-guest, we use the host's libc instead.
+			if [[ -n ${EPREFIX} ]] ; then
+				confgcc+=( --with-sysroot="${EPREFIX}" )
+			fi
+
+			# We need to build against the right headers and libraries. Again,
+			# for prefix-guest, this is the host's.
+			if [[ -n ${ESYSROOT} ]] ; then
+				confgcc+=( --with-build-sysroot="${ESYSROOT}" )
+			fi
+		elif use prefix ; then
 			# should be /usr, because it's the path to search includes
 			# for, which is unrelated to TOOLCHAIN_PREFIX, a.k.a.
 			# PREFIX
@@ -1190,7 +1108,7 @@ toolchain_src_configure() {
 	# gcc has fixed-point arithmetic support in 4.3 for mips targets that can
 	# significantly increase compile time by several hours.  This will allow
 	# users to control this feature in the event they need the support.
-	tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
+	in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
 
 	case $(tc-is-softfloat) in
 		yes)
@@ -1222,13 +1140,11 @@ toolchain_src_configure() {
 				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
+				. "${srcdir}"/config.gcc) &>/dev/null
 			then
 				confgcc+=( --with-arch=${arm_arch} )
 			fi
@@ -1237,10 +1153,7 @@ toolchain_src_configure() {
 			[[ ${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
+			if [[ $(tc-is-softfloat) == "no" ]] && [[ ${CTARGET} == armv[67]* ]] ; then
 				# Follow the new arm hardfp distro standard by default
 				confgcc+=( --with-float=hard )
 				case ${CTARGET} in
@@ -1248,6 +1161,15 @@ toolchain_src_configure() {
 					armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
 				esac
 			fi
+
+			# If multilib is used, make the compiler build multilibs
+			# for A or R and M architecture profiles. Do this only
+			# when no specific arch/mode/float is specified, e.g.
+			# for target arm-none-eabi, since doing this is
+			# incompatible with --with-arch/cpu/float/fpu.
+			if is_multilib && [[ ${arm_arch} == arm ]] ; then
+				confgcc+=( --with-multilib-list=aprofile,rmprofile )
+			fi
 			;;
 		mips)
 			# Add --with-abi flags to set default ABI
@@ -1255,9 +1177,9 @@ toolchain_src_configure() {
 			;;
 
 		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
-			if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
+			if has x32 $(get_all_abis TARGET) ; then
 				confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
 			fi
 			;;
@@ -1266,10 +1188,6 @@ toolchain_src_configure() {
 			# 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 )
@@ -1284,6 +1202,13 @@ toolchain_src_configure() {
 			# - bug #704784
 			# - https://gcc.gnu.org/PR93157
 			[[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
+
+			if in_iuse ieee-long-double; then
+				# musl requires 64-bit long double, not IBM double-double or IEEE quad.
+				if [[ ${CTARGET} == powerpc64le-*-gnu ]]; then
+					use ieee-long-double && confgcc+=( --with-long-double-format=ieee )
+				fi
+			fi
 			;;
 		riscv)
 			# Add --with-abi flags to set default ABI
@@ -1295,19 +1220,15 @@ toolchain_src_configure() {
 	# be small, and should simplify building of 64bit kernels in a 32bit
 	# userland by not needing sys-devel/kgcc64. bug #349405
 	case $(tc-arch) in
-		ppc|ppc64)
+		amd64|ppc|ppc64|sparc|x86)
 			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
 
 	# 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
+	# for things like libobjc-gnu and libfortran.  If we enable it on
 	# non-Darwin we screw up the behaviour this eclass relies on.  We in
 	# particular need this over --libdir for bug #255315.
 	[[ ${CTARGET} == *-darwin* ]] && \
@@ -1315,15 +1236,6 @@ toolchain_src_configure() {
 
 	### library options
 
-	if tc_version_is_between 3.0 7.0 ; then
-		if is_gcj ; then
-			confgcc+=( --disable-gjdoc )
-			use awt && confgcc+=( --enable-java-awt=gtk )
-		else
-			confgcc+=( --disable-libgcj )
-		fi
-	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
@@ -1345,10 +1257,6 @@ toolchain_src_configure() {
 	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 the target libc does not provide
@@ -1402,50 +1310,52 @@ 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
-		confgcc+=( --disable-lto )
-	fi
-
 	# graphite was added in 4.4 but we only support it in 6.5+ due to external
 	# library issues. bug #448024, bug #701270
-	if tc_version_is_at_least 6.5 && in_iuse graphite ; then
+	if in_iuse graphite ; then
 		confgcc+=( $(use_with graphite isl) )
 		use graphite && confgcc+=( --disable-isl-version-check )
-	elif tc_version_is_at_least 5.0 ; then
+	else
 		confgcc+=( --without-isl )
-	elif tc_version_is_at_least 4.8 ; then
-		confgcc+=( --without-cloog )
-	elif tc_version_is_at_least 4.4 ; then
-		confgcc+=( --without-{cloog,ppl} )
 	fi
 
-	if tc_version_is_at_least 4.8; then
-		if in_iuse sanitize ; then
-			# See Note [implicitly enabled flags]
-			confgcc+=( $(usex sanitize '' --disable-libsanitizer) )
-		else
-			confgcc+=( --disable-libsanitizer )
-		fi
+	if in_iuse sanitize ; then
+		# See Note [implicitly enabled flags]
+		confgcc+=( $(usex sanitize '' --disable-libsanitizer) )
+	else
+		confgcc+=( --disable-libsanitizer )
 	fi
 
-	if tc_version_is_at_least 6.0 && in_iuse pie ; then
+	if in_iuse pie ; then
 		confgcc+=( $(use_enable pie default-pie) )
+
+		if tc_version_is_at_least 14.0.0_pre20230612 ${PV} ; then
+			confgcc+=( --enable-host-pie )
+		fi
+	fi
+
+	if in_iuse default-znow && tc_version_is_at_least 14.0.0_pre20230619 ${PV}; then
+		# See https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=33ebb0dff9bb022f1e0709e0e73faabfc3df7931.
+		# TODO: Add to LDFLAGS_FOR_TARGET?
+		confgcc+=(
+			$(use_enable default-znow host-bind-now)
+		)
 	fi
 
-	if tc_version_is_at_least 6.0 && in_iuse ssp ; then
+	if in_iuse ssp ; then
 		confgcc+=(
 			# This defaults to -fstack-protector-strong.
 			$(use_enable ssp default-ssp)
 		)
 	fi
 
-	# Disable gcc info regeneration -- it ships with generated info pages
-	# already.  Our custom version/urls/etc... trigger it. bug #464008
-	export gcc_cv_prog_makeinfo_modern=no
+	# TODO: Ignore RCs here (but TOOLCHAIN_IS_RC isn't yet an eclass var)
+	if [[ ${PV} == *_p* && -f "${S}"/gcc/doc/gcc.info ]] ; then
+		# Safeguard against https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106899 being fixed
+		# without corresponding ebuild changes.
+		eqawarn "Snapshot release with pre-generated info pages found!"
+		eqawarn "The BDEPEND in the ebuild should be updated to drop texinfo."
+	fi
 
 	# Do not let the X detection get in our way.  We know things can be found
 	# via system paths, so no need to hardcode things that'll break multilib.
@@ -1455,8 +1365,8 @@ toolchain_src_configure() {
 
 	confgcc+=( "$@" ${EXTRA_ECONF} )
 
-	if [[ -n ${build_config_targets} ]] ; then
-		# ./configure --with-build-config='bootstrap-lto bootstrap-cet'
+	if ! is_crosscompile && ! tc-is-cross-compiler && [[ -n ${build_config_targets} ]] ; then
+		# e.g. ./configure --with-build-config='bootstrap-lto bootstrap-cet'
 		confgcc+=( --with-build-config="${build_config_targets[*]}" )
 	fi
 
@@ -1529,6 +1439,7 @@ downgrade_arch_flags() {
 
 	# "added" "arch" "replacement"
 	local archlist=(
+		12.3 znver4 znver3
 		10 znver3 znver2
 		9 znver2 znver1
 		4.9 bdver4 bdver3
@@ -1637,6 +1548,9 @@ gcc_do_filter_flags() {
 		append-flags -O2
 	fi
 
+	# Please use USE=lto instead (bug #906007).
+	filter-lto
+
 	# Avoid shooting self in foot
 	filter-flags '-mabi*' -m31 -m32 -m64
 
@@ -1647,39 +1561,14 @@ gcc_do_filter_flags() {
 
 	filter-flags '-fsanitize=*'
 
-	if tc_version_is_between 6 8 ; then
-		# -mstackrealign triggers crashes in exception throwing
-		# at least on ada: bug #688580
-		# The reason is unknown. Drop the flag for now.
-		filter-flags -mstackrealign
-	fi
-
 	case $(tc-arch) in
 		amd64|x86)
 			filter-flags '-mcpu=*'
-
-			# bug #357287
-			tc_version_is_between 4.4 4.5 && append-flags -mno-avx
-
-			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
 
 	strip-unsupported-flags
@@ -1695,27 +1584,6 @@ gcc_do_filter_flags() {
 		local VAR="CFLAGS_"${CTARGET//[-.]/_}
 		CXXFLAGS=${!VAR-${CFLAGS}}
 	fi
-
-	export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
-}
-
-setup_minispecs_gcc_build_specs() {
-	# Setup the "build.specs" file for gcc 4.3 to use when building.
-	if hardened_gcc_works pie ; then
-		cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
-	fi
-
-	if hardened_gcc_works ssp ; then
-		for s in ssp sspall ; do
-			cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
-		done
-	fi
-
-	for s in nostrict znow ; do
-		cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
-	done
-
-	export GCC_SPECS="${WORKDIR}"/build.specs
 }
 
 gcc-multilib-configure() {
@@ -1739,7 +1607,7 @@ gcc-multilib-configure() {
 	if [[ -n ${list} ]] ; then
 		case ${CTARGET} in
 			x86_64*)
-				tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} )
+				confgcc+=( --with-multilib-list=${list:1} )
 			;;
 		esac
 	fi
@@ -1773,7 +1641,7 @@ toolchain_src_compile() {
 	touch "${S}"/gcc/c-gperf.h || die
 
 	# Do not make manpages if we do not have perl ...
-	[[ ! -x /usr/bin/perl ]] \
+	[[ ! -x "${BROOT}"/usr/bin/perl ]] \
 		&& find "${WORKDIR}"/build -name '*.[17]' -exec touch {} +
 
 	# To compile ada library standard files special compiler options are passed
@@ -1814,7 +1682,7 @@ gcc_do_make() {
 			GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
 
 			ewarn "Disabling bootstrapping. ONLY recommended for development."
-			ewarn "This is NOT a safe configuration for endusers!"
+			ewarn "This is NOT a safe configuration for end users!"
 			ewarn "This compiler may not be safe or reliable for production use!"
 		elif _tc_use_if_iuse pgo; then
 			GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
@@ -1823,17 +1691,8 @@ gcc_do_make() {
 		fi
 	fi
 
-	# Older versions of GCC could not do profiledbootstrap in parallel due to
-	# collisions with profiling info.
-	if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] ; then
-		! tc_version_is_at_least 4.6 && export MAKEOPTS="${MAKEOPTS} -j1"
-	fi
-
 	if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
 		STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
-	elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
-		# See bug #79852
-		STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
 	fi
 
 	if is_crosscompile; then
@@ -1858,7 +1717,7 @@ gcc_do_make() {
 			LIBPATH="${LIBPATH}" \
 			BOOT_CFLAGS="${BOOT_CFLAGS}"
 		popd > /dev/null || die
-        fi
+	fi
 
 	einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
 
@@ -1888,13 +1747,9 @@ gcc_do_make() {
 
 	if ! is_crosscompile && _tc_use_if_iuse cxx && _tc_use_if_iuse doc ; then
 		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
-			else
-				cd "${CTARGET}"/libstdc++-v3
-				emake doxygen-man
-			fi
+			cd "${CTARGET}"/libstdc++-v3/doc || die
+			emake doc-man-doxygen
+
 			# Clean bogus manpages. bug #113902
 			find -name '*_build_*' -delete
 
@@ -1923,12 +1778,39 @@ toolchain_src_test() {
 	# '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.
-	SANDBOX_ON=0 LD_PRELOAD= emake -k check
+	#
+	# Nonfatal here as we die if compare_tests failed
+	SANDBOX_ON=0 LD_PRELOAD= nonfatal emake -k check
+	local success_tests=$?
+
+	if [[ ! -d "${BROOT}"/var/cache/gcc/${SLOT} ]] && ! [[ ${success_tests} -eq 0 ]] ; then
+		# We have no reference data saved from a previous run to know if
+		# the failures are tolerable or not, so we bail out.
+		eerror "Reference test data does NOT exist at ${BROOT}/var/cache/gcc/${SLOT}"
+		eerror "Tests failed and nothing to compare with, so this is a fatal error."
+		eerror "(Set GCC_TESTS_IGNORE_NO_BASELINE=1 to make this non-fatal for initial run.)"
+
+		if [[ -z ${GCC_TESTS_IGNORE_NO_BASELINE} ]] ; then
+			die "Tests failed (failures occurred with no reference data)"
+		fi
+	fi
 
-	einfo "Testing complete."
+	einfo "Testing complete! Review the following output to check for success or failure."
 	einfo "Please ignore any 'mail' lines in the summary output below (no mail is sent)."
 	einfo "Summary:"
 	"${S}"/contrib/test_summary
+
+	# If previous results exist on the system, compare with it
+	# TODO: Distribute some baseline results in e.g. gcc-patches.git?
+	if [[ -d "${BROOT}"/var/cache/gcc/${SLOT} ]] ; then
+		einfo "Comparing with previous cached results at ${BROOT}/var/cache/gcc/${SLOT}"
+
+		# Exit with the following values:
+		# 0 if there is nothing of interest
+		# 1 if there are errors when comparing single test case files
+		# N for the number of errors found when comparing directories
+		"${S}"/contrib/compare_tests "${BROOT}"/var/cache/gcc/${SLOT}/ . || die "Comparison for tests results failed, error code: $?"
+	fi
 }
 
 #---->> src_install <<----
@@ -1939,26 +1821,20 @@ toolchain_src_install() {
 	# Don't allow symlinks in private gcc include dir as this can break the build
 	find gcc/include*/ -type l -delete || die
 
-	# 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. bug #464008
-	mkdir -p gcc/doc || die
-	local x=
-	for x in "${S}"/gcc/doc/*.info* ; do
-		if [[ -f ${x} ]] ; then
-			cp "${x}" gcc/doc/ || die
-		fi
-	done
-
-	# We remove the generated fixincludes, as they can cause things to break
-	# (ncurses, openssl, etc).  We do not prevent them from being built, as
-	# in the following commit which we revert:
-	# https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
-	# This is because bsd userland needs fixedincludes to build gcc, while
-	# linux does not.  Both can dispose of them afterwards.
-	while read x ; do
-		grep -q 'It has been auto-edited by fixincludes from' "${x}" \
-			&& use !prefix && rm -f "${x}"
-	done < <(find gcc/include*/ -name '*.h')
+	# Re-enable fixincludes for >= GCC 13
+	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107128
+	if [[ ${GCCMAJOR} -lt 13 ]] ; then
+		# We remove the generated fixincludes, as they can cause things to break
+		# (ncurses, openssl, etc).  We do not prevent them from being built, as
+		# in the following commit which we revert:
+		# https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
+		# This is because bsd userland needs fixedincludes to build gcc, while
+		# linux does not.  Both can dispose of them afterwards.
+		while read x ; do
+			grep -q 'It has been auto-edited by fixincludes from' "${x}" \
+				&& rm -f "${x}"
+		done < <(find gcc/include*/ -name '*.h')
+	fi
 
 	if is_jit ; then
 		# See https://gcc.gnu.org/onlinedocs/gcc-11.3.0/jit/internals/index.html#packaging-notes
@@ -1971,7 +1847,7 @@ toolchain_src_install() {
 		#
 		# Do the 'make install' from the build directory
 		pushd "${WORKDIR}"/build-jit > /dev/null || die
-		S="${WORKDIR}"/build-jit emake DESTDIR="${D}" install
+		S="${WORKDIR}"/build-jit emake DESTDIR="${D}" -j1 install
 
 		# Punt some tools which are really only useful while building gcc
 		find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
@@ -1985,7 +1861,17 @@ toolchain_src_install() {
 	fi
 
 	# Do the 'make install' from the build directory
-	S="${WORKDIR}"/build emake DESTDIR="${D}" install
+	#
+	# Unfortunately, we have to use -j1 for make install. Upstream
+	# don't really test it and there's not much appetite for fixing bugs
+	# with it. Several reported bugs exist where the resulting image
+	# was wrong, rather than a simple compile/install failure:
+	# - bug #906155
+	# - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42980
+	# - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51814
+	# - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103656
+	# - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109898
+	S="${WORKDIR}"/build emake DESTDIR="${D}" -j1 install
 
 	# Punt some tools which are really only useful while building gcc
 	find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
@@ -2006,18 +1892,11 @@ toolchain_src_install() {
 	create_gcc_env_entry
 	create_revdep_rebuild_entry
 
-	# Setup the gcc_env_entry for hardened gcc 4 with minispecs
-	want_minispecs && copy_minispecs_gcc_specs
-
-	# Make sure we don't have stuff lying around that
-	# can nuke multiple versions of gcc
-	gcc_slot_java
-
 	dodir /usr/bin
 	cd "${D}"${BINPATH} || die
 	# Ugh: we really need to auto-detect this list.
 	#      It's constantly out of date.
-	for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo gnat* ; do
+	for x in cpp gcc gccrs g++ c++ gcov g77 gfortran gccgo gnat* ; do
 		# For some reason, g77 gets made instead of ${CTARGET}-g77...
 		# this should take care of that
 		if [[ -f ${x} ]] ; then
@@ -2049,7 +1928,7 @@ toolchain_src_install() {
 	if ! is_crosscompile; then
 		# Rename the main go binaries as we don't want to clobber dev-lang/go
 		# when gcc-config runs. bug #567806
-		if tc_version_is_at_least 5 && is_go ; then
+		if is_go ; then
 			for x in go gofmt; do
 				mv ${x} ${x}-${GCCMAJOR} || die
 			done
@@ -2154,15 +2033,20 @@ toolchain_src_install() {
 	export QA_WX_LOAD="usr/lib*/go/*/*.gox"
 
 	# Disable RANDMMAP so PCH works, bug #301299
-	if tc_version_is_at_least 4.3 ; then
-		pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
-		pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
-	fi
-
-	# Disable MPROTECT so java works, bug #574808
-	if is_gcj ; then
-		pax-mark -m "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
-		pax-mark -m "${ED}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
+	pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
+	pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
+
+	if use test ; then
+		# TODO: In future, install orphaned to allow comparison across
+		# more versions even after unmerged? Also would be useful for
+		# historical records and tracking down regressions a while
+		# after they first appeared, but were only just reported.
+		einfo "Copying test results to ${EPREFIX}/var/cache/gcc/${SLOT} for future comparison"
+		(
+			dodir /var/cache/gcc/${SLOT}
+			cd "${WORKDIR}"/build || die
+			find . -name \*.sum -exec cp --parents -v {} "${ED}"/var/cache/gcc/${SLOT} \;
+		)
 	fi
 }
 
@@ -2174,7 +2058,7 @@ gcc_movelibs() {
 	# move them to the compiler-specific CHOST internal dir.  This is stuff
 	# that you want to link against when building tools rather than building
 	# code to run on the target.
-	if tc_version_is_at_least 5 && is_crosscompile ; then
+	if is_crosscompile ; then
 		dodir "${HOSTLIBPATH#${EPREFIX}}"
 		mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
 	fi
@@ -2216,14 +2100,6 @@ gcc_movelibs() {
 			fi
 		done
 		fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
-
-		# SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
-		FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
-		for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
-			[[ -f ${x} ]] || continue
-			sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}" || die
-			mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
-		done
 	done
 
 	# We remove directories separately to avoid this case:
@@ -2272,7 +2148,7 @@ create_gcc_env_entry() {
 	local gcc_envd_file="${ED}${gcc_envd_base}"
 	if [[ -z $1 ]] ; then
 		# 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!
 		#gcc_specs_file="${LIBPATH}/specs"
 		gcc_specs_file=""
@@ -2336,67 +2212,6 @@ create_revdep_rebuild_entry() {
 	EOF
 }
 
-copy_minispecs_gcc_specs() {
-	# 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.
-	if hardened_gcc_works ; then
-		create_gcc_env_entry hardenednopiessp
-	fi
-	if hardened_gcc_works pie ; then
-		create_gcc_env_entry hardenednopie
-	fi
-	if hardened_gcc_works ssp ; then
-		create_gcc_env_entry hardenednossp
-	fi
-	create_gcc_env_entry vanilla
-	insinto ${LIBPATH#${EPREFIX}}
-	doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
-	# Build system specs file which, if it exists, must be a complete set of
-	# specs as it completely and unconditionally overrides the builtin specs.
-	if ! tc_version_is_at_least 4.4 ; then
-		$(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
-		cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
-		doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
-	fi
-}
-
-gcc_slot_java() {
-	local x
-
-	# Move Java headers to compiler-specific dir
-	for x in "${D}${PREFIX}"/include/gc*.h "${D}${PREFIX}"/include/j*.h ; do
-		[[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/include/
-	done
-	for x in gcj gnu java javax org ; do
-		if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
-			dodir /${LIBPATH#${EPREFIX}}/include/${x}
-			mv -f "${D}${PREFIX}"/include/${x}/* "${D}${LIBPATH}"/include/${x}/
-			rm -rf "${D}${PREFIX}"/include/${x}
-		fi
-	done
-
-	if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
-		dodir /${LIBPATH#${EPREFIX}}/security
-		mv -f "${D}${PREFIX}"/lib*/security/* "${D}${LIBPATH}"/security
-		rm -rf "${D}${PREFIX}"/lib*/security
-	fi
-
-	# Move random gcj files to compiler-specific directories
-	for x in libgcj.spec logging.properties ; do
-		x="${D}${PREFIX}/lib/${x}"
-		[[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/
-	done
-
-	# Rename jar because it could clash with Kaffe's jar if this gcc is
-	# primary compiler (aka doesn't have the -<version> extension)
-	cd "${D}${BINPATH}"
-	[[ -f jar ]] && mv -f jar gcj-jar
-}
-
 #---->> pkg_post* <<----
 
 toolchain_pkg_postinst() {
@@ -2459,14 +2274,14 @@ do_gcc_config() {
 			ewarn "The currently selected specs-specific gcc config,"
 			ewarn "${current_specs}, doesn't exist anymore. This is usually"
 			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."
 			use_specs=""
 		fi
 
 		target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
 	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
 		# TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
 		# doing a partial grep like this.
@@ -2519,7 +2334,7 @@ should_we_gcc_config() {
 #---->> support and misc functions <<----
 
 # 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
 # exactly get enabled
@@ -2563,11 +2378,6 @@ is_fortran() {
 	_tc_use_if_iuse fortran
 }
 
-is_gcj() {
-	gcc-lang-supported java || return 1
-	_tc_use_if_iuse cxx && _tc_use_if_iuse gcj
-}
-
 is_go() {
 	gcc-lang-supported go || return 1
 	_tc_use_if_iuse cxx && _tc_use_if_iuse go
@@ -2598,6 +2408,16 @@ is_objcxx() {
 	_tc_use_if_iuse cxx && _tc_use_if_iuse objc++
 }
 
+is_modula2() {
+	gcc-lang-supported m2 || return 1
+	_tc_use_if_iuse cxx && _tc_use_if_iuse modula2
+}
+
+is_rust() {
+	gcc-lang-supported rust || return 1
+	_tc_use_if_iuse rust
+}
+
 # Grab a variable from the build system (taken from linux-info.eclass)
 get_make_var() {
 	local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
@@ -2607,91 +2427,17 @@ get_make_var() {
 
 XGCC() { get_make_var GCC_FOR_TARGET ; }
 
-# The gentoo pie-ssp patches allow for 3 configurations:
-# 1) PIE+SSP by default
-# 2) PIE by default
-# 3) SSP by default
-hardened_gcc_works() {
-	if [[ $1 == "pie" ]] ; then
-		# $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.
-
-		want_pie || return 1
-		_tc_use_if_iuse nopie && return 1
-		hardened_gcc_is_stable pie
-		return $?
-	elif [[ $1 == "ssp" ]] ; then
-		[[ -n ${SPECS_VER} ]] || return 1
-		_tc_use_if_iuse nossp && return 1
-		hardened_gcc_is_stable ssp
-		return $?
-	else
-		# laziness ;)
-		hardened_gcc_works pie || return 1
-		hardened_gcc_works ssp || return 1
-		return 0
-	fi
-}
-
-hardened_gcc_is_stable() {
-	local tocheck
-	if [[ $1 == "pie" ]] ; then
-		tocheck=${PIE_GLIBC_STABLE}
-	elif [[ $1 == "ssp" ]] ; then
-		tocheck=${SSP_STABLE}
-	else
-		die "hardened_gcc_stable needs to be called with pie or ssp"
-	fi
-
-	has $(tc-arch) ${tocheck} && return 0
-	return 1
-}
-
-want_minispecs() {
-	# On gcc 6, we don't need minispecs
-	if tc_version_is_at_least 6.0 ; then
-		return 0
-	fi
-	if tc_version_is_at_least 4.3.2 && _tc_use_if_iuse hardened ; then
-		if ! want_pie ; then
-			ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
-		elif use vanilla ; then
-			ewarn "You will not get hardened features if you have the vanilla USE-flag."
-		elif _tc_use_if_iuse nopie && _tc_use_if_iuse nossp ; then
-			ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
-		elif ! hardened_gcc_works ; then
-			ewarn "Your $(tc-arch) arch is not supported."
-		else
-			return 0
-		fi
-		ewarn "Hope you know what you are doing. Hardened will not work."
-		return 0
-	fi
-	return 1
-}
-
-want_pie() {
-	! _tc_use_if_iuse hardened && [[ -n ${PIE_VER} ]] \
-		&& _tc_use_if_iuse nopie && return 1
-	[[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
-	tc_version_is_at_least 4.3.2 && return 1
-	[[ -z ${PIE_VER} ]] && return 1
-	_tc_use_if_iuse nopie || return 0
-	return 1
-}
-
 has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
 toolchain_death_notice() {
 	if [[ -e "${WORKDIR}"/build ]] ; then
 		pushd "${WORKDIR}"/build >/dev/null
 		(echo '' | $(tc-getCC ${CTARGET}) ${CFLAGS} -v -E - 2>&1) > gccinfo.log
 		[[ -e "${T}"/build.log ]] && cp "${T}"/build.log .
-		tar jcf "${WORKDIR}"/gcc-build-logs.tar.bz2 \
+		tar -acf "${WORKDIR}"/gcc-build-logs.tar.xz \
 			gccinfo.log build.log $(find -name config.log)
 		rm gccinfo.log build.log
 		eerror
-		eerror "Please include ${WORKDIR}/gcc-build-logs.tar.bz2 in your bug report."
+		eerror "Please include ${WORKDIR}/gcc-build-logs.tar.xz in your bug report."
 		eerror
 		popd >/dev/null
 	fi
@@ -2699,9 +2445,6 @@ toolchain_death_notice() {
 
 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
@@ -2719,3 +2462,5 @@ EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
 # Thus safer way to enable/disable the feature is to rely on implicit
 # enabled-by-default state:
 #    econf $(usex foo '' --disable-foo)
+
+EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_postinst pkg_postrm


             reply	other threads:[~2023-09-03 19:39 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-03 19:39 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-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-06-06  8:42 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=1693769968.cbcf8a9a914d88f8c61f27e1343776159a97d218.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