commit:     a0a7ca1dc65b9d19def3e3c5f7010540449c9dd5
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  6 12:48:14 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun  6 12:48:14 2018 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=a0a7ca1d

eclass: sync with gx86

 eclass/autotools.eclass          |  34 +++++---
 eclass/db.eclass                 |  29 +++----
 eclass/flag-o-matic.eclass       |  83 ++++++++++---------
 eclass/gnuconfig.eclass          |   1 -
 eclass/python-utils-r1.eclass    |  49 +++++++----
 eclass/toolchain-binutils.eclass |  12 +--
 eclass/toolchain-funcs.eclass    |  62 ++++++++++----
 eclass/toolchain.eclass          | 174 ++++++++++++++++++++++++---------------
 eclass/user.eclass               |  31 ++-----
 9 files changed, 279 insertions(+), 196 deletions(-)

diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass
index b6efa541de..f30ac7414f 100644
--- a/eclass/autotools.eclass
+++ b/eclass/autotools.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: autotools.eclass
@@ -46,16 +46,20 @@ inherit libtool
 # @INTERNAL
 # @DESCRIPTION:
 # CONSTANT!
-# The latest major version/slot of automake available on each arch.  #312315
-# We should list both the latest stable, and the latest unstable.  #465732
-# This way the stable builds will still work, but the unstable are allowed
-# to build & test things for us ahead of time (if they have it installed).
+# The latest major unstable and stable version/slot of automake available
+# on each arch.
+# List latest unstable version first to boost testing adoption rate because
+# most package manager dependency resolver will pick the first suitable
+# version.
 # If a newer slot is stable on any arch, and is NOT reflected in this list,
 # then circular dependencies may arise during emerge @system bootstraps.
+# 
+# See bug 312315 and 465732 for further information and context.
+# 
 # Do NOT change this variable in your ebuilds!
 # If you want to force a newer minor version, you can specify the correct
 # WANT value by using a colon:  <PV>:<WANT_AUTOMAKE>
-_LATEST_AUTOMAKE=( 1.15:1.15 )
+_LATEST_AUTOMAKE=( 1.16.1:1.16 1.15.1:1.15 )
 
 _automake_atom="sys-devel/automake"
 _autoconf_atom="sys-devel/autoconf"
@@ -110,7 +114,7 @@ RDEPEND=""
 # @ECLASS-VARIABLE: AUTOTOOLS_AUTO_DEPEND
 # @DESCRIPTION:
 # Set to 'no' to disable automatically adding to DEPEND.  This lets
-# ebuilds former conditional depends by using ${AUTOTOOLS_DEPEND} in
+# ebuilds form conditional depends by using ${AUTOTOOLS_DEPEND} in
 # their own DEPEND string.
 : ${AUTOTOOLS_AUTO_DEPEND:=yes}
 if [[ ${AUTOTOOLS_AUTO_DEPEND} != "no" ]] ; then
@@ -433,7 +437,7 @@ config_rpath_update() {
 # @DESCRIPTION:
 # Process the WANT_AUTO{CONF,MAKE} flags.
 autotools_env_setup() {
-       # We do the "latest" → version switch here because it solves
+       # We do the "latest" → version switch here because it solves
        # possible order problems, see bug #270010 as an example.
        # During bootstrap in prefix there might be no automake merged yet
        # due to --nodeps, but still available somewhere in PATH.
@@ -442,9 +446,17 @@ autotools_env_setup() {
                ROOT=/ has_version "sys-devel/automake"; then
                local pv
                for pv in ${_LATEST_AUTOMAKE[@]/#*:} ; do
-                       # has_version respects ROOT, but in this case, we don't 
want it to,
-                       # thus "ROOT=/" prefix:
-                       ROOT=/ has_version "=sys-devel/automake-${pv}*" && 
export WANT_AUTOMAKE="${pv}"
+                       # Break on first hit to respect _LATEST_AUTOMAKE order.
+                       local hv_args=""
+                       case ${EAPI:-0} in
+                               5|6)
+                                       hv_args="--host-root"
+                                       ;;
+                               7)
+                                       hv_args="-b"
+                                       ;;
+                       esac
+                       ROOT=/ has_version ${hv_args} 
"=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}" && break
                done
                [[ ${WANT_AUTOMAKE} == "latest" ]] && \
                        die "Cannot find the latest automake! Tried 
${_LATEST_AUTOMAKE[*]}"

diff --git a/eclass/db.eclass b/eclass/db.eclass
index 8973031ba9..7f80f13823 100644
--- a/eclass/db.eclass
+++ b/eclass/db.eclass
@@ -1,11 +1,12 @@
-# Copyright 1999-2013 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/db.eclass,v 1.49 2013/07/21 09:23:45 
pacho Exp $
-# This is a common location for functions used in the sys-libs/db ebuilds
-#
-# Bugs: [email protected]
 
-inherit eutils multilib
+# @ECLASS: db.eclass
+# @MAINTAINER:
+# [email protected]
+# @BLURB: Internal eclass used by sys-libs/db ebuilds
+
+inherit eutils multilib multiprocessing
 
 IUSE="doc test examples"
 
@@ -22,11 +23,9 @@ db_fix_so() {
        cd "${LIB}"
 
        # first clean up old symlinks
-       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname)" 
-delete
-       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname 
"[23]")" -delete
-       find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname)" -delete 
#519364
-       find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname "[23]")" 
-delete #519364
-       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -delete
+       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*'"$(get_libname)" 
-exec rm \{} \;
+       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*'"$(get_libname 
"[23]")" -exec rm \{} \;
+       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -exec rm \{} \;
 
        # now rebuild all the correct ones
        for ext in so a dylib sl; do
@@ -152,12 +151,10 @@ db_src_install_usrlibcleanup() {
                mv "${LIB}/libdb_cxx.a" "${LIB}/libdb_cxx-${SLOT}.a"
        fi
 
-       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname)" 
-delete
-       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1_-]*'"$(get_libname 
"[23]")" -delete
-       find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname)" -delete 
#519364
-       find "${LIB}" -maxdepth 1 -type l -name "libdb$(get_libname "[23]")" 
-delete #519364
+       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*'"$(get_libname)" 
-exec rm \{} \;
+       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*'"$(get_libname 
"[23]")" -exec rm \{} \;
        einfo "removing unversioned static archives"
-       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -delete
+       find "${LIB}" -maxdepth 1 -type l -name 'libdb[1._-]*a' -exec rm \{} \;
 
        rm -f \
                "${ED}"/usr/include/{db,db_185}.h \

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 14922d1f58..3f9fd205c4 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -1,6 +1,5 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id$
 
 # @ECLASS: flag-o-matic.eclass
 # @MAINTAINER:
@@ -17,7 +16,7 @@ inherit eutils toolchain-funcs multilib
 
 # Return all the flag variables that our high level funcs operate on.
 all-flag-vars() {
-       echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
+       echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
 }
 
 # {C,CPP,CXX,CCAS,F,FC,LD}FLAGS that we allow in strip-flags
@@ -25,10 +24,10 @@ all-flag-vars() {
 setup-allowed-flags() {
        ALLOWED_FLAGS=(
                -pipe -O '-O[12sg]' -mcpu -march -mtune
-               '-fstack-protector*' '-fsanitize*'
+               '-fstack-protector*' '-fsanitize*' '-fstack-check*' 
-fno-stack-check
                -fbounds-check -fbounds-checking -fno-strict-overflow
                -fno-PIE -fno-pie -nopie -no-pie -fno-unit-at-a-time
-               -g '-g[0-9]' -ggdb '-ggdb[0-9]' '-gdwarf-*' gstabs -gstabs+
+               -g '-g[0-9]' -ggdb '-ggdb[0-9]' '-gdwarf-*' gstabs -gstabs+ -gz
                -fno-ident -fpermissive -frecord-gcc-switches
                '-fdiagnostics*' '-fplugin*'
                '-W*' -w
@@ -117,7 +116,7 @@ _filter-var() {
                done
                new+=( "${f}" )
        done
-       eval export ${var}=\""${new[*]}"\"
+       export ${var}="${new[*]}"
 }
 
 # @FUNCTION: filter-flags
@@ -274,7 +273,7 @@ replace-flags() {
                        [[ ${f} == ${1} ]] && f=${2}
                        new+=( "${f}" )
                done
-               eval export ${var}=\""${new[*]}"\"
+               export ${var}="${new[*]}"
        done
 
        return 0
@@ -299,9 +298,8 @@ replace-cpu-flags() {
 }
 
 _is_flagq() {
-       local x var
-       eval var=\""\${$1[*]}"\"
-       for x in ${var} ; do
+       local x var="$1[*]"
+       for x in ${!var} ; do
                [[ ${x} == $2 ]] && return 0
        done
        return 1
@@ -415,7 +413,7 @@ strip-flags() {
                if [[ ${!var} != "${new[*]}" ]] ; then
                        einfo "strip-flags: ${var}: changed '${!var}' to 
'${new[*]}'"
                fi
-               eval export ${var}=\""${new[*]}"\"
+               export ${var}="${new[*]}"
        done
 
        set +f  # re-enable pathname expansion
@@ -426,9 +424,9 @@ strip-flags() {
 test-flag-PROG() {
        local comp=$1
        local lang=$2
-       local flag=$3
+       shift 2
 
-       [[ -z ${comp} || -z ${flag} ]] && return 1
+       [[ -z ${comp} || -z $1 ]] && return 1
 
        local src=${T}/tf-${comp}-${SECONDS}.${lang}
        local cmdline=(
@@ -440,12 +438,21 @@ test-flag-PROG() {
                # don't use -o /dev/null: /usr/ccs/bin/as: File exists (Sun LD)
                -c -o "${src}.o"
        )
-       if "${cmdline[@]}" -x${lang} - </dev/null >/dev/null 2>&1 ; then
-               "${cmdline[@]}" "${flag}" -x${lang} - </dev/null >/dev/null 2>&1
+       if "${cmdline[@]}" -x${lang} - </dev/null &>/dev/null ; then
+               cmdline+=( "$@" -x${lang} - )
        else
                # don't use /dev/null as input: -xc flag needs not to exist 
#254120
                echo "int main() { return 0; }" > "${src}"
-               "${cmdline[@]}" "${flag}" -c -o "${src}.o" "${src}" >/dev/null 
2>&1
+               cmdline+=( "$@" -c -o "${src}.o" "${src}" )
+       fi
+
+       if ! "${cmdline[@]}" </dev/null &>/dev/null; then
+               # -Werror makes clang bail out on unused arguments as well;
+               # try to add -Qunused-arguments to work-around that
+               # other compilers don't support it but then, it's failure like
+               # any other
+               cmdline+=( -Qunused-arguments )
+               "${cmdline[@]}" </dev/null &>/dev/null
        fi
        local ret=$?
        rm -f "${src}"{,.o}
@@ -456,25 +463,25 @@ test-flag-PROG() {
 # @USAGE: <flag>
 # @DESCRIPTION:
 # Returns shell true if <flag> is supported by the C compiler, else returns 
shell false.
-test-flag-CC() { test-flag-PROG "CC" c "$1"; }
+test-flag-CC() { test-flag-PROG "CC" c "$@"; }
 
 # @FUNCTION: test-flag-CXX
 # @USAGE: <flag>
 # @DESCRIPTION:
 # Returns shell true if <flag> is supported by the C++ compiler, else returns 
shell false.
-test-flag-CXX() { test-flag-PROG "CXX" c++ "$1"; }
+test-flag-CXX() { test-flag-PROG "CXX" c++ "$@"; }
 
 # @FUNCTION: test-flag-F77
 # @USAGE: <flag>
 # @DESCRIPTION:
 # Returns shell true if <flag> is supported by the Fortran 77 compiler, else 
returns shell false.
-test-flag-F77() { test-flag-PROG "F77" f77 "$1"; }
+test-flag-F77() { test-flag-PROG "F77" f77 "$@"; }
 
 # @FUNCTION: test-flag-FC
 # @USAGE: <flag>
 # @DESCRIPTION:
 # Returns shell true if <flag> is supported by the Fortran 90 compiler, else 
returns shell false.
-test-flag-FC() { test-flag-PROG "FC" f95 "$1"; }
+test-flag-FC() { test-flag-PROG "FC" f95 "$@"; }
 
 test-flags-PROG() {
        local comp=$1
@@ -485,8 +492,21 @@ test-flags-PROG() {
 
        [[ -z ${comp} ]] && return 1
 
-       for x ; do
-               test-flag-${comp} "${x}" && flags+=( "${x}" )
+       while (( $# )); do
+               case "$1" in
+                       --param)
+                               if test-flag-${comp} "$1" "$2"; then
+                                       flags+=( "$1" "$2" )
+                               fi
+                               shift 2
+                               ;;
+                       *)
+                               if test-flag-${comp} "$1"; then
+                                       flags+=( "$1" )
+                               fi
+                               shift 1
+                               ;;
+               esac
        done
 
        echo "${flags[*]}"
@@ -547,6 +567,9 @@ strip-unsupported-flags() {
        export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
        export FFLAGS=$(test-flags-F77 ${FFLAGS})
        export FCFLAGS=$(test-flags-FC ${FCFLAGS})
+       # note: this does not verify the linker flags but it is enough
+       # to strip invalid C flags which are much more likely, #621274
+       export LDFLAGS=$(test-flags-CC ${LDFLAGS})
 }
 
 # @FUNCTION: get-flag
@@ -578,21 +601,7 @@ get-flag() {
 # WORKS. Non-multilib gcc will take both -m32 and -m64. If the flag works
 # return code is 0, else the return code is 1.
 has_m64() {
-       eqawarn "${FUNCNAME}: don't use this anymore"
-
-       # this doesnt test if the flag is accepted, it tests if the flag
-       # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
-       # please dont replace this function with test_flag in some future
-       # clean-up!
-
-       local temp="$(emktemp)"
-       echo "int main() { return(0); }" > "${temp}".c
-       MY_CC=$(tc-getCC)
-       ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1
-       local ret=$?
-       rm -f "${temp}".c
-       [[ ${ret} != 1 ]] && return 0
-       return 1
+       die "${FUNCNAME}: don't use this anymore"
 }
 
 has_m32() {

diff --git a/eclass/gnuconfig.eclass b/eclass/gnuconfig.eclass
index 7cfb7d38ea..3c8d98d6a9 100644
--- a/eclass/gnuconfig.eclass
+++ b/eclass/gnuconfig.eclass
@@ -1,6 +1,5 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/gnuconfig.eclass,v 1.36 2014/11/15 
06:20:07 vapier Exp $
 #
 # THIS ECLASS IS DEAD: It has been integrated into portage
 #

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 422a8223be..ed84c2680c 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: python-utils-r1.eclass
@@ -19,7 +19,7 @@
 # https://wiki.gentoo.org/wiki/Project:Python/python-utils-r1
 
 case "${EAPI:-0}" in
-       0|1|2|3|4|5|6)
+       0|1|2|3|4|5|6|7)
                ;;
        *)
                die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
@@ -169,7 +169,8 @@ _python_set_impls() {
 # Check whether the specified <impl> matches at least one
 # of the patterns following it. Return 0 if it does, 1 otherwise.
 #
-# <impl> should be in PYTHON_COMPAT form. The patterns can be either:
+# <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns can be
+# either:
 # a) fnmatch-style patterns, e.g. 'python2*', 'pypy'...
 # b) '-2' to indicate all Python 2 variants (= !python_is_python3)
 # c) '-3' to indicate all Python 3 variants (= python_is_python3)
@@ -186,7 +187,8 @@ _python_impl_matches() {
                elif [[ ${pattern} == -3 ]]; then
                        python_is_python3 "${impl}"
                        return
-               elif [[ ${impl} == ${pattern} ]]; then
+               # unify value style to allow lax matching
+               elif [[ ${impl/./_} == ${pattern/./_} ]]; then
                        return 0
                fi
        done
@@ -732,8 +734,8 @@ python_optimize() {
                        # 2) skip paths which do not exist
                        #    (python2.6 complains about them verbosely)
 
-                       if [[ ${f} == /* && -d ${D}${f} ]]; then
-                               set -- "${D}${f}" "${@}"
+                       if [[ ${f} == /* && -d ${D%/}${f} ]]; then
+                               set -- "${D%/}${f}" "${@}"
                        fi
                done < <("${PYTHON}" -c 'import sys; 
print("\0".join(sys.path))' || die)
 
@@ -743,7 +745,7 @@ python_optimize() {
        local d
        for d; do
                # make sure to get a nice path without //
-               local instpath=${d#${D}}
+               local instpath=${d#${D%/}}
                instpath=/${instpath##/}
 
                case "${EPYTHON}" in
@@ -968,7 +970,7 @@ python_domodule() {
                doins -r "${@}" || return ${?}
        )
 
-       python_optimize "${ED}/${d}"
+       python_optimize "${ED%/}/${d}"
 }
 
 # @FUNCTION: python_doheader
@@ -1130,9 +1132,20 @@ python_is_python3() {
 python_is_installed() {
        local impl=${1:-${EPYTHON}}
        [[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON"
+       local hasv_args=()
+
+       case ${EAPI:-0} in
+               0|1|2|3|4)
+                       local -x ROOT=/
+                       ;;
+               5|6)
+                       hasv_args+=( --host-root )
+                       ;;
+               *)
+                       hasv_args+=( -b )
+                       ;;
+       esac
 
-       # for has_version
-       local -x ROOT=/
        case "${impl}" in
                pypy|pypy3)
                        local append=
@@ -1141,13 +1154,13 @@ python_is_installed() {
                        fi
 
                        # be happy with just the interpeter, no need for the 
virtual
-                       has_version "dev-python/${impl}${append}" \
-                               || has_version "dev-python/${impl}-bin${append}"
+                       has_version "${hasv_args[@]}" 
"dev-python/${impl}${append}" \
+                               || has_version "${hasv_args[@]}" 
"dev-python/${impl}-bin${append}"
                        ;;
                *)
                        local PYTHON_PKG_DEP
                        python_export "${impl}" PYTHON_PKG_DEP
-                       has_version "${PYTHON_PKG_DEP}"
+                       has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
                        ;;
        esac
 }
@@ -1211,7 +1224,7 @@ python_fix_shebang() {
                                for i in "${split_shebang[@]}"; do
                                        case "${i}" in
                                                *"${EPYTHON}")
-                                                       debug-print 
"${FUNCNAME}: in file ${f#${D}}"
+                                                       debug-print 
"${FUNCNAME}: in file ${f#${D%/}}"
                                                        debug-print 
"${FUNCNAME}: shebang matches EPYTHON: ${shebang}"
 
                                                        # Nothing to do, move 
along.
@@ -1220,7 +1233,7 @@ python_fix_shebang() {
                                                        break
                                                        ;;
                                                *python|*python[23])
-                                                       debug-print 
"${FUNCNAME}: in file ${f#${D}}"
+                                                       debug-print 
"${FUNCNAME}: in file ${f#${D%/}}"
                                                        debug-print 
"${FUNCNAME}: rewriting shebang: ${shebang}"
 
                                                        if [[ ${i} == *python2 
]]; then
@@ -1270,7 +1283,7 @@ python_fix_shebang() {
                        fi
 
                        if [[ ! ${quiet} ]]; then
-                               einfo "Fixing shebang in ${f#${D}}."
+                               einfo "Fixing shebang in ${f#${D%/}}."
                        fi
 
                        if [[ ! ${error} ]]; then
@@ -1284,7 +1297,7 @@ python_fix_shebang() {
                                any_fixed=1
                        else
                                eerror "The file has incompatible shebang:"
-                               eerror "  file: ${f#${D}}"
+                               eerror "  file: ${f#${D%/}}"
                                eerror "  current shebang: ${shebang}"
                                eerror "  requested impl: ${EPYTHON}"
                                die "${FUNCNAME}: conversion of incompatible 
shebang requested"
@@ -1295,7 +1308,7 @@ python_fix_shebang() {
                        local cmd=eerror
                        [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn
 
-                       "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D}} did not 
match any fixable files."
+                       "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did 
not match any fixable files."
                        if [[ ${any_correct} ]]; then
                                "${cmd}" "All files have ${EPYTHON} shebang 
already."
                        else

diff --git a/eclass/toolchain-binutils.eclass b/eclass/toolchain-binutils.eclass
index 89c00e6228..095e5d196a 100644
--- a/eclass/toolchain-binutils.eclass
+++ b/eclass/toolchain-binutils.eclass
@@ -1,6 +1,5 @@
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id$
 #
 # Maintainer: Toolchain Ninjas <[email protected]>
 #
@@ -76,11 +75,12 @@ add_src_uri() {
        else
                a+=".bz2"
        fi
-       set -- mirror://gentoo https://dev.gentoo.org/~vapier/dist
+       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}}"
 }
-add_src_uri binutils-${BVER}-patches-${PATCHVER}.tar ${PATCHVER}
-add_src_uri binutils-${BVER}-uclibc-patches-${UCLIBC_PATCHVER}.tar 
${UCLIBC_PATCHVER}
+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
@@ -218,7 +218,7 @@ toolchain-binutils_src_prepare() {
 }
 
 _eprefix_init() {
-       has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
+       has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
 }
 
 # Intended for ebuilds to override to set their own versioning information.

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index d9450c3584..14d7aea8b4 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: toolchain-funcs.eclass
@@ -40,7 +40,13 @@ _tc-getPROG() {
        export ${var}="${prog[*]}"
        echo "${!var}"
 }
-tc-getBUILD_PROG() { _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" 
"${@:2}"; }
+tc-getBUILD_PROG() {
+       local vars="BUILD_$1 $1_FOR_BUILD HOST$1"
+       # respect host vars if not cross-compiling
+       # https://bugs.gentoo.org/630282
+       tc-is-cross-compiler || vars+=" $1"
+       _tc-getPROG CBUILD "${vars}" "${@:2}"
+}
 tc-getPROG() { _tc-getPROG CHOST "$@"; }
 
 # @FUNCTION: tc-getAR
@@ -241,13 +247,21 @@ tc-stack-grows-down() {
 # Export common build related compiler settings.
 tc-export_build_env() {
        tc-export "$@"
-       # Some build envs will initialize vars like:
-       # : ${BUILD_LDFLAGS:-${LDFLAGS}}
-       # So make sure all variables are non-empty. #526734
-       : ${BUILD_CFLAGS:=-O1 -pipe}
-       : ${BUILD_CXXFLAGS:=-O1 -pipe}
-       : ${BUILD_CPPFLAGS:= }
-       : ${BUILD_LDFLAGS:= }
+       if tc-is-cross-compiler; then
+               # Some build envs will initialize vars like:
+               # : ${BUILD_LDFLAGS:-${LDFLAGS}}
+               # So make sure all variables are non-empty. #526734
+               : ${BUILD_CFLAGS:=-O1 -pipe}
+               : ${BUILD_CXXFLAGS:=-O1 -pipe}
+               : ${BUILD_CPPFLAGS:= }
+               : ${BUILD_LDFLAGS:= }
+       else
+               # https://bugs.gentoo.org/654424
+               : ${BUILD_CFLAGS:=${CFLAGS}}
+               : ${BUILD_CXXFLAGS:=${CXXFLAGS}}
+               : ${BUILD_CPPFLAGS:=${CPPFLAGS}}
+               : ${BUILD_LDFLAGS:=${LDFLAGS}}
+       fi
        export BUILD_{C,CXX,CPP,LD}FLAGS
 
        # Some packages use XXX_FOR_BUILD.
@@ -377,11 +391,28 @@ tc-ld-disable-gold() {
        local path_ld=$(which "${bfd_ld}" 2>/dev/null)
        [[ -e ${path_ld} ]] && export LD=${bfd_ld}
 
-       # Set up LDFLAGS to select gold based on the gcc version.
-       local major=$(gcc-major-version "$@")
-       local minor=$(gcc-minor-version "$@")
-       if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]] ; then
-               # <=gcc-4.7 requires some coercion.  Only works if bfd exists.
+       # Set up LDFLAGS to select gold based on the gcc / clang version.
+       local fallback="true"
+       if tc-is-gcc; then
+               local major=$(gcc-major-version "$@")
+               local minor=$(gcc-minor-version "$@")
+               if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 
]]; then
+                       # gcc-4.8+ supports -fuse-ld directly.
+                       export LDFLAGS="${LDFLAGS} -fuse-ld=bfd"
+                       fallback="false"
+               fi
+       elif tc-is-clang; then
+               local major=$(clang-major-version "$@")
+               local minor=$(clang-minor-version "$@")
+               if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 
]]; then
+                       # clang-3.5+ supports -fuse-ld directly.
+                       export LDFLAGS="${LDFLAGS} -fuse-ld=bfd"
+                       fallback="false"
+               fi
+       fi
+       if [[ ${fallback} == "true" ]] ; then
+               # <=gcc-4.7 and <=clang-3.4 require some coercion.
+               # Only works if bfd exists.
                if [[ -e ${path_ld} ]] ; then
                        local d="${T}/bfd-linker"
                        mkdir -p "${d}"
@@ -390,9 +421,6 @@ tc-ld-disable-gold() {
                else
                        die "unable to locate a BFD linker to bypass gold"
                fi
-       else
-               # gcc-4.8+ supports -fuse-ld directly.
-               export LDFLAGS="${LDFLAGS} -fuse-ld=bfd"
        fi
 }
 

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 9dcfcf1d88..4235583495 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # Maintainer: Toolchain Ninjas <[email protected]>
@@ -23,14 +23,13 @@ fi
 
 FEATURES=${FEATURES/multilib-strict/}
 
-EXPORTED_FUNCTIONS="pkg_setup src_unpack src_compile src_test src_install 
pkg_postinst pkg_postrm"
 case ${EAPI:-0} in
-       0|1)    die "Need to upgrade to at least EAPI=2";;
-       2|3)    EXPORTED_FUNCTIONS+=" src_prepare src_configure" ;;
-       4*|5*)  EXPORTED_FUNCTIONS+=" pkg_pretend src_prepare src_configure" ;;
-       *)      die "I don't speak EAPI ${EAPI}."
+       0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
+       5*)   ;;
+       *)       die "I don't speak EAPI ${EAPI}." ;;
 esac
-EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
+EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
+       src_compile src_test src_install pkg_postinst pkg_postrm
 
 #---->> globals <<----
 
@@ -141,7 +140,8 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
        [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
        [[ -n ${D_VER}   ]] && IUSE+=" d"
        [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
-       tc_version_is_at_least 3 && IUSE+=" doc gcj awt hardened multilib objc"
+       tc_version_is_at_least 3 && IUSE+=" doc hardened multilib objc"
+       tc_version_is_between 3 7 && IUSE+=" awt gcj"
        tc_version_is_at_least 3.3 && IUSE+=" pgo"
        tc_version_is_at_least 4.0 && IUSE+=" objc-gc"
        tc_version_is_between 4.0 4.9 && IUSE+=" mudflap"
@@ -153,9 +153,12 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
        # 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" IUSE_DEF+=( sanitize )
-       tc_version_is_at_least 4.9 && IUSE+=" cilk +vtv"
+       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 mpx"
        tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
+       # systemtap is a gentoo-specific switch: bug #654748
+       tc_version_is_at_least 8.0 && IUSE+=" systemtap"
 fi
 
 IUSE+=" ${IUSE_DEF[*]/#/+}"
@@ -170,7 +173,7 @@ RDEPEND="sys-libs/zlib
 tc_version_is_at_least 3 && RDEPEND+=" virtual/libiconv"
 
 if tc_version_is_at_least 4 ; then
-       GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0 >=dev-libs/mpfr-2.4.2:0"
+       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 in_iuse fortran ; then
@@ -178,7 +181,7 @@ if tc_version_is_at_least 4 ; then
        fi
 fi
 
-tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0"
+tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
 
 if in_iuse objc-gc ; then
        if tc_version_is_at_least 7 ; then
@@ -188,12 +191,12 @@ fi
 
 if in_iuse graphite ; then
        if tc_version_is_at_least 5.0 ; then
-               RDEPEND+=" graphite? ( >=dev-libs/isl-0.14 )"
+               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
-                               >=dev-libs/isl-0.11.1
+                               >=dev-libs/cloog-0.18.0:0=
+                               >=dev-libs/isl-0.11.1:0=
                        )"
        fi
 fi
@@ -210,11 +213,10 @@ DEPEND="${RDEPEND}
 if in_iuse gcj ; then
        GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
        GCJ_GTK_DEPS="
+               x11-base/xorg-proto
                x11-libs/libXt
                x11-libs/libX11
                x11-libs/libXtst
-               x11-proto/xproto
-               x11-proto/xextproto
                =x11-libs/gtk+-2*
                virtual/pkgconfig
        "
@@ -223,6 +225,11 @@ if in_iuse gcj ; then
        DEPEND+=" gcj? ( awt? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
 fi
 
+if in_iuse systemtap ; then
+       # gcc needs sys/sdt.h headers on target
+       DEPEND+=" systemtap? ( dev-util/systemtap )"
+fi
+
 PDEPEND=">=sys-devel/gcc-config-1.7"
 
 #---->> S + SRC_URI essentials <<----
@@ -320,7 +327,11 @@ get_gcc_src_uri() {
        elif [[ -n ${PRERELEASE} ]] ; then
                
GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2";
        elif [[ -n ${SNAPSHOT} ]] ; then
-               
GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2";
+               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
        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"
@@ -385,9 +396,6 @@ toolchain_pkg_pretend() {
                        "in your make.conf if you want to use this version."
        fi
 
-       [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && \
-               die "Sorry, this version does not support uClibc"
-
        if ! use_if_iuse cxx ; then
                use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled 
due to USE="-cxx"'
                use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, 
disabled due to USE="-cxx"'
@@ -400,10 +408,6 @@ toolchain_pkg_pretend() {
 #---->> pkg_setup <<----
 
 toolchain_pkg_setup() {
-       case ${EAPI} in
-       2|3) toolchain_pkg_pretend ;;
-       esac
-
        # we dont want to use the installed compiler's specs to build gcc
        unset GCC_SPECS
        unset LANGUAGES #265283
@@ -441,7 +445,11 @@ gcc_quick_unpack() {
        elif [[ -n ${PRERELEASE} ]] ; then
                unpack gcc-${PRERELEASE}.tar.bz2
        elif [[ -n ${SNAPSHOT} ]] ; then
-               unpack gcc-${SNAPSHOT}.tar.bz2
+               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
@@ -518,7 +526,7 @@ toolchain_src_prepare() {
        do_gcc_CYGWINPORTS_patches
        epatch_user
 
-       if ( tc_version_is_at_least 4.8.2 || use hardened ) && ! use vanilla ; 
then
+       if ( tc_version_is_at_least 4.8.2 || use_if_iuse hardened ) && ! use 
vanilla ; then
                make_gcc_hard
        fi
 
@@ -568,7 +576,7 @@ toolchain_src_prepare() {
        fi
 
        # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
-       if tc_version_is_at_least 4.3 && use gcj ; then
+       if tc_version_is_at_least 4.3 && 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
@@ -691,20 +699,20 @@ make_gcc_hard() {
 
        # Gcc >= 6.X we can use configurations options to turn pie/ssp on as 
default
        if tc_version_is_at_least 6.0 ; then
-               if use pie ; then
+               if use_if_iuse pie ; then
                        einfo "Updating gcc to use automatic PIE building ..."
                fi
-               if use ssp ; then
+               if use_if_iuse ssp ; then
                        einfo "Updating gcc to use automatic SSP building ..."
                fi
-               if use hardened ; then
+               if use_if_iuse hardened ; then
                        # Will add some optimatizion as default.
                        gcc_hard_flags+=" -DEXTRA_OPTIONS"
                        # rebrand to make bug reports easier
                        
BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
                fi
        else
-               if use hardened ; then
+               if 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
@@ -952,7 +960,7 @@ toolchain_src_configure() {
 
        # Use the default ("release") checking because upstream usually neglects
        # to test "disabled" so it has a history of breaking. #317217
-       if tc_version_is_at_least 3.4 ; then
+       if tc_version_is_at_least 3.4 && in_iuse debug ; then
                # The "release" keyword is new to 4.0. #551636
                local off=$(tc_version_is_at_least 4.0 && echo release || echo 
no)
                confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug 
yes ${off})}" )
@@ -965,7 +973,7 @@ toolchain_src_configure() {
        )
 
        # If we want hardened support with the newer piepatchset for >=gcc 4.4
-       if tc_version_is_at_least 4.4 && want_minispecs ; then
+       if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; 
then
                confgcc+=( $(use_enable hardened esp) )
        fi
 
@@ -977,7 +985,7 @@ toolchain_src_configure() {
        fi
 
        # Support to disable pch when building libstdcxx
-       if tc_version_is_at_least 6.0 && ! use pch ; then
+       if tc_version_is_at_least 6.0 && ! use_if_iuse pch ; then
                confgcc+=( --disable-libstdcxx-pch )
        fi
 
@@ -1012,7 +1020,14 @@ toolchain_src_configure() {
                case ${CTARGET} in
                *-linux)                 needed_libc=no-fucking-clue;;
                *-dietlibc)              needed_libc=dietlibc;;
-               *-elf|*-eabi)    needed_libc=newlib;;
+               *-elf|*-eabi)
+                       needed_libc=newlib
+                       # Bare-metal targets don't have access to 
clock_gettime()
+                       # arm-none-eabi example: bug #589672
+                       # But we explicitly do --enable-libstdcxx-time above.
+                       # Undoing it here.
+                       confgcc+=( --disable-libstdcxx-time )
+                       ;;
                *-gentoo-freebsd*)               needed_libc=freebsd-lib;;
                *-gnu*)                  needed_libc=glibc;;
                *-klibc)                 needed_libc=klibc;;
@@ -1046,7 +1061,7 @@ toolchain_src_configure() {
                                        --disable-threads
                                        --without-headers
                                )
-                       elif built_with_use --hidden --missing false 
${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then
+                       elif has_version 
"${CATEGORY}/${needed_libc}[headers-only(-)]" ; then
                                confgcc+=(
                                        "${confgcc_no_libc[@]}"
                                        --with-sysroot="${PREFIX}"/${CTARGET}
@@ -1116,12 +1131,12 @@ toolchain_src_configure() {
        gcc-multilib-configure
 
        # ppc altivec support
-       confgcc+=( $(use_enable altivec) )
+       in_iuse altivec && confgcc+=( $(use_enable altivec) )
 
        # 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 && confgcc+=( $(use_enable fixed-point) )
+       tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( 
$(use_enable fixed-point) )
 
        case $(tc-is-softfloat) in
        yes)    confgcc+=( --with-float=soft ) ;;
@@ -1259,7 +1274,17 @@ toolchain_src_configure() {
                        if hardened_gcc_is_stable ssp; then
                                export gcc_cv_libc_provides_ssp=yes
                        fi
-                       confgcc+=( --disable-libssp )
+                       if use_if_iuse ssp; then
+                               # On some targets USE="ssp -libssp" is an 
invalid
+                               # configuration as target libc does not provide
+                               # stack_chk_* functions. Do not disable libssp 
there.
+                               case ${CTARGET} in
+                                       mingw*|*-mingw*) ewarn "Not disabling 
libssp" ;;
+                                       *) confgcc+=( --disable-libssp ) ;;
+                               esac
+                       else
+                               confgcc+=( --disable-libssp )
+                       fi
                fi
        fi
 
@@ -1271,6 +1296,10 @@ toolchain_src_configure() {
                confgcc+=( $(use_enable mpx libmpx) )
        fi
 
+       if in_iuse systemtap ; then
+               confgcc+=( $(use_enable systemtap) )
+       fi
+
        if in_iuse vtv ; then
                confgcc+=(
                        $(use_enable vtv vtable-verify)
@@ -1292,23 +1321,26 @@ toolchain_src_configure() {
 
        # 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 ; then
+       if tc_version_is_at_least 5.0 && in_iuse graphite ; then
                confgcc+=( $(use_with graphite isl) )
                use graphite && confgcc+=( --disable-isl-version-check )
-       elif tc_version_is_at_least 4.8 ; then
+       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 4.4 ; then
                confgcc+=( --without-{cloog,ppl} )
        fi
 
-       if tc_version_is_at_least 4.8 ; then
+       if tc_version_is_at_least 4.8 && in_iuse sanitize ; then
                confgcc+=( $(use_enable sanitize libsanitizer) )
        fi
 
-       if tc_version_is_at_least 6.0 ; then
+       if tc_version_is_at_least 6.0 && in_iuse pie ; then
+               confgcc+=( $(use_enable pie default-pie) )
+       fi
+
+       if tc_version_is_at_least 6.0 && in_iuse ssp ; then
                confgcc+=(
-                       $(use_enable pie default-pie)
                        # This defaults to -fstack-protector-strong.
                        $(use_enable ssp default-ssp)
                )
@@ -1547,7 +1579,7 @@ gcc_do_filter_flags() {
 
                # "hppa2.0-unknown-linux-gnu" -> hppa2_0_unknown_linux_gnu
                local VAR="CFLAGS_"${CTARGET//[-.]/_}
-               CXXFLAGS=${!VAR}
+               CXXFLAGS=${!VAR-${CFLAGS}}
        fi
 
        export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
@@ -1638,7 +1670,7 @@ gcc_do_make() {
                # resulting binaries natively ^^;
                GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
        else
-               if tc_version_is_at_least 3.3 && use pgo; then
+               if tc_version_is_at_least 3.3 && use_if_iuse pgo; then
                        GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
                else
                        GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
@@ -1685,7 +1717,7 @@ gcc_do_make() {
                ${GCC_MAKE_TARGET} \
                || die "emake failed with ${GCC_MAKE_TARGET}"
 
-       if ! is_crosscompile && use cxx && use_if_iuse doc ; then
+       if ! is_crosscompile && use_if_iuse cxx && 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
@@ -1738,8 +1770,12 @@ toolchain_src_install() {
                fi
        done
 
-       # Remove generated headers, as they can cause things to break
-       # (ncurses, openssl, etc), unless when in a prefix.
+       # 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}"
@@ -1850,7 +1886,7 @@ toolchain_src_install() {
 
        # Rather install the script, else portage with changing $FILESDIR
        # between binary and source package borks things ....
-       if ! is_crosscompile ; then
+       if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
                insinto "${DATAPATH#${EPREFIX}}"
                newins "$(prefixify_ro 
"${FILESDIR}"/awk/fixlafiles.awk-no_gcc_la)" fixlafiles.awk || die
                exeinto "${DATAPATH#${EPREFIX}}"
@@ -1866,6 +1902,7 @@ toolchain_src_install() {
        # libsupc++.la: This has no dependencies.
        # libcc1.la: There is no static library, only dynamic.
        # libcc1plugin.la: Same as above, and it's loaded via dlopen.
+       # libcp1plugin.la: Same as above, and it's loaded via dlopen.
        # libgomp.la: gcc itself handles linkage (libgomp.spec).
        # libgomp-plugin-*.la: Same as above, and it's an internal plugin only
        # loaded via dlopen.
@@ -1885,6 +1922,7 @@ toolchain_src_install() {
                        -name libsupc++.la -o \
                        -name libcc1.la -o \
                        -name libcc1plugin.la -o \
+                       -name libcp1plugin.la -o \
                        -name 'libgomp.la' -o \
                        -name 'libgomp-plugin-*.la' -o \
                        -name libgfortran.la -o \
@@ -2144,7 +2182,7 @@ toolchain_pkg_postinst() {
                eselect compiler-shadow update all
        fi
 
-       if ! is_crosscompile ; then
+       if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
                echo
                ewarn "If you have issues with packages unable to locate 
libstdc++.la,"
                ewarn "then try running 'fix_libtool_files.sh' on the old gcc 
versions."
@@ -2160,12 +2198,12 @@ toolchain_pkg_postinst() {
 
                mkdir -p "${EROOT}"usr/{share/gcc-data,sbin,bin}
                # DATAPATH has EPREFIX already, use ROOT with it
-               cp "${ROOT%/}${DATAPATH}"/fixlafiles.awk 
"${EROOT}"usr/share/gcc-data/ || die
-               cp "${ROOT%/}${DATAPATH}"/fix_libtool_files.sh 
"${EROOT}"usr/sbin/ || die
+               cp "${ROOT}${DATAPATH}"/fixlafiles.awk 
"${EROOT}"usr/share/gcc-data/ || die
+               cp "${ROOT}${DATAPATH}"/fix_libtool_files.sh 
"${EROOT}"usr/sbin/ || die
 
                # Since these aren't critical files and portage sucks with
                # handling of binpkgs, don't require these to be found
-               cp "${ROOT%/}${DATAPATH}"/c{89,99} "${EROOT}"usr/bin/ 
2>/dev/null
+               cp "${ROOT}${DATAPATH}"/c{89,99} "${EROOT}"usr/bin/ 2>/dev/null
        fi
 
        if use regression-test ; then
@@ -2234,7 +2272,7 @@ do_gcc_config() {
                [[ -n ${current_specs} ]] && use_specs=-${current_specs}
 
                if [[ -n ${use_specs} ]] && \
-                  [[ ! -e 
${ROOT}etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
+                  [[ ! -e 
${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
                then
                        ewarn "The currently selected specs-specific gcc 
config,"
                        ewarn "${current_specs}, doesn't exist anymore. This is 
usually"
@@ -2309,13 +2347,13 @@ gcc-lang-supported() {
 
 is_ada() {
        gcc-lang-supported ada || return 1
-       use ada
+       use_if_iuse ada
 }
 
 is_cxx() {
        gcc-lang-supported 'c++' || return 1
        ! is_crosscompile && tc_version_is_at_least 4.8 && return 0
-       use cxx
+       use_if_iuse cxx
 }
 
 is_d() {
@@ -2325,27 +2363,27 @@ is_d() {
 
 is_f77() {
        gcc-lang-supported f77 || return 1
-       use fortran
+       use_if_iuse fortran
 }
 
 is_f95() {
        gcc-lang-supported f95 || return 1
-       use fortran
+       use_if_iuse fortran
 }
 
 is_fortran() {
        gcc-lang-supported fortran || return 1
-       use fortran
+       use_if_iuse fortran
 }
 
 is_gcj() {
        gcc-lang-supported java || return 1
-       use cxx && use_if_iuse gcj
+       use_if_iuse cxx && use_if_iuse gcj
 }
 
 is_go() {
        gcc-lang-supported go || return 1
-       use cxx && use_if_iuse go
+       use_if_iuse cxx && use_if_iuse go
 }
 
 is_jit() {
@@ -2355,7 +2393,7 @@ is_jit() {
 
 is_multilib() {
        tc_version_is_at_least 3 || return 1
-       use multilib
+       use_if_iuse multilib
 }
 
 is_objc() {
@@ -2365,7 +2403,7 @@ is_objc() {
 
 is_objcxx() {
        gcc-lang-supported 'obj-c++' || return 1
-       use cxx && use_if_iuse objc++
+       use_if_iuse cxx && use_if_iuse objc++
 }
 
 # Grab a variable from the build system (taken from linux-info.eclass)
@@ -2433,12 +2471,12 @@ want_minispecs() {
        if tc_version_is_at_least 6.0 ; then
                return 0
        fi
-       if tc_version_is_at_least 4.3.2 && use hardened ; then
+       if tc_version_is_at_least 4.3.2 && 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 use nopie && use nossp ; then
+               elif use_if_iuse nopie && 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."
@@ -2452,11 +2490,11 @@ want_minispecs() {
 }
 
 want_pie() {
-       ! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1
+       ! use_if_iuse hardened && [[ -n ${PIE_VER} ]] && 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
-       use !nopie && return 0
+       use_if_iuse nopie || return 0
        return 1
 }
 

diff --git a/eclass/user.eclass b/eclass/user.eclass
index 847fc1a0fa..83f13f25f4 100644
--- a/eclass/user.eclass
+++ b/eclass/user.eclass
@@ -1,13 +1,9 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/user.eclass,v 1.24 2014/07/11 
08:21:58 ulm Exp $
 
 # @ECLASS: user.eclass
 # @MAINTAINER:
 # [email protected] (Linux)
-# Joe Jezak <[email protected]> (OS X)
-# [email protected] (OS X)
-# Aaron Walker <[email protected]> (FreeBSD)
 # @BLURB: user management in ebuilds
 # @DESCRIPTION:
 # The user eclass contains a suite of functions that allow ebuilds
@@ -107,6 +103,10 @@ egetent() {
 # Default uid is (pass -1 for this) next available, default shell is
 # /bin/false, default homedir is /dev/null, and there are no default groups.
 enewuser() {
+       if [[ ${EUID} != 0 ]] ; then
+               einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
+               return 0
+       fi
        _assert_pkg_ebuild_phase ${FUNCNAME}
 
        # get the username
@@ -116,14 +116,6 @@ enewuser() {
                die "Cannot call enewuser without a username"
        fi
 
-       # in Gentoo Prefix, we may be unprivileged, such that we can't handle 
this
-       rootuid=$(python -c 'from portage.const import rootuid; print(rootuid)')
-       if [[ ${rootuid} != 0 ]] ; then
-               ewarn "'enewuser()'  disabled in Gentoo Prefix with non-root 
user (by design)"
-               ewarn "    User: '$euser' not created"
-               return 0
-       fi
-
        # lets see if the username already exists
        if [[ -n $(egetent passwd "${euser}") ]] ; then
                return 0
@@ -196,7 +188,6 @@ enewuser() {
        local egroups=$1; shift
        local g egroups_arr
        IFS="," read -r -a egroups_arr <<<"${egroups}"
-       shift
        if [[ ${#egroups_arr[@]} -gt 0 ]] ; then
                local defgroup exgroups
                for g in "${egroups_arr[@]}" ; do
@@ -275,6 +266,10 @@ enewuser() {
 # do the rest.  You may specify the gid for the group or allow the group to
 # allocate the next available one.
 enewgroup() {
+       if [[ ${EUID} != 0 ]] ; then
+               einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
+               return 0
+       fi
        _assert_pkg_ebuild_phase ${FUNCNAME}
 
        # get the group
@@ -284,14 +279,6 @@ enewgroup() {
                die "Cannot call enewgroup without a group"
        fi
 
-       # in Gentoo Prefix, we may be unprivileged, such that we can't handle 
this
-       rootuid=$(python -c 'from portage.const import rootuid; print(rootuid)')
-       if [[ ${rootuid} != 0 ]] ; then
-               ewarn "'enewgroup()' disabled in Gentoo Prefix with non-root 
user (by design)"
-               ewarn "    Group: '$egroup' not created"
-               return 0
-       fi
-
        # see if group already exists
        if [[ -n $(egetent group "${egroup}") ]] ; then
                return 0

Reply via email to