-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
-# @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/}
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
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})
-# 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
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"
+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=()
}
if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
- IUSE+=" altivec debug +cxx +fortran +nptl" TC_FEATURES+=(fortran nptl)
+ 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"
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)
+ # sanitizer support appeared in gcc-4.8, but <gcc-5 does not
+ # support modern glibc.
+ tc_version_is_at_least 5 && 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"
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 <<----
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"
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
# 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
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"
[[ -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})"
#---->> pkg_pretend <<----
toolchain_pkg_pretend() {
- if [[ -n ${PRERELEASE}${SNAPSHOT} || ${PV} == *9999* ]] &&
- [[ -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."
- fi
-
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"'
#---->> 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 <<----
- # Injection point for more tarballs. dev-lang/gnat-gpl uses
- # 'GCC_A_FAKEIT' to specify it's own source and binary tarballs.
- 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
- 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
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}"
-
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
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
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 | \
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
- guess_patch_type_in_dir "${WORKDIR}"/patch
- EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
- epatch "${WORKDIR}"/patch
+ tc_apply_patches "Applying Gentoo patches ..." "${WORKDIR}"/patch/*.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
+ tc_apply_patches "Applying uClibc patches ..." "${WORKDIR}"/uclibc/*.patch
fi
fi
}
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}"
}
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}"
}
local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
# readarray -t is available since bash-4.4 only, #690686
- local patches=( $(sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport) )
- for p in ${patches[*]}; do
- epatch "${d}/${p}"
- done
+ local patches=( $(
+ for p in $(
+ sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport
+ ); do
+ echo "${d}/${p}"
+ done
+ ) )
+ 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
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}
# gcc-4.3+ has configure flags (whoo!)
tc_version_is_at_least 4.3 && return 0
- local version_string=${GCC_CONFIG_VER}
+ local version_string=${GCC_RELEASE_VER}
einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
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
# 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
# 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)
# 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
*-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
*-cygwin) needed_libc=cygwin;;
x86_64-*-mingw*|\
*-w64-mingw*) needed_libc=mingw64-runtime;;
- mingw*|*-mingw*) needed_libc=mingw-runtime;;
avr) confgcc+=( --enable-shared --disable-threads );;
esac
if [[ -n ${needed_libc} ]] ; then
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}) )
)
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
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
- if tc_version_is_at_least 4.8 && in_iuse sanitize ; then
- # See Note [implicitly enabled flags]
- confgcc+=( $(usex sanitize '' --disable-libsanitizer) )
+ if tc_version_is_at_least 4.8; then
+ if in_iuse sanitize ; then
+ # See Note [implicitly enabled flags]
+ confgcc+=( $(usex sanitize '' --disable-libsanitizer) )
+ else
+ confgcc+=( --disable-libsanitizer )
+ fi
fi
if tc_version_is_at_least 6.0 && in_iuse pie ; then
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)
# 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}
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=(
[[ ${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
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
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)
#---->> 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 <<----
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
find gcc/include*/ -type l -delete
# Copy over the info pages. We disabled their generation earlier, but the
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
if [[ -f ${CTARGET}-${x} ]] ; then
if ! is_crosscompile ; then
ln -sf ${CTARGET}-${x} ${x}
- dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
+ dosym ${BINPATH}/${CTARGET}-${x} \
/usr/bin/${x}-${GCC_CONFIG_VER}
fi
# Create versioned symlinks
- dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
+ dosym ${BINPATH}/${CTARGET}-${x} \
/usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
fi
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
# 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
# handling of binpkgs, don't require these to be found
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
- 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/"
- fi
}
toolchain_pkg_postrm() {