commit:     5b99beb42d0df33eda54d61e712f310311b730dc
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 13 07:51:01 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 13 07:51:01 2020 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=5b99beb4

eclass/toolchain-*: sync with gx86

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

 eclass/toolchain-binutils.eclass | 504 -------------------------------------
 eclass/toolchain-funcs.eclass    |  60 +++--
 eclass/toolchain.eclass          | 522 +++++++++++++++++++--------------------
 3 files changed, 292 insertions(+), 794 deletions(-)

diff --git a/eclass/toolchain-binutils.eclass b/eclass/toolchain-binutils.eclass
deleted file mode 100644
index 6e3a60f357..0000000000
--- a/eclass/toolchain-binutils.eclass
+++ /dev/null
@@ -1,504 +0,0 @@
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-#
-# Maintainer: Toolchain Ninjas <[email protected]>
-# @SUPPORTED_EAPIS: 0 1 2 3 4 5
-#
-# We install binutils into CTARGET-VERSION specific directories.  This lets
-# us easily merge multiple versions for multiple targets (if we wish) and
-# then switch the versions on the fly (with `binutils-config`).
-#
-# binutils-9999           -> live git
-# binutils-9999_preYYMMDD -> nightly snapshot date YYMMDD
-# binutils-#              -> normal release
-
-if [[ -n ${BINUTILS_TYPE} ]] ; then
-       BTYPE=${BINUTILS_TYPE}
-else
-       case ${PV} in
-       9999_pre*) BTYPE="snap";;
-       *.*.90)    BTYPE="snap";;
-       *.*.*.*.*) BTYPE="hjlu";;
-       *)         BTYPE="rel";;
-       esac
-fi
-
-case ${BTYPE} in
-snap)
-       BVER=${PV/9999_pre}
-       ;;
-*)
-       BVER=${BINUTILS_VER:-${PV}}
-       ;;
-esac
-
-inherit eutils libtool flag-o-matic gnuconfig multilib versionator unpacker
-case ${EAPI:-0} in
-0|1)
-       EXPORT_FUNCTIONS src_unpack src_compile src_test src_install 
pkg_postinst pkg_postrm ;;
-2|3|4|5)
-       EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile 
src_test src_install pkg_postinst pkg_postrm ;;
-*) die "unsupported EAPI ${EAPI}" ;;
-esac
-
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} == ${CHOST} ]] ; then
-       if [[ ${CATEGORY} == cross-* ]] ; then
-               export CTARGET=${CATEGORY#cross-}
-       fi
-fi
-is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
-
-DESCRIPTION="Tools necessary to build programs"
-HOMEPAGE="https://sourceware.org/binutils/";
-
-case ${BTYPE} in
-       snap)
-               
SRC_URI="ftp://gcc.gnu.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2
-                       
ftp://sourceware.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2"; ;;
-       hjlu)
-               
SRC_URI="mirror://kernel/linux/devel/binutils/binutils-${BVER}.tar."
-               version_is_at_least 2.21.51.0.5 && SRC_URI+="xz" || 
SRC_URI+="bz2" ;;
-       rel) SRC_URI="mirror://gnu/binutils/binutils-${BVER}.tar.bz2" ;;
-esac
-add_src_uri() {
-       [[ -z $2 ]] && return
-       local a=$1
-       if version_is_at_least 2.22.52.0.2 ; then
-               a+=".xz"
-       else
-               a+=".bz2"
-       fi
-       set -- mirror://gentoo https://dev.gentoo.org/~vapier/dist 
https://dev.gentoo.org/~tamiko/distfiles 
https://dev.gentoo.org/~dilfridge/distfiles
-       SRC_URI="${SRC_URI} ${@/%//${a}}"
-}
-PATCH_BINUTILS_VER=${PATCH_BINUTILS_VER:-${BVER}}
-add_src_uri binutils-${PATCH_BINUTILS_VER}-patches-${PATCHVER}.tar ${PATCHVER}
-add_src_uri 
binutils-${PATCH_BINUTILS_VER}-uclibc-patches-${UCLIBC_PATCHVER}.tar 
${UCLIBC_PATCHVER}
-add_src_uri elf2flt-${ELF2FLT_VER}.tar ${ELF2FLT_VER}
-
-if version_is_at_least 2.18 ; then
-       LICENSE="|| ( GPL-3 LGPL-3 )"
-else
-       LICENSE="|| ( GPL-2 LGPL-2 )"
-fi
-IUSE="cxx multitarget nls static-libs test vanilla"
-if version_is_at_least 2.19 && ! version_is_at_least 2.26 ; then
-       IUSE+=" zlib"
-fi
-SLOT="${BVER}"
-
-RDEPEND=">=sys-devel/binutils-config-3"
-if in_iuse zlib ; then
-       RDEPEND+=" zlib? ( sys-libs/zlib )"
-elif version_is_at_least 2.26 ; then
-       RDEPEND+=" sys-libs/zlib"
-fi
-DEPEND="${RDEPEND}
-       test? ( dev-util/dejagnu )
-       nls? ( sys-devel/gettext )
-       sys-devel/flex
-       virtual/yacc"
-if is_cross ; then
-       # The build assumes the host has libiberty and such when cross-compiling
-       # its build tools.  We should probably make binutils itself build a 
local
-       # copy to use, but until then, be lazy.
-       DEPEND+=" >=sys-libs/binutils-libs-${PV}"
-fi
-
-S=${WORKDIR}/binutils-${BVER}
-
-LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${BVER}
-INCPATH=${LIBPATH}/include
-DATAPATH=/usr/share/binutils-data/${CTARGET}/${BVER}
-MY_BUILDDIR=${WORKDIR}/build
-if is_cross ; then
-       BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${BVER}
-else
-       BINPATH=/usr/${CTARGET}/binutils-bin/${BVER}
-fi
-
-tc-binutils_unpack() {
-       unpacker ${A}
-       mkdir -p "${MY_BUILDDIR}"
-       [[ -d ${WORKDIR}/patch ]] && mkdir "${WORKDIR}"/patch/skip
-}
-
-# In case the ebuild wants to add a few of their own.
-PATCHES=()
-
-tc-binutils_apply_patches() {
-       cd "${S}"
-
-       if ! use vanilla ; then
-               if [[ -n ${PATCHVER} ]] ; then
-                       EPATCH_SOURCE=${WORKDIR}/patch
-                       if [[ ${CTARGET} == mips* ]] ; then
-                               # remove gnu-hash for mips (bug #233233)
-                               EPATCH_EXCLUDE+=" 
77_all_generate-gnu-hash.patch"
-                       fi
-                       [[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
-                               && EPATCH_SUFFIX="patch.bz2" \
-                               || EPATCH_SUFFIX="patch"
-                       epatch
-               fi
-               if [[ -n ${UCLIBC_PATCHVER} ]] ; then
-                       EPATCH_SOURCE=${WORKDIR}/uclibc-patches
-                       [[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
-                               && EPATCH_SUFFIX="patch.bz2" \
-                               || EPATCH_SUFFIX="patch"
-                       EPATCH_MULTI_MSG="Applying uClibc fixes ..." \
-                       epatch
-               elif [[ ${CTARGET} == *-uclibc* ]] ; then
-                       # starting with binutils-2.17.50.0.17, we no longer need
-                       # uClibc patchsets :D
-                       if grep -qs 'linux-gnu' "${S}"/ltconfig ; then
-                               die "sorry, but this binutils doesn't yet 
support uClibc :("
-                       fi
-               fi
-               [[ ${#PATCHES[@]} -gt 0 ]] && epatch "${PATCHES[@]}"
-
-               # Make sure our explicit libdir paths don't get clobbered. 
#562460
-               sed -i \
-                       -e 's:@bfdlibdir@:@libdir@:g' \
-                       -e 's:@bfdincludedir@:@includedir@:g' \
-                       {bfd,opcodes}/Makefile.in || die
-
-               epatch_user
-       fi
-
-       # fix locale issues if possible #122216
-       if [[ -e ${FILESDIR}/binutils-configure-LANG.patch ]] ; then
-               einfo "Fixing misc issues in configure files"
-               for f in $(find "${S}" -name configure -exec grep -l 'autoconf 
version 2.13' {} +) ; do
-                       ebegin "  Updating ${f/${S}\/}"
-                       patch "${f}" 
"${FILESDIR}"/binutils-configure-LANG.patch >& "${T}"/configure-patch.log \
-                               || eerror "Please file a bug about this"
-                       eend $?
-               done
-       fi
-       # fix conflicts with newer glibc #272594
-       if [[ -e libiberty/testsuite/test-demangle.c ]] ; then
-               sed -i 's:\<getline\>:get_line:g' 
libiberty/testsuite/test-demangle.c
-       fi
-
-       # Fix po Makefile generators
-       sed -i \
-               -e '/^datadir = /s:$(prefix)/@DATADIRNAME@:@datadir@:' \
-               -e '/^gnulocaledir = /s:$(prefix)/share:$(datadir):' \
-               */po/Make-in || die "sed po's failed"
-
-       # Run misc portage update scripts
-       gnuconfig_update
-       elibtoolize --portage --no-uclibc
-}
-
-toolchain-binutils_src_unpack() {
-       tc-binutils_unpack
-       case ${EAPI:-0} in
-       0|1) toolchain-binutils_src_prepare ;;
-       esac
-}
-
-toolchain-binutils_src_prepare() {
-       tc-binutils_apply_patches
-}
-
-_eprefix_init() {
-       has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
-}
-
-# Intended for ebuilds to override to set their own versioning information.
-toolchain-binutils_bugurl() {
-       printf "https://bugs.gentoo.org/";
-}
-toolchain-binutils_pkgversion() {
-       printf "Gentoo ${BVER}"
-       [[ -n ${PATCHVER} ]] && printf " p${PATCHVER}"
-}
-
-toolchain-binutils_src_configure() {
-       _eprefix_init
-
-       # make sure we filter $LINGUAS so that only ones that
-       # actually work make it through #42033
-       strip-linguas -u */po
-
-       # keep things sane
-       strip-flags
-
-       local x
-       echo
-       for x in CATEGORY CBUILD CHOST CTARGET CFLAGS LDFLAGS ; do
-               einfo "$(printf '%10s' ${x}:) ${!x}"
-       done
-       echo
-
-       cd "${MY_BUILDDIR}"
-       local myconf=()
-
-       # enable gold if available (installed as ld.gold)
-       # PREFIX LOCAL: Linux only (fails to compile on Solaris, MiNT #353410)
-       if [[ ${CHOST} == *-linux* ]] && use cxx ; then
-               if grep -q 'enable-gold=default' "${S}"/configure ; then
-                       myconf+=( --enable-gold )
-               # old ways - remove when 2.21 is stable
-               elif grep -q 'enable-gold=both/ld' "${S}"/configure ; then
-                       myconf+=( --enable-gold=both/ld )
-               elif grep -q 'enable-gold=both/bfd' "${S}"/configure ; then
-                       myconf+=( --enable-gold=both/bfd )
-               fi
-               if grep -q -e '--enable-plugins' "${S}"/ld/configure ; then
-                       myconf+=( --enable-plugins )
-               fi
-       fi
-
-       use nls \
-               && myconf+=( --without-included-gettext ) \
-               || myconf+=( --disable-nls )
-
-       if in_iuse zlib ; then
-               # older versions did not have an explicit configure flag
-               export ac_cv_search_zlibVersion=$(usex zlib -lz no)
-               myconf+=( $(use_with zlib) )
-       elif version_is_at_least 2.26 ; then
-               myconf+=( --with-system-zlib )
-       fi
-
-       # For bi-arch systems, enable a 64bit bfd.  This matches
-       # the bi-arch logic in toolchain.eclass. #446946
-       # We used to do it for everyone, but it's slow on 32bit arches. #438522
-       case $(tc-arch) in
-       ppc|sparc|x86) myconf+=( --enable-64-bit-bfd ) ;;
-       esac
-
-       [[ ${CHOST} == *"-solaris"* ]] && use nls && append-libs -lintl
-       use multitarget && myconf+=( --enable-targets=all --enable-64-bit-bfd )
-       [[ -n ${CBUILD} ]] && myconf+=( --build=${CBUILD} )
-       is_cross && myconf+=(
-               --with-sysroot="${EPREFIX}"/usr/${CTARGET}
-               --enable-poison-system-directories
-       )
-
-       # glibc-2.3.6 lacks support for this ... so rather than force glibc-2.5+
-       # on everyone in alpha (for now), we'll just enable it when possible
-       has_version ">=${CATEGORY}/glibc-2.5" && myconf+=( --enable-secureplt )
-       has_version ">=sys-libs/glibc-2.5" && myconf+=( --enable-secureplt )
-
-       myconf+=(
-               --prefix="${EPREFIX}"/usr
-               --host=${CHOST}
-               --target=${CTARGET}
-               --datadir="${EPREFIX}"${DATAPATH}
-               --infodir="${EPREFIX}"${DATAPATH}/info
-               --mandir="${EPREFIX}"${DATAPATH}/man
-               --bindir="${EPREFIX}"${BINPATH}
-               --libdir="${EPREFIX}"${LIBPATH}
-               --libexecdir="${EPREFIX}"${LIBPATH}
-               --includedir="${EPREFIX}"${INCPATH}
-               --enable-obsolete
-               --enable-shared
-               --enable-threads
-               # Newer versions (>=2.27) offer a configure flag now.
-               --enable-relro
-               # Newer versions (>=2.24) make this an explicit option. #497268
-               --enable-install-libiberty
-               --disable-werror
-               --with-bugurl="$(toolchain-binutils_bugurl)"
-               --with-pkgversion="$(toolchain-binutils_pkgversion)"
-               $(use_enable static-libs static)
-               ${EXTRA_ECONF}
-               # Disable modules that are in a combined binutils/gdb tree. 
#490566
-               --disable-{gdb,libdecnumber,readline,sim}
-               # Strip out broken static link flags.
-               # https://gcc.gnu.org/PR56750
-               --without-stage1-ldflags
-       )
-       echo ./configure "${myconf[@]}"
-       "${S}"/configure "${myconf[@]}" || die
-
-       # Prevent makeinfo from running in releases.  It may not always be
-       # installed, and older binutils may fail with newer texinfo.
-       # Besides, we never patch the doc files anyways, so regenerating
-       # in the first place is useless. #193364
-       # For older versions, it means we don't get any info pages at all.
-       # Oh well, tough luck. #294617
-       if [[ -e ${S}/gas/doc/as.info ]] || ! version_is_at_least 2.24 ; then
-               sed -i \
-                       -e '/^MAKEINFO/s:=.*:= true:' \
-                       Makefile || die
-       fi
-}
-
-toolchain-binutils_src_compile() {
-       _eprefix_init
-       case ${EAPI:-0} in
-       0|1) toolchain-binutils_src_configure ;;
-       esac
-
-       cd "${MY_BUILDDIR}"
-       emake all || die "emake failed"
-
-       # only build info pages if we user wants them, and if
-       # we have makeinfo (may not exist when we bootstrap)
-       if type -p makeinfo > /dev/null ; then
-               emake info || die "make info failed"
-       fi
-       # we nuke the manpages when we're left with junk
-       # (like when we bootstrap, no perl -> no manpages)
-       find . -name '*.1' -a -size 0 -delete
-
-       # elf2flt only works on some arches / targets
-       if [[ -n ${ELF2FLT_VER} ]] && [[ ${CTARGET} == *linux* || ${CTARGET} == 
*-elf* ]] ; then
-               cd "${WORKDIR}"/elf2flt-${ELF2FLT_VER}
-
-               local x supported_arches=$(sed -n 
'/defined(TARGET_/{s:^.*TARGET_::;s:)::;p}' elf2flt.c | sort -u)
-               for x in ${supported_arches} UNSUPPORTED ; do
-                       [[ ${CTARGET} == ${x}* ]] && break
-               done
-
-               if [[ ${x} != "UNSUPPORTED" ]] ; then
-                       append-flags -I"${S}"/include
-                       myconf+=(
-                               --with-bfd-include-dir=${MY_BUILDDIR}/bfd
-                               --with-libbfd=${MY_BUILDDIR}/bfd/libbfd.a
-                               
--with-libiberty=${MY_BUILDDIR}/libiberty/libiberty.a
-                               
--with-binutils-ldscript-dir="${EPREFIX}"${LIBPATH}/ldscripts
-                       )
-                       echo ./configure "${myconf[@]}"
-                       ./configure "${myconf[@]}" || die
-                       emake || die "make elf2flt failed"
-               fi
-       fi
-}
-
-toolchain-binutils_src_test() {
-       cd "${MY_BUILDDIR}"
-       emake -k check || die "check failed :("
-}
-
-toolchain-binutils_src_install() {
-       _eprefix_init
-       local x d
-
-       cd "${MY_BUILDDIR}"
-       emake DESTDIR="${D}" tooldir="${EPREFIX}${LIBPATH}" install || die
-       rm -rf "${ED}"/${LIBPATH}/bin
-       use static-libs || find "${ED}" -name '*.la' -delete
-
-       # Newer versions of binutils get fancy with ${LIBPATH} #171905
-       cd "${ED}"/${LIBPATH}
-       for d in ../* ; do
-               [[ ${d} == ../${BVER} ]] && continue
-               mv ${d}/* . || die
-               rmdir ${d} || die
-       done
-
-       # Now we collect everything intp the proper SLOT-ed dirs
-       # When something is built to cross-compile, it installs into
-       # /usr/$CHOST/ by default ... we have to 'fix' that :)
-       if is_cross ; then
-               cd "${ED}"/${BINPATH}
-               for x in * ; do
-                       mv ${x} ${x/${CTARGET}-}
-               done
-
-               if [[ -d ${ED}/usr/${CHOST}/${CTARGET} ]] ; then
-                       mv "${ED}"/usr/${CHOST}/${CTARGET}/include 
"${ED}"/${INCPATH}
-                       mv "${ED}"/usr/${CHOST}/${CTARGET}/lib/* 
"${ED}"/${LIBPATH}/
-                       rm -r "${ED}"/usr/${CHOST}/{include,lib}
-               fi
-       fi
-       insinto ${INCPATH}
-       local libiberty_headers=(
-               # Not all the libiberty headers.  See 
libiberty/Makefile.in:install_to_libdir.
-               demangle.h
-               dyn-string.h
-               fibheap.h
-               hashtab.h
-               libiberty.h
-               objalloc.h
-               splay-tree.h
-       )
-       doins "${libiberty_headers[@]/#/${S}/include/}" || die
-       if [[ -d ${ED}/${LIBPATH}/lib ]] ; then
-               mv "${ED}"/${LIBPATH}/lib/* "${ED}"/${LIBPATH}/
-               rm -r "${ED}"/${LIBPATH}/lib
-       fi
-
-       # Insert elf2flt where appropriate
-       if [[ -x ${WORKDIR}/elf2flt-${ELF2FLT_VER}/elf2flt ]] ; then
-               cd "${WORKDIR}"/elf2flt-${ELF2FLT_VER}
-               insinto ${LIBPATH}/ldscripts
-               doins elf2flt.ld || die "doins elf2flt.ld failed"
-               exeinto ${BINPATH}
-               doexe elf2flt flthdr || die "doexe elf2flt flthdr failed"
-               mv "${ED}"/${BINPATH}/{ld,ld.real} || die
-               newexe ld-elf2flt ld || die "doexe ld-elf2flt failed"
-               newdoc README README.elf2flt
-       fi
-
-       # Generate an env.d entry for this binutils
-       insinto /etc/env.d/binutils
-       cat <<-EOF > "${T}"/env.d
-               TARGET="${CTARGET}"
-               VER="${BVER}"
-               LIBPATH="${EPREFIX}${LIBPATH}"
-       EOF
-       newins "${T}"/env.d ${CTARGET}-${BVER}
-
-       # Handle documentation
-       if ! is_cross ; then
-               cd "${S}"
-               dodoc README
-               docinto bfd
-               dodoc bfd/ChangeLog* bfd/README bfd/PORTING bfd/TODO
-               docinto binutils
-               dodoc binutils/ChangeLog binutils/NEWS binutils/README
-               docinto gas
-               dodoc gas/ChangeLog* gas/CONTRIBUTORS gas/NEWS gas/README*
-               docinto gprof
-               dodoc gprof/ChangeLog* gprof/TEST gprof/TODO gprof/bbconv.pl
-               docinto ld
-               dodoc ld/ChangeLog* ld/README ld/NEWS ld/TODO
-               docinto libiberty
-               dodoc libiberty/ChangeLog* libiberty/README
-               docinto opcodes
-               dodoc opcodes/ChangeLog*
-       fi
-       # Remove shared info pages
-       rm -f "${ED}"/${DATAPATH}/info/{dir,configure.info,standards.info}
-       # Trim all empty dirs
-       find "${ED}" -depth -type d -exec rmdir {} + 2>/dev/null
-}
-
-toolchain-binutils_pkg_postinst() {
-       _eprefix_init
-       # Make sure this ${CTARGET} has a binutils version selected
-       [[ -e ${EROOT}/etc/env.d/binutils/config-${CTARGET} ]] && return 0
-       binutils-config ${CTARGET}-${BVER}
-}
-
-toolchain-binutils_pkg_postrm() {
-       _eprefix_init
-       local current_profile=$(binutils-config -c ${CTARGET})
-
-       # If no other versions exist, then uninstall for this
-       # target ... otherwise, switch to the newest version
-       # Note: only do this if this version is unmerged.  We
-       #       rerun binutils-config if this is a remerge, as
-       #       we want the mtimes on the symlinks updated (if
-       #       it is the same as the current selected profile)
-       if [[ ! -e ${EPREFIX}${BINPATH}/ld ]] && [[ ${current_profile} == 
${CTARGET}-${BVER} ]] ; then
-               local choice=$(binutils-config -l | grep ${CTARGET} | awk 
'{print $2}')
-               choice=${choice//$'\n'/ }
-               choice=${choice/* }
-               if [[ -z ${choice} ]] ; then
-                       env -i ROOT="${ROOT}" binutils-config -u ${CTARGET}
-               else
-                       binutils-config ${choice}
-               fi
-       elif [[ $(CHOST=${CTARGET} binutils-config -c) == ${CTARGET}-${BVER} ]] 
; then
-               binutils-config ${CTARGET}-${BVER}
-       fi
-}

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 99aac55dea..a491b75522 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -207,14 +207,13 @@ tc-cpp-is-true() {
        local CONDITION=${1}
        shift
 
-       local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
-                       #if ${CONDITION}
-                       true
-                       #endif
-               EOF
-       )
-
-       [[ ${RESULT} == true ]]
+       $(tc-getTARGET_CPP) "${@}" -P - <<-EOF >/dev/null 2>&1
+               #if ${CONDITION}
+               true
+               #else
+               #error false
+               #endif
+       EOF
 }
 
 # @FUNCTION: tc-detect-is-softfloat
@@ -453,6 +452,36 @@ tc-ld-is-gold() {
        return 1
 }
 
+# @FUNCTION: tc-ld-is-lld
+# @USAGE: [toolchain prefix]
+# @DESCRIPTION:
+# Return true if the current linker is set to lld.
+tc-ld-is-lld() {
+       local out
+
+       # First check the linker directly.
+       out=$($(tc-getLD "$@") --version 2>&1)
+       if [[ ${out} == *"LLD"* ]] ; then
+               return 0
+       fi
+
+       # Then see if they're selecting lld via compiler flags.
+       # Note: We're assuming they're using LDFLAGS to hold the
+       # options and not CFLAGS/CXXFLAGS.
+       local base="${T}/test-tc-lld"
+       cat <<-EOF > "${base}.c"
+       int main() { return 0; }
+       EOF
+       out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version 
"${base}.c" -o "${base}" 2>&1)
+       rm -f "${base}"*
+       if [[ ${out} == *"LLD"* ]] ; then
+               return 0
+       fi
+
+       # No lld here!
+       return 1
+}
+
 # @FUNCTION: tc-ld-disable-gold
 # @USAGE: [toolchain prefix]
 # @DESCRIPTION:
@@ -980,18 +1009,11 @@ tc-enables-ssp-all() {
 # @FUNCTION: gen_usr_ldscript
 # @USAGE: [-a] <list of libs to create linker scripts for>
 # @DESCRIPTION:
-# This function generate linker scripts in /usr/lib for dynamic
-# libs in /lib.  This is to fix linking problems when you have
-# the .so in /lib, and the .a in /usr/lib.  What happens is that
-# in some cases when linking dynamic, the .a in /usr/lib is used
-# instead of the .so in /lib due to gcc/libtool tweaking ld's
-# library search path.  This causes many builds to fail.
-# See bug #4411 for more info.
-#
-# Note that you should in general use the unversioned name of
-# the library (libfoo.so), as ldconfig should usually update it
-# correctly to point to the latest version of the library present.
+# This function is deprecated. Use the version from
+# usr-ldscript.eclass instead.
 gen_usr_ldscript() {
+       ewarn "${FUNCNAME}: Please migrate to usr-ldscript.eclass"
+
        local lib libdir=$(get_libdir) output_format="" auto=false 
suffix=$(get_libname)
        [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/
 

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 99b8c08d9c..89a522f9cf 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,25 +1,28 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # Maintainer: Toolchain Ninjas <[email protected]>
-# @SUPPORTED_EAPIS: 5 6
+# @SUPPORTED_EAPIS: 5 6 7
 
 DESCRIPTION="The GNU Compiler Collection"
 HOMEPAGE="https://gcc.gnu.org/";
-RESTRICT="strip" # cross-compilers need controlled stripping
 
 inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils 
toolchain-funcs prefix
 
-if [[ ${PV} == *_pre9999* ]] ; then
+tc_is_live() {
+       [[ ${PV} == *9999* ]]
+}
+
+if tc_is_live ; then
        EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"
        # naming style:
-       # gcc-4.7.1_pre9999 -> gcc-4_7-branch
+       # 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
        #  inheriting this eclass.
-       EGIT_BRANCH="${PN}-${PV%.?_pre9999}-branch"
+       EGIT_BRANCH="releases/${PN}-${PV%.?.?_pre9999}"
        EGIT_BRANCH=${EGIT_BRANCH//./_}
-       inherit git-2
+       inherit git-r3
 fi
 
 FEATURES=${FEATURES/multilib-strict/}
@@ -27,8 +30,10 @@ 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
 
@@ -65,34 +70,36 @@ tc_version_is_between() {
 GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
 GCC_PVR=${GCC_PV}
 [[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
+
+# 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})
+
 GCC_BRANCH_VER=$(ver_cut 1-2 ${GCC_PV})
 GCCMAJOR=$(ver_cut 1 ${GCC_PV})
 GCCMINOR=$(ver_cut 2 ${GCC_PV})
 GCCMICRO=$(ver_cut 3 ${GCC_PV})
-[[ ${BRANCH_UPDATE-notset} == "notset" ]] && \
-       BRANCH_UPDATE=$(ver_cut 4 ${GCC_PV})
-
-# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
-# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
-GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(ver_rs 3 '-' ${GCC_PV})}
-
-# Pre-release support
-if [[ ${GCC_PV} == *_pre* ]] ; then
-       PRERELEASE=${GCC_PV/_pre/-}
-elif [[ ${GCC_PV} == *_alpha* ]] ; then
-       SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha}
-elif [[ ${GCC_PV} == *_beta* ]] ; then
-       SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta}
+
+# 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
+# (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_rcYYYYMMDD: release candidates
+if [[ ${GCC_PV} == *_alpha* ]] ; then
+       # weekly snapshots
+       SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_alpha}
 elif [[ ${GCC_PV} == *_rc* ]] ; then
+       # release candidates
        SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
 fi
 
-if [[ ${SNAPSHOT} == [56789].0-* ]] ; then
-       # The gcc-5+ releases have dropped the .0 for some reason.
-       SNAPSHOT=${SNAPSHOT/.0}
-fi
-
 PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
 
 if tc_version_is_at_least 3.4.0 ; then
@@ -131,15 +138,18 @@ else
        LICENSE="GPL-2+ LGPL-2.1+ FDL-1.1+"
 fi
 
-if tc_version_is_at_least 8.3; then
-       GCC_EBUILD_TEST_FLAG='test'
-else
-       # Don't force USE regression-test->test change on every
-       # gcc ebuild just yet. Let's do the change when >=gcc-8.3
-       # is commonly used as a main compiler.
-       GCC_EBUILD_TEST_FLAG='regression-test'
-fi
-IUSE="${GCC_EBUILD_TEST_FLAG} vanilla +nls +nptl"
+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=()
 
@@ -148,11 +158,13 @@ tc_has_feature() {
 }
 
 if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
-       IUSE+=" altivec debug +cxx +fortran" TC_FEATURES+=(fortran)
+       IUSE+=" altivec debug +cxx +nptl" TC_FEATURES+=(nptl)
        [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
        [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
        [[ -n ${D_VER}   ]] && IUSE+=" d"
        [[ -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"
@@ -163,11 +175,16 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
        tc_version_is_at_least 4.2 && IUSE+=" +openmp"
        tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
        tc_version_is_at_least 4.7 && IUSE+=" go"
-       # Note: while <=gcc-4.7 also 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
        tc_version_is_at_least 4.8 &&
-               IUSE+=" graphite +sanitize" TC_FEATURES+=(graphite)
+               IUSE+=" +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+=" +vtv"
        tc_version_is_at_least 5.0 && IUSE+=" jit"
@@ -178,9 +195,16 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
                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)
 fi
 
-SLOT="${GCC_CONFIG_VER}"
+if tc_version_is_at_least 10; then
+       # Note: currently we pull in releases, snapshots and
+       # git versions into the same SLOT.
+       SLOT="${GCCMAJOR}"
+else
+       SLOT="${GCC_CONFIG_VER}"
+fi
 
 #---->> DEPEND <<----
 
@@ -207,25 +231,18 @@ if tc_has_feature objc-gc ; then
 fi
 
 if tc_has_feature graphite ; then
-       if tc_version_is_at_least 5.0 ; then
-               RDEPEND+=" graphite? ( >=dev-libs/isl-0.14:0= )"
-       elif tc_version_is_at_least 4.8 ; then
-               RDEPEND+="
-                       graphite? (
-                               >=dev-libs/cloog-0.18.0:0=
-                               >=dev-libs/isl-0.11.1:0=
-                       )"
-       fi
+       RDEPEND+=" graphite? ( >=dev-libs/isl-0.14:0= )"
 fi
 
-DEPEND="${RDEPEND}
+BDEPEND="
        >=sys-devel/bison-1.875
        >=sys-devel/flex-2.5.4
        nls? ( sys-devel/gettext )
-       ${GCC_EBUILD_TEST_FLAG}? (
+       test? (
                >=dev-util/dejagnu-1.4.4
                >=sys-devel/autogen-5.5.4
        )"
+DEPEND="${RDEPEND}"
 
 if tc_has_feature gcj ; then
        GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
@@ -247,15 +264,23 @@ if tc_has_feature systemtap ; then
        DEPEND+=" systemtap? ( dev-util/systemtap )"
 fi
 
+if tc_has_feature zstd ; then
+       DEPEND+=" zstd? ( app-arch/zstd )"
+fi
+
+case ${EAPI:-0} in
+       5*|6) DEPEND+=" ${BDEPEND}" ;;
+esac
+
 PDEPEND=">=sys-devel/gcc-config-1.7"
 
 #---->> S + SRC_URI essentials <<----
 
 # Set the source directory depending on whether we're using
-# a prerelease, snapshot, or release tarball.
+# a live git tree, snapshot, or release tarball.
 S=$(
-       if [[ -n ${PRERELEASE} ]] ; then
-               echo ${WORKDIR}/gcc-${PRERELEASE}
+       if tc_is_live ; then
+               echo ${EGIT_CHECKOUT_DIR}
        elif [[ -n ${SNAPSHOT} ]] ; then
                echo ${WORKDIR}/gcc-${SNAPSHOT}
        else
@@ -279,20 +304,16 @@ gentoo_urls() {
 # Other than the variables normally set by portage, this function's behavior
 # can be altered by setting the following:
 #
+#      GCC_TARBALL_SRC_URI
+#                      Override link to main tarball into SRC_URI. Used by 
dev-lang/gnat-gpl
+#                      to provide gcc tarball snapshots. Patches are usually 
reused as-is.
+#
 #      SNAPSHOT
 #                      If set, this variable signals that we should be using a 
snapshot of
 #                      gcc. It is expected to be in the format "YYYY-MM-DD". 
Note that if
 #                      the ebuild has a _pre suffix, this variable is ignored 
and the
 #                      prerelease tarball is used instead.
 #
-#      BRANCH_UPDATE
-#                      If set, this variable signals that we should be using 
the main
-#                      release tarball (determined by ebuild version) and 
applying a
-#                      CVS branch update patch against it. The location of 
this branch
-#                      update patch is assumed to be in 
${GENTOO_TOOLCHAIN_BASE_URI}.
-#                      Just like with SNAPSHOT, this variable is ignored if 
the ebuild
-#                      has a _pre suffix.
-#
 #      PATCH_VER
 #      PATCH_GCC_VER
 #                      This should be set to the version of the gentoo patch 
tarball.
@@ -345,27 +366,20 @@ get_gcc_src_uri() {
        export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
 
        # Set where to download gcc itself depending on whether we're using a
-       # prerelease, snapshot, or release tarball.
-       if [[ ${PV} == *9999* ]] ; then
-               # Nothing to do w/git snapshots.
-               :
-       elif [[ -n ${PRERELEASE} ]] ; then
-               
GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2";
+       # live git tree, snapshot, or release tarball.
+       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.
+               GCC_SRC_URI="${GCC_TARBALL_SRC_URI}"
        elif [[ -n ${SNAPSHOT} ]] ; then
-               if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 
|| tc_version_is_at_least 7.2 ; then
-                       
GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz";
-               else
-                       
GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2";
-               fi
+               
GCC_SRC_URI="ftp://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"
                else
                        
GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
                fi
-               # we want all branch updates to be against the main release
-               [[ -n ${BRANCH_UPDATE} ]] && \
-                       GCC_SRC_URI+=" $(gentoo_urls 
gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
        fi
 
        [[ -n ${UCLIBC_VER} ]] && \
@@ -373,7 +387,6 @@ get_gcc_src_uri() {
        [[ -n ${PATCH_VER} ]] && \
                GCC_SRC_URI+=" $(gentoo_urls 
gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
 
-       # strawberry pie, Cappuccino and a Gauloises (it's a good thing)
        [[ -n ${PIE_VER} ]] && \
                
PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
                GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
@@ -415,8 +428,12 @@ SRC_URI=$(get_gcc_src_uri)
 
 #---->> pkg_pretend <<----
 
+toolchain_is_unsupported() {
+       [[ -n ${SNAPSHOT} ]] || tc_is_live
+}
+
 toolchain_pkg_pretend() {
-       if [[ -n ${PRERELEASE}${SNAPSHOT} || ${PV} == *9999* ]] &&
+       if toolchain_is_unsupported &&
           [[ -z ${I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS} ]] ; then
                die "Please \`export I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS=1\` 
or define it" \
                        "in your make.conf if you want to use this version."
@@ -451,49 +468,37 @@ toolchain_pkg_setup() {
 #---->> src_unpack <<----
 
 toolchain_src_unpack() {
-       if [[ ${PV} == *9999* ]]; then
-               git-2_src_unpack
-       else
-               gcc_quick_unpack
+       if tc_is_live ; then
+               git-r3_src_unpack
        fi
+
+       default_src_unpack
 }
 
-gcc_quick_unpack() {
-       pushd "${WORKDIR}" > /dev/null
-       export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
-       export UCLIBC_GCC_VER=${UCLIBC_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}}
+#---->> src_prepare <<----
 
-       if [[ -n ${GCC_A_FAKEIT} ]] ; then
-               unpack ${GCC_A_FAKEIT}
-       elif [[ -n ${PRERELEASE} ]] ; then
-               unpack gcc-${PRERELEASE}.tar.bz2
-       elif [[ -n ${SNAPSHOT} ]] ; then
-               if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 
|| tc_version_is_at_least 7.2 ; then
-                       unpack gcc-${SNAPSHOT}.tar.xz
-               else
-                       unpack gcc-${SNAPSHOT}.tar.bz2
-               fi
-       elif [[ ${PV} != *9999* ]] ; then
-               if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 
|| tc_version_is_at_least 7.2 ; then
-                       unpack gcc-${GCC_RELEASE_VER}.tar.xz
-               else
-                       unpack gcc-${GCC_RELEASE_VER}.tar.bz2
-               fi
-               # We want branch updates to be against a release tarball
-               if [[ -n ${BRANCH_UPDATE} ]] ; then
-                       pushd "${S}" > /dev/null
-                       epatch 
"${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
-                       popd > /dev/null
-               fi
-       fi
+# '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}"
 
        if [[ -n ${D_VER} ]] && use d ; then
-               pushd "${S}"/gcc > /dev/null
-               unpack gdc-${D_VER}-src.tar.bz2
-               cd ..
+               mv "${WORKDIR}"/d gcc/d || die
                ebegin "Adding support for the D language"
                ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
                if ! eend $? ; then
@@ -502,58 +507,20 @@ gcc_quick_unpack() {
                        eerror "  ${T}/dgcc.log"
                        die "failed to include the D language"
                fi
-               popd > /dev/null
        fi
 
-       [[ -n ${PATCH_VER} ]] && \
-               unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
-
-       [[ -n ${UCLIBC_VER} ]] && \
-               unpack 
gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2
-
-       if want_pie ; then
-               if [[ -n ${PIE_CORE} ]] ; then
-                       unpack ${PIE_CORE}
-               else
-                       unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2
-               fi
-               [[ -n ${SPECS_VER} ]] && \
-                       unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2
-       fi
-
-       use_if_iuse boundschecking && unpack 
"bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
-
-       [[ -n ${CYGWINPORTS_GITREV} ]] && use elibc_Cygwin && unpack 
"gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz"
-
-       popd > /dev/null
-}
-
-#---->> src_prepare <<----
-
-toolchain_src_prepare() {
-       export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
-       cd "${S}"
-
-       if ! use vanilla ; then
-               if [[ -n ${PATCH_VER} ]] ; then
-                       guess_patch_type_in_dir "${WORKDIR}"/patch
-                       EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
-                       epatch "${WORKDIR}"/patch
-                       BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} 
p${PATCH_VER}"
-               fi
-               if [[ -n ${UCLIBC_VER} ]] ; then
-                       guess_patch_type_in_dir "${WORKDIR}"/uclibc
-                       EPATCH_MULTI_MSG="Applying uClibc patches ..." \
-                       epatch "${WORKDIR}"/uclibc
-               fi
-       fi
+       do_gcc_gentoo_patches
        do_gcc_HTB_patches
        do_gcc_PIE_patches
        do_gcc_CYGWINPORTS_patches
 
+       if tc_is_live ; then
+               BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, commit 
${EGIT_VERSION}"
+       fi
+
        case ${EAPI:-0} in
                5*) epatch_user;;
-               6) eapply_user ;;
+               6|7) eapply_user ;;
                *) die "Update toolchain_src_prepare() for ${EAPI}." ;;
        esac
 
@@ -574,14 +541,8 @@ toolchain_src_prepare() {
                "${S}"/gcc/config/darwin.h || die "sed gcc/config/darwin.h 
failed"
        # add prefixed Frameworks to default search paths (may want to
        # change this in a cross-compile)
-       # 2018-06-20 (grobian): disabled this because
-       #                       1. no packages seem to use this
-       #                       2. absence of this dir causes
-       #                          warnings->errors with gcc-7
-       #                       3. after 2. would need to create the dir
-       #                          somewhere, but 1. still applies
-       #sed -i -e "/\"\/System\/Library\/Frameworks\"\,/i\ \    
\"${EPREFIX}/Frameworks\"\, " \
-       #       "${S}"/gcc/config/darwin-c.c || die "sed gcc/config/darwin-c.c 
failed"
+       sed -i -e "/\"\/System\/Library\/Frameworks\"\,/i\ \    
\"${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
@@ -602,13 +563,10 @@ toolchain_src_prepare() {
        gcc_version_patch
 
        if tc_version_is_at_least 4.1 ; then
-               if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} ]] ; then
-                       # BASE-VER must be a three-digit version number
-                       # followed by an optional -pre string
-                       #   eg. 4.5.1, 4.6.2-pre20120213, 4.7.0-pre9999
-                       # If BASE-VER differs from ${PV/_/-} then libraries get 
installed in
-                       # the wrong directory.
-                       echo ${PV/_/-} > "${S}"/gcc/BASE-VER
+               local actual_version=$(< "${S}"/gcc/BASE-VER)
+               if [[ "${GCC_RELEASE_VER}" != "${actual_version}" ]] ; then
+                       eerror "'${S}/gcc/BASE-VER' contains 
'${actual_version}', expected '${GCC_RELEASE_VER}'"
+                       die "Please set 'TOOLCHAIN_GCC_PV' to 
'${actual_version}'"
                fi
        fi
 
@@ -659,8 +617,11 @@ toolchain_src_prepare() {
        sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
 
        # Prevent new texinfo from breaking old versions (see #198182, #464008)
-       tc_version_is_at_least 4.1 && epatch 
"${FILESDIR}"/gcc-configure-texinfo.patch
+       if tc_version_is_at_least 4.1; then
+               tc_apply_patches "Remove texinfo (bug #198182, bug #464008)" 
"${FILESDIR}"/gcc-configure-texinfo.patch
+       fi
 
+       # >=gcc-4
        if [[ -x contrib/gcc_update ]] ; then
                einfo "Touching generated files"
                ./contrib/gcc_update --touch | \
@@ -670,17 +631,23 @@ toolchain_src_prepare() {
        fi
 }
 
-guess_patch_type_in_dir() {
-       [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
-               && EPATCH_SUFFIX="patch.bz2" \
-               || EPATCH_SUFFIX="patch"
+do_gcc_gentoo_patches() {
+       if ! use vanilla ; then
+               if [[ -n ${PATCH_VER} ]] ; then
+                       tc_apply_patches "Applying Gentoo patches ..." 
"${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
+               fi
+       fi
 }
 
 do_gcc_HTB_patches() {
        use_if_iuse boundschecking || return 0
 
        # modify the bounds checking patch with a regression patch
-       epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
+       tc_apply_patches "Bounds checking patch" 
"${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
        BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, 
HTB-${HTB_GCC_VER}-${HTB_VER}"
 }
 
@@ -688,23 +655,7 @@ do_gcc_PIE_patches() {
        want_pie || return 0
        use vanilla && return 0
 
-       if tc_version_is_at_least 4.3.2 ; then
-               guess_patch_type_in_dir "${WORKDIR}"/piepatch/
-               EPATCH_MULTI_MSG="Applying pie patches ..." \
-               epatch "${WORKDIR}"/piepatch/
-       else
-               guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream
-
-               # corrects startfile/endfile selection and shared/static/pie 
flag usage
-               EPATCH_MULTI_MSG="Applying upstream pie patches ..." \
-               epatch "${WORKDIR}"/piepatch/upstream
-               # adds non-default pie support (rs6000)
-               EPATCH_MULTI_MSG="Applying non-default pie patches ..." \
-               epatch "${WORKDIR}"/piepatch/nondef
-               # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is 
defined
-               EPATCH_MULTI_MSG="Applying default pie patches ..." \
-               epatch "${WORKDIR}"/piepatch/def
-       fi
+       tc_apply_patches "Applying pie patches ..." 
"${WORKDIR}"/piepatch/*.patch
 
        BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
 }
@@ -713,21 +664,18 @@ do_gcc_CYGWINPORTS_patches() {
        [[ -n ${CYGWINPORTS_GITREV} ]] || return 0
        use elibc_Cygwin || return 0
 
-       local -a patches
        local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
-       readarray -t patches < <(sed -e '1,/PATCH_URI="/d;/"/,$d' < 
"${d}"/gcc.cygport)
-       for p in ${patches[*]}; do
-               epatch "${d}/${p}"
-       done
+       # readarray -t is available since bash-4.4 only, #690686
+       local patches=( $(sed -e '1,/PATCH_URI="/d;/"/,$d' < 
"${d}"/gcc.cygport) )
+       tc_apply_patches "Applying cygwin port patches ..." ${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
+       # 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
@@ -742,7 +690,10 @@ make_gcc_hard() {
                        einfo "Updating gcc to use automatic SSP building ..."
                fi
                if use_if_iuse hardened ; then
-                       # Will add some optimatizion as default.
+                       # Will add some hardened options as default, like:
+                       # -fstack-clash-protection
+                       # -z now
+                       # see *_all_extra-options.patch gcc patches.
                        gcc_hard_flags+=" -DEXTRA_OPTIONS"
                        # rebrand to make bug reports easier
                        
BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
@@ -845,8 +796,7 @@ gcc_version_patch() {
        # gcc-4.3+ has configure flags (whoo!)
        tc_version_is_at_least 4.3 && return 0
 
-       local version_string=${GCC_CONFIG_VER}
-       [[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}"
+       local version_string=${GCC_RELEASE_VER}
 
        einfo "patching gcc version: ${version_string} 
(${BRANDING_GCC_PKGVERSION})"
 
@@ -995,9 +945,9 @@ toolchain_src_configure() {
        tc_version_is_at_least 3.4 || confgcc+=( --disable-libunwind-exceptions 
)
 
        # Use the default ("release") checking because upstream usually neglects
-       # to test "disabled" so it has a history of breaking. #317217
+       # to test "disabled" so it has a history of breaking. bug #317217
        if tc_version_is_at_least 3.4 && in_iuse debug ; then
-               # The "release" keyword is new to 4.0. #551636
+               # 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})}" )
        fi
@@ -1015,12 +965,12 @@ toolchain_src_configure() {
 
        # 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.  #411681
+       # going to link in -lrt to all C++ apps. bug #411681
        if tc_version_is_at_least 4.4 && is_cxx ; then
                confgcc+=( --enable-libstdcxx-time )
        fi
 
-       # Build compiler using LTO
+       # Build compiler itself using LTO
        if tc_version_is_at_least 9.1 && use_if_iuse lto ; then
                confgcc+=( --with-build-config=bootstrap-lto )
        fi
@@ -1033,7 +983,9 @@ toolchain_src_configure() {
        # The jit language requires this.
        is_jit && confgcc+=( --enable-host-shared )
 
-       # # Turn on the -Wl,--build-id flag by default for ELF targets. #525942
+       # build-id was disabled for file collisions: bug #526144
+       #
+       # # Turn on the -Wl,--build-id flag by default for ELF targets. bug 
#525942
        # # This helps with locating debug files.
        # case ${CTARGET} in
        # *-linux-*|*-elf|*-eabi)
@@ -1059,7 +1011,7 @@ toolchain_src_configure() {
                # disable a bunch of features or gcc goes boom
                local needed_libc=""
                case ${CTARGET} in
-               *-linux)                 needed_libc=no-fucking-clue;;
+               *-linux)                 needed_libc=error-unknown-libc;;
                *-dietlibc)              needed_libc=dietlibc;;
                *-elf|*-eabi)
                        needed_libc=newlib
@@ -1074,10 +1026,12 @@ toolchain_src_configure() {
                *-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 #291870
+                       then
                                confgcc+=( --disable-shared )
                        fi
                        needed_libc=uclibc-ng
@@ -1138,10 +1092,12 @@ toolchain_src_configure() {
        # destructors", but apparently requires glibc.
        case ${CTARGET} in
        *-uclibc*)
-               confgcc+=(
-                       --disable-__cxa_atexit
-                       $(use_enable nptl tls)
-               )
+               if tc_has_feature nptl ; then
+                       confgcc+=(
+                               --disable-__cxa_atexit
+                               $(use_enable nptl tls)
+                       )
+               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 )
@@ -1254,6 +1210,15 @@ toolchain_src_configure() {
                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}) )
@@ -1281,10 +1246,11 @@ toolchain_src_configure() {
        ### library options
 
        if tc_version_is_between 3.0 7.0 ; then
-               if ! is_gcj ; then
+               if is_gcj ; then
+                       confgcc+=( --disable-gjdoc )
+                       use awt && confgcc+=( --enable-java-awt=gtk )
+               else
                        confgcc+=( --disable-libgcj )
-               elif use awt ; then
-                       confgcc+=( --enable-java-awt=gtk )
                fi
        fi
 
@@ -1358,6 +1324,10 @@ toolchain_src_configure() {
                )
        fi
 
+       if in_iuse zstd ; then
+               confgcc+=( $(use_with zstd) )
+       fi
+
        # newer gcc's come with libquadmath, but only fortran uses
        # it, so auto punt it when we don't care
        if tc_version_is_at_least 4.6 && ! is_fortran ; then
@@ -1370,14 +1340,15 @@ toolchain_src_configure() {
                confgcc+=( --disable-lto )
        fi
 
-       # graphite was added in 4.4 but we only support it in 4.8+ due to 
external
-       # library issues.  #448024
-       if tc_version_is_at_least 5.0 && in_iuse graphite ; then
+       # graphite was added in 4.4 but we only support it in 6.5+ due to 
external
+       # library issues.  #448024, #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 )
-       elif tc_version_is_at_least 4.8 && in_iuse graphite ; then
-               confgcc+=( $(use_with graphite cloog) )
-               use graphite && confgcc+=( --disable-isl-version-check )
+       elif tc_version_is_at_least 5.0 ; then
+               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
@@ -1445,7 +1416,8 @@ downgrade_arch_flags() {
        local arch bver i isa myarch mytune rep ver
 
        bver=${1:-${GCC_BRANCH_VER}}
-       [[ $(gcc-version) < ${bver} ]] && return 0
+       # Don't perform downgrade if running gcc is older than ebuild's.
+       tc_version_is_at_least ${bver} $(gcc-version) || return 0
        [[ $(tc-arch) != amd64 && $(tc-arch) != x86 ]] && return 0
 
        myarch=$(get-flag march)
@@ -1453,7 +1425,7 @@ downgrade_arch_flags() {
 
        # If -march=native isn't supported we have to tease out the actual arch
        if [[ ${myarch} == native || ${mytune} == native ]] ; then
-               if [[ ${bver} < 4.2 ]] ; 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}
@@ -1461,10 +1433,10 @@ downgrade_arch_flags() {
        fi
 
        # Handle special -mtune flags
-       [[ ${mytune} == intel && ${bver} < 4.9 ]] && replace-cpu-flags intel 
generic
-       [[ ${mytune} == generic && ${bver} < 4.2 ]] && filter-flags '-mtune=*'
+       [[ ${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=*'
-       [[ ${bver} < 3.4 ]] && filter-flags '-mtune=*'
+       tc_version_is_at_least 3.4 ${bver} || filter-flags '-mtune=*'
 
        # "added" "arch" "replacement"
        local archlist=(
@@ -1514,8 +1486,8 @@ downgrade_arch_flags() {
 
                [[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue
 
-               if [[ ${ver} > ${bver} ]] ; then
-                       einfo "Replacing ${myarch} (added in gcc ${ver}) with 
${rep}..."
+               if ! tc_version_is_at_least ${ver} ${bver}; then
+                       einfo "Downgrading '${myarch}' (added in gcc ${ver}) 
with '${rep}'..."
                        [[ ${myarch} == ${arch} ]] && replace-cpu-flags 
${myarch} ${rep}
                        [[ ${mytune} == ${arch} ]] && replace-cpu-flags 
${mytune} ${rep}
                        continue
@@ -1563,13 +1535,17 @@ downgrade_arch_flags() {
        for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do
                ver=${isalist[i]}
                isa=${isalist[i + 1]}
-               [[ ${ver} > ${bver} ]] && filter-flags ${isa} ${isa/-m/-mno-}
+               tc_version_is_at_least ${ver} ${bver} || filter-flags ${isa} 
${isa/-m/-mno-}
        done
 }
 
 gcc_do_filter_flags() {
+       # Be conservative here:
+       # - don't allow -O3 and like to over-optimize libgcc # 701786
+       # - don't allow -O0 to generate potentially invalid startup code
        strip-flags
-       replace-flags -O? -O2
+       filter-flags '-O?'
+       append-flags -O2
 
        # dont want to funk ourselves
        filter-flags '-mabi*' -m31 -m32 -m64
@@ -1596,6 +1572,13 @@ gcc_do_filter_flags() {
                filter-flags -Wstack-protector
        fi
 
+       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
+
        if tc_version_is_at_least 3.4 ; then
                case $(tc-arch) in
                        amd64|x86)
@@ -1808,11 +1791,11 @@ gcc_do_make() {
 #---->> src_test <<----
 
 toolchain_src_test() {
-       if use ${GCC_EBUILD_TEST_FLAG} ; then
-               cd "${WORKDIR}"/build
-               # enable verbose test run and result logging
-               emake -k check RUNTESTFLAGS='-a -v'
-       fi
+       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.
+       SANDBOX_ON=0 LD_PRELOAD= emake -k check
 }
 
 #---->> src_install <<----
@@ -1820,7 +1803,7 @@ toolchain_src_test() {
 toolchain_src_install() {
        cd "${WORKDIR}"/build
 
-       # Do allow symlinks in private gcc include dir as this can break the 
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
@@ -1866,6 +1849,7 @@ toolchain_src_install() {
 
        dodir /etc/env.d/gcc
        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
@@ -1878,7 +1862,7 @@ toolchain_src_install() {
        cd "${D}"${BINPATH}
        # 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 ; do
+       for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo gnat* ; do
                # For some reason, g77 gets made instead of ${CTARGET}-g77...
                # this should take care of that
                if [[ -f ${x} ]] ; then
@@ -1917,15 +1901,17 @@ toolchain_src_install() {
                fi
        fi
 
-       # TODO: implement stripping (we use RESTRICT=strip)
-       # As gcc installs object files both build against ${CHOST} and 
${CTARGET}
-       # we will ned to run stripping using different tools:
+       # As gcc installs object files built against bost ${CHOST} and 
${CTARGET}
+       # ideally we will need to strip them using different tools:
        # Using ${CHOST} tools:
        #  - "${D}${BINPATH}"
        #  - (for is_crosscompile) "${D}${HOSTLIBPATH}"
        #  - "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
        # Using ${CTARGET} tools:
        #  - "${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}"
 
        cd "${S}"
        if is_crosscompile; then
@@ -1950,13 +1936,6 @@ toolchain_src_install() {
        # prune empty dirs left behind
        find "${ED}" -depth -type d -delete 2>/dev/null
 
-       # install testsuite results
-       if use ${GCC_EBUILD_TEST_FLAG}; then
-               docinto testsuite
-               find "${WORKDIR}"/build -type f -name "*.sum" -exec dodoc {} +
-               find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -exec 
dodoc {} +
-       fi
-
        # Rather install the script, else portage with changing $FILESDIR
        # between binary and source package borks things ....
        if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
@@ -2012,7 +1991,7 @@ toolchain_src_install() {
        # for people who are testing as non-root.
        chown -R ${PORTAGE_INST_UID:-0}:${PORTAGE_INST_GID:-0} "${D}${LIBPATH}" 
2>/dev/null
 
-       # Move pretty-printers to gdb datadir to shut ldconfig up
+       # Installing gdb pretty-printers into gdb-specific location.
        local py 
gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/}
        pushd "${D}${LIBPATH}" >/dev/null
        for py in $(find . -name '*-gdb.py') ; do
@@ -2173,8 +2152,6 @@ create_gcc_env_entry() {
        fi
 
        cat <<-EOF > ${gcc_envd_file}
-       PATH="${BINPATH}"
-       ROOTPATH="${BINPATH}"
        GCC_PATH="${BINPATH}"
        LDPATH="${ldpaths}"
        MANPATH="${DATAPATH}/man"
@@ -2186,6 +2163,20 @@ create_gcc_env_entry() {
        EOF
 }
 
+create_revdep_rebuild_entry() {
+       local 
revdep_rebuild_base="/etc/revdep-rebuild/05cross-${CTARGET}-${GCC_CONFIG_VER}"
+       local revdep_rebuild_file="${ED}${revdep_rebuild_base}"
+
+       is_crosscompile || return 0
+
+       dodir /etc/revdep-rebuild
+       cat <<-EOF > "${revdep_rebuild_file}"
+       # Generated by ${CATEGORY}/${PF}
+       # Ignore libraries built for ${CTARGET}, https://bugs.gentoo.org/692844.
+       SEARCH_DIRS_MASK="${LIBPATH}"
+       EOF
+}
+
 copy_minispecs_gcc_specs() {
        # on gcc 6 we don't need minispecs
        if tc_version_is_at_least 6.0 ; then
@@ -2279,12 +2270,7 @@ toolchain_pkg_postinst() {
                cp "${ROOT%/}${DATAPATH}"/c{89,99} "${EROOT%/}"/usr/bin/ 
2>/dev/null
        fi
 
-       if use ${GCC_EBUILD_TEST_FLAG} ; then
-               elog "Testsuite results have been installed into 
/usr/share/doc/${PF}/testsuite"
-               echo
-       fi
-
-       if [[ -n ${PRERELEASE}${SNAPSHOT} ]] ; then
+       if toolchain_is_unsupported ; then
                einfo "This GCC ebuild is provided for your convenience, and 
the use"
                einfo "of this compiler is not supported by the Gentoo 
Developers."
                einfo "Please report bugs to upstream at 
http://gcc.gnu.org/bugzilla/";
@@ -2292,6 +2278,7 @@ toolchain_pkg_postinst() {
 }
 
 toolchain_pkg_postrm() {
+       do_gcc_config
        if [[ ! ${ROOT%/} && -f 
${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
                eselect compiler-shadow clean all
        fi
@@ -2304,6 +2291,7 @@ toolchain_pkg_postrm() {
        # 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
+                       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}
@@ -2315,15 +2303,8 @@ toolchain_pkg_postrm() {
        [[ ${ROOT%/} ]] && return 0
 
        if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
-               # make sure the profile is sane during same-slot upgrade #289403
-               do_gcc_config
-
                einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'"
                fix_libtool_files.sh ${GCC_RELEASE_VER}
-               if [[ -n ${BRANCH_UPDATE} ]] ; then
-                       einfo "Running 'fix_libtool_files.sh 
${GCC_RELEASE_VER}-${BRANCH_UPDATE}'"
-                       fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}
-               fi
        fi
 
        return 0
@@ -2425,7 +2406,6 @@ is_ada() {
 
 is_cxx() {
        gcc-lang-supported 'c++' || return 1
-       ! is_crosscompile && tc_version_is_at_least 4.8 && return 0
        use_if_iuse cxx
 }
 

Reply via email to