* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2016-12-26 0:04 Aric Belsito
0 siblings, 0 replies; 24+ messages in thread
From: Aric Belsito @ 2016-12-26 0:04 UTC (permalink / raw
To: gentoo-commits
commit: d245318d8912a6fef051fe1bdfbee626af72a742
Author: Aric Belsito <lluixhi <AT> gmail <DOT> com>
AuthorDate: Mon Dec 26 00:01:52 2016 +0000
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Mon Dec 26 00:03:31 2016 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=d245318d
eclass: Synchronize toolchain.eclass with upstream.
musl supports __cxa_atexit, and --enable-__cxa_atexit is passed by default, but
it appears that upstream has a convention of including this in the
toolchain.eclass
eclass/toolchain.eclass | 143 +++++++++++++++++++++++++++++++-----------------
1 file changed, 94 insertions(+), 49 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 1192f62..a6034d3 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
@@ -131,7 +131,7 @@ else
LICENSE="GPL-2+ LGPL-2.1+ FDL-1.1+"
fi
-IUSE="multislot regression-test vanilla"
+IUSE="regression-test vanilla"
IUSE_DEF=( nls nptl )
if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
@@ -152,9 +152,9 @@ 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"
- tc_version_is_at_least 5.0 && IUSE+=" jit pch"
- tc_version_is_at_least 6.0 && IUSE+=" pie +ssp"
+ tc_version_is_at_least 4.9 && IUSE+=" cilk +vtv"
+ tc_version_is_at_least 5.0 && IUSE+=" jit mpx"
+ tc_version_is_at_least 6.0 && IUSE+=" pie ssp +pch"
fi
IUSE+=" ${IUSE_DEF[*]/#/+}"
@@ -627,20 +627,47 @@ do_gcc_PIE_patches() {
# configure to build with the hardened GCC specs as the default
make_gcc_hard() {
- # Gcc >= 6.X we don't need to sed in Makefile
- # It have configurations options to turn pie/ssp on as default
+ local gcc_hard_flags=""
+ # Gcc >= 6.X we can use configuration options to turn pie/ssp on as default
if tc_version_is_at_least 6.0 ; then
- if use hardened ; then
- # rebrand to make bug reports easier
- BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
- fi
if use pie ; then
einfo "Updating gcc to use automatic PIE building ..."
fi
if use ssp ; then
einfo "Updating gcc to use automatic SSP building ..."
fi
- return 1
+ if use hardened ; then
+ # Will add some optimizations by 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
+ # rebrand to make bug reports easier
+ BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
+ if hardened_gcc_works ; then
+ einfo "Updating gcc to use automatic PIE + SSP building ..."
+ gcc_hard_flags+=" -DEFAULT_PIE_SSP"
+ elif hardened_gcc_works pie ; then
+ einfo "Updating gcc to use automatic PIE building ..."
+ ewarn "SSP has not been enabled by default"
+ gcc_hard_flags+=" -DEFAULT_PIE"
+ elif hardened_gcc_works ssp ; then
+ einfo "Updating gcc to use automatic SSP building ..."
+ ewarn "PIE has not been enabled by default"
+ gcc_hard_flags+=" -DEFAULT_SSP"
+ else
+ # do nothing if hardened isn't supported, but don't die either
+ ewarn "hardened is not supported for this arch in this gcc version"
+ return 0
+ fi
+ else
+ if hardened_gcc_works ssp ; then
+ einfo "Updating gcc to use automatic SSP building ..."
+ gcc_hard_flags+=" -DEFAULT_SSP"
+ fi
+ fi
fi
# we want to be able to control the pie patch logic via something other
@@ -651,36 +678,8 @@ make_gcc_hard() {
# Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
if tc_version_is_at_least 4.7 ; then
sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
- -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
- -i "${S}"/gcc/Makefile.in
- fi
-
- # defaults to enable for all toolchains
- local gcc_hard_flags=""
- if use hardened ; then
- if hardened_gcc_works ; then
- einfo "Updating gcc to use automatic PIE + SSP building ..."
- gcc_hard_flags+=" -DEFAULT_PIE_SSP"
- elif hardened_gcc_works pie ; then
- einfo "Updating gcc to use automatic PIE building ..."
- ewarn "SSP has not been enabled by default"
- gcc_hard_flags+=" -DEFAULT_PIE"
- elif hardened_gcc_works ssp ; then
- einfo "Updating gcc to use automatic SSP building ..."
- ewarn "PIE has not been enabled by default"
- gcc_hard_flags+=" -DEFAULT_SSP"
- else
- # do nothing if hardened isn't supported, but don't die either
- ewarn "hardened is not supported for this arch in this gcc version"
- return 0
- fi
- # rebrand to make bug reports easier
- BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
- else
- if hardened_gcc_works ssp ; then
- einfo "Updating gcc to use automatic SSP building ..."
- gcc_hard_flags+=" -DEFAULT_SSP"
- fi
+ -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
+ -i "${S}"/gcc/Makefile.in
fi
sed -i \
@@ -917,7 +916,7 @@ toolchain_src_configure() {
fi
# Support to disable pch when building libstdcxx
- if tc_version_is_at_least 5.0 && ! use pch ; then
+ if tc_version_is_at_least 6.0 && ! use pch ; then
confgcc+=( --disable-libstdcxx-pch )
fi
@@ -1022,6 +1021,9 @@ toolchain_src_configure() {
*-elf|*-eabi)
confgcc+=( --with-newlib )
;;
+ *-musl*)
+ confgcc+=( --enable-__cxa_atexit )
+ ;;
*-gnu*)
confgcc+=(
--enable-__cxa_atexit
@@ -1187,6 +1189,17 @@ toolchain_src_configure() {
confgcc+=( $(use_enable cilk libcilkrts) )
fi
+ if in_iuse mpx ; then
+ confgcc+=( $(use_enable mpx libmpx) )
+ fi
+
+ if in_iuse vtv ; then
+ confgcc+=(
+ $(use_enable vtv vtable-verify)
+ $(use_enable vtv libvtv)
+ )
+ 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
@@ -1756,13 +1769,49 @@ toolchain_src_install() {
if ! is_crosscompile ; then
insinto "${DATAPATH}"
newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die
- find "${D}/${LIBPATH}" -name libstdc++.la -type f -delete
- find "${D}/${LIBPATH}" -name 'lib*san.la' -type f -delete #487550 #546700
exeinto "${DATAPATH}"
doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die
doexe "${GCC_FILESDIR}"/c{89,99} || die
fi
+ # libstdc++.la: Delete as it doesn't add anything useful: g++ itself
+ # handles linkage correctly in the dynamic & static case. It also just
+ # causes us pain: any C++ progs/libs linking with libtool will gain a
+ # reference to the full libstdc++.la file which is gcc version specific.
+ # libstdc++fs.la: It doesn't link against anything useful.
+ # 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.
+ # libgomp.la: gcc itself handles linkage (libgomp.spec).
+ # libgomp-plugin-*.la: Same as above, and it's an internal plugin only
+ # loaded via dlopen.
+ # libgfortran.la: gfortran itself handles linkage correctly in the
+ # dynamic & static case (libgfortran.spec). #573302
+ # libgfortranbegin.la: Same as above, and it's an internal lib.
+ # libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
+ # libmpxwrappers.la: See above.
+ # libitm.la: gcc itself handles linkage correctly (libitm.spec).
+ # libvtv.la: gcc itself handles linkage correctly.
+ # lib*san.la: Sanitizer linkage is handled internally by gcc, and they
+ # do not support static linking. #487550 #546700
+ find "${D}/${LIBPATH}" \
+ '(' \
+ -name libstdc++.la -o \
+ -name libstdc++fs.la -o \
+ -name libsupc++.la -o \
+ -name libcc1.la -o \
+ -name libcc1plugin.la -o \
+ -name 'libgomp.la' -o \
+ -name 'libgomp-plugin-*.la' -o \
+ -name libgfortran.la -o \
+ -name libgfortranbegin.la -o \
+ -name libmpx.la -o \
+ -name libmpxwrappers.la -o \
+ -name libitm.la -o \
+ -name libvtv.la -o \
+ -name 'lib*san.la' \
+ ')' -type f -delete
+
# Use gid of 0 because some stupid ports don't have
# the group 'root' set to gid 0. Send to /dev/null
# for people who are testing as non-root.
@@ -2122,10 +2171,6 @@ should_we_gcc_config() {
local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
- # If we're using multislot, just run gcc-config if we're installing
- # to the same profile as the current one.
- use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]])
-
if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
return 0
else
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2021-11-20 23:24 Sam James
0 siblings, 0 replies; 24+ messages in thread
From: Sam James @ 2021-11-20 23:24 UTC (permalink / raw
To: gentoo-commits
commit: 50bc869cdb4564df70349ef6f2ae40dbbc50fbbe
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 20 23:24:17 2021 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 20 23:24:17 2021 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=50bc869c
toolchain.eclass: drop obsolete eclass fork (now in ::gentoo)
Signed-off-by: Sam James <sam <AT> gentoo.org>
eclass/toolchain.eclass | 2391 -----------------------------------------------
1 file changed, 2391 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
deleted file mode 100644
index 627531f2..00000000
--- a/eclass/toolchain.eclass
+++ /dev/null
@@ -1,2391 +0,0 @@
-# Copyright 1999-2021 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-# @ECLASS: toolchain.eclass
-# @MAINTAINER:
-# Toolchain Ninjas <toolchain@gentoo.org>
-# @SUPPORTED_EAPIS: 5 6 7 8
-# @BLURB: Common code for sys-devel/gcc ebuilds
-
-DESCRIPTION="The GNU Compiler Collection"
-HOMEPAGE="https://gcc.gnu.org/"
-
-inherit flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
-
-tc_is_live() {
- [[ ${PV} == *9999* ]]
-}
-
-if tc_is_live ; then
- EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git"
- # naming style:
- # 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="releases/${PN}-${PV%.?.?_pre9999}"
- EGIT_BRANCH=${EGIT_BRANCH//./_}
- inherit git-r3
-fi
-
-FEATURES=${FEATURES/multilib-strict/}
-
-case ${EAPI} in
- 5|6) inherit eapi7-ver eutils ;;
- 7) inherit eutils ;;
- 8) ;;
- *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
-esac
-
-EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
- src_compile src_test src_install pkg_postinst pkg_postrm
-
-#---->> globals <<----
-
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} = ${CHOST} ]] ; then
- if [[ ${CATEGORY} == cross-* ]] ; then
- export CTARGET=${CATEGORY#cross-}
- fi
-fi
-: ${TARGET_ABI:=${ABI}}
-: ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
-: ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
-
-is_crosscompile() {
- [[ ${CHOST} != ${CTARGET} ]]
-}
-
-# General purpose version check. Without a second arg matches up to minor version (x.x.x)
-tc_version_is_at_least() {
- ver_test "${2:-${GCC_RELEASE_VER}}" -ge "$1"
-}
-
-# General purpose version range check
-# Note that it matches up to but NOT including the second version
-tc_version_is_between() {
- tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}"
-}
-
-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})
-
-# 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
-
-# Require minimum gcc version to simplify assumptions.
-# Normally we would require gcc-6+ (based on sys-devel/gcc)
-# but we still have sys-devel/gcc-apple-4.2.1_p5666.
-tc_version_is_at_least 4.2.1 || die "${ECLASS}: ${GCC_RELEASE_VER} is too old."
-
-PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
-
-LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
-INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
-
-if is_crosscompile ; then
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
- HOSTLIBPATH=${PREFIX}/${CHOST}/${CTARGET}/lib/${GCC_CONFIG_VER}
-else
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
-fi
-
-DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
-
-# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
-# We will handle /usr/include/g++-v3/ with gcc-config ...
-STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
-
-#---->> LICENSE+SLOT+IUSE logic <<----
-
-LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
-IUSE="test vanilla +nls"
-RESTRICT="!test? ( test )"
-
-tc_supports_dostrip() {
- case ${EAPI} in
- 5|6) return 1 ;;
- 7|8) return 0 ;;
- *) die "Update apply_patches() for ${EAPI}." ;;
- esac
-}
-
-tc_supports_dostrip || RESTRICT+=" strip" # cross-compilers need controlled stripping
-
-TC_FEATURES=()
-
-tc_has_feature() {
- has "$1" "${TC_FEATURES[@]}"
-}
-
-if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
- IUSE+=" debug +cxx +nptl" TC_FEATURES+=(nptl)
- [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
- [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
- IUSE+=" +fortran" TC_FEATURES+=(fortran)
- IUSE+=" doc hardened multilib objc"
- tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=(gcj)
- IUSE+=" pgo"
- IUSE+=" objc-gc" TC_FEATURES+=(objc-gc)
- IUSE+=" libssp objc++"
- IUSE+=" +openmp"
- tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
- tc_version_is_at_least 4.7 && IUSE+=" go"
- # sanitizer support appeared in gcc-4.8, but <gcc-5 does not
- # support modern glibc.
- tc_version_is_at_least 5 && IUSE+=" +sanitize" TC_FEATURES+=(sanitize)
- # Note:
- # <gcc-4.8 supported graphite, it required forked ppl
- # versions which we dropped. Since graphite was also experimental in
- # the older versions, we don't want to bother supporting it. #448024
- # <gcc-5 supported graphite, it required cloog
- # <gcc-6.5 supported graphite, it required old incompatible isl
- tc_version_is_at_least 6.5 &&
- IUSE+=" graphite" TC_FEATURES+=(graphite)
- tc_version_is_between 4.9 8 && IUSE+=" cilk"
- tc_version_is_at_least 4.9 && IUSE+=" ada"
- tc_version_is_at_least 4.9 && IUSE+=" vtv"
- tc_version_is_at_least 5.0 && IUSE+=" jit"
- tc_version_is_between 5.0 9 && IUSE+=" mpx"
- tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
- # systemtap is a gentoo-specific switch: bug #654748
- tc_version_is_at_least 8.0 &&
- IUSE+=" systemtap" TC_FEATURES+=(systemtap)
- tc_version_is_at_least 9.0 && IUSE+=" d"
- tc_version_is_at_least 9.1 && IUSE+=" lto"
- tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=(zstd)
- tc_version_is_at_least 11 && IUSE+=" valgrind" TC_FEATURES+=(valgrind)
- tc_version_is_at_least 11 && IUSE+=" custom-cflags"
-fi
-
-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 <<----
-
-RDEPEND="sys-libs/zlib
- virtual/libiconv
- nls? ( virtual/libintl )
-"
-
-GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0= >=dev-libs/mpfr-2.4.2:0="
-if tc_version_is_at_least 4.3 ; then
- RDEPEND+=" ${GMP_MPFR_DEPS}"
-elif tc_has_feature fortran ; then
- RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
-fi
-
-tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
-
-if tc_has_feature objc-gc ; then
- if tc_version_is_at_least 7 ; then
- RDEPEND+=" objc-gc? ( >=dev-libs/boehm-gc-7.4.2 )"
- fi
-fi
-
-if tc_has_feature graphite ; then
- RDEPEND+=" graphite? ( >=dev-libs/isl-0.14:0= )"
-fi
-
-BDEPEND="
- >=sys-devel/bison-1.875
- >=sys-devel/flex-2.5.4
- nls? ( sys-devel/gettext )
- test? (
- >=dev-util/dejagnu-1.4.4
- >=sys-devel/autogen-5.5.4
- )"
-DEPEND="${RDEPEND}"
-
-if tc_has_feature gcj ; then
- DEPEND+="
- gcj? (
- awt? (
- x11-base/xorg-proto
- x11-libs/libXt
- x11-libs/libX11
- x11-libs/libXtst
- =x11-libs/gtk+-2*
- x11-libs/pango
- virtual/pkgconfig
- )
- >=media-libs/libart_lgpl-2.1
- app-arch/zip
- app-arch/unzip
- )
- "
-fi
-
-if tc_has_feature sanitize ; then
- # libsanitizer relies on 'crypt.h' to be present
- # on target. glibc user to provide it unconditionally.
- # Nowadays it's a standalone library: #802648
- DEPEND+=" sanitize? ( virtual/libcrypt )"
-fi
-
-if tc_has_feature systemtap ; then
- # gcc needs sys/sdt.h headers on target
- DEPEND+=" systemtap? ( dev-util/systemtap )"
-fi
-
-if tc_has_feature zstd ; then
- DEPEND+=" zstd? ( app-arch/zstd )"
-fi
-
-if tc_has_feature valgrind; then
- BDEPEND+=" valgrind? ( dev-util/valgrind )"
-fi
-
-case ${EAPI} in
- 5|6) DEPEND+=" ${BDEPEND}" ;;
-esac
-
-PDEPEND=">=sys-devel/gcc-config-2.3"
-
-#---->> S + SRC_URI essentials <<----
-
-# Set the source directory depending on whether we're using
-# a live git tree, snapshot, or release tarball.
-S=$(
- if tc_is_live ; then
- echo ${EGIT_CHECKOUT_DIR}
- elif [[ -n ${SNAPSHOT} ]] ; then
- echo ${WORKDIR}/gcc-${SNAPSHOT}
- else
- echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
- fi
-)
-
-gentoo_urls() {
- local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
- HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI
- HTTP~tamiko/distfiles/URI HTTP~sam/distfiles/URI
- HTTP~sam/distfiles/sys-devel/gcc/URI HTTP~slyfox/distfiles/URI"
- devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
- echo mirror://gentoo/$1 ${devspace//URI/$1}
-}
-
-# This function handles the basics of setting the SRC_URI for a gcc ebuild.
-# To use, set SRC_URI with:
-#
-# SRC_URI="$(get_gcc_src_uri)"
-#
-# 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.
-#
-# PATCH_VER
-# PATCH_GCC_VER
-# This should be set to the version of the gentoo patch tarball.
-# The resulting filename of this tarball will be:
-# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
-#
-# PIE_VER
-# PIE_GCC_VER
-# These variables control patching in various updates for the logic
-# controlling Position Independant Executables. PIE_VER is expected
-# to be the version of this patch, and PIE_GCC_VER the gcc version of
-# the patch:
-# An example:
-# PIE_VER="8.7.6.5"
-# PIE_GCC_VER="3.4.0"
-# The resulting filename of this tarball will be:
-# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
-#
-# SPECS_VER
-# SPECS_GCC_VER
-# This is for the minispecs files included in the hardened gcc-4.x
-# The specs files for hardenedno*, vanilla and for building the "specs" file.
-# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
-# the gcc version of the patch.
-# An example:
-# SPECS_VER="8.7.6.5"
-# SPECS_GCC_VER="3.4.0"
-# The resulting filename of this tarball will be:
-# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
-#
-# CYGWINPORTS_GITREV
-# If set, this variable signals that we should apply additional patches
-# maintained by upstream Cygwin developers at github/cygwinports/gcc,
-# using the specified git commit id there. The list of patches to
-# apply is extracted from gcc.cygport, maintained there as well.
-# This is done for compilers running on Cygwin, not for cross compilers
-# with a Cygwin target.
-get_gcc_src_uri() {
- export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
- export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
- export MUSL_GCC_VER=${MUSL_GCC_VER:-${PATCH_GCC_VER}}
- export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
- export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
- export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
-
- # Set where to download gcc itself depending on whether we're using a
- # 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
- 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
- fi
-
- [[ -n ${UCLIBC_VER} ]] && \
- GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
- [[ -n ${PATCH_VER} ]] && \
- GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
- [[ -n ${MUSL_VER} ]] && \
- GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.bz2)"
-
- [[ -n ${PIE_VER} ]] && \
- PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
- GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
-
- # gcc minispec for the hardened gcc 4 compiler
- [[ -n ${SPECS_VER} ]] && \
- GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
-
- if tc_has_feature gcj ; then
- if tc_version_is_at_least 4.5 ; then
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
- elif tc_version_is_at_least 4.3 ; then
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
- fi
- fi
-
- # Cygwin patches from https://github.com/cygwinports/gcc
- [[ -n ${CYGWINPORTS_GITREV} ]] && \
- GCC_SRC_URI+=" elibc_Cygwin? ( https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.tar.gz
- -> gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz )"
-
- echo "${GCC_SRC_URI}"
-}
-
-SRC_URI=$(get_gcc_src_uri)
-
-#---->> pkg_pretend <<----
-
-toolchain_pkg_pretend() {
- if ! _tc_use_if_iuse cxx ; then
- _tc_use_if_iuse go && \
- ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
- _tc_use_if_iuse objc++ && \
- ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
- _tc_use_if_iuse gcj && \
- ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
- fi
-
- want_minispecs
-}
-
-#---->> pkg_setup <<----
-
-toolchain_pkg_setup() {
- # we dont want to use the installed compiler's specs to build gcc
- unset GCC_SPECS
- unset LANGUAGES #265283
-}
-
-#---->> src_unpack <<----
-
-toolchain_src_unpack() {
- if tc_is_live ; then
- git-r3_src_unpack
- fi
-
- default_src_unpack
-}
-
-#---->> src_prepare <<----
-
-# 'epatch' is not available in EAPI=7. Abstract away patchset application
-# until we eventually get all gcc ebuilds on EAPI=7 or later.
-tc_apply_patches() {
- [[ ${#@} -lt 2 ]] && die "usage: tc_apply_patches <message> <patches...>"
-
- einfo "$1"; shift
-
- case ${EAPI} 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|8) eapply "$@" ;;
- *) die "Update apply_patches() for ${EAPI}." ;;
- esac
-}
-
-toolchain_src_prepare() {
- export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
- cd "${S}"
-
- do_gcc_gentoo_patches
- do_gcc_PIE_patches
- do_gcc_CYGWINPORTS_patches
-
- if tc_is_live ; then
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, commit ${EGIT_VERSION}"
- fi
-
- case ${EAPI} in
- 5) epatch_user;;
- 6|7|8) eapply_user ;;
- *) die "Update toolchain_src_prepare() for ${EAPI}." ;;
- esac
-
- if ( tc_version_is_at_least 4.8.2 || _tc_use_if_iuse hardened ) \
- && ! use vanilla ; then
- make_gcc_hard
- fi
-
- # make sure the pkg config files install into multilib dirs.
- # since we configure with just one --libdir, we can't use that
- # (as gcc itself takes care of building multilibs). #435728
- find "${S}" -name Makefile.in \
- -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
-
- setup_multilib_osdirnames
- gcc_version_patch
-
- 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
-
- # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
- if tc_version_is_at_least 4.3 && _tc_use_if_iuse gcj ; then
- if tc_version_is_at_least 4.5 ; then
- einfo "Copying ecj-4.5.jar"
- cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
- else
- einfo "Copying ecj-4.3.jar"
- cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
- fi
- fi
-
- # Prevent libffi from being installed
- if tc_version_is_between 3.0 4.8 ; then
- sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in || die
- sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in || die
- fi
-
- # Fixup libtool to correctly generate .la files with portage
- elibtoolize --portage --shallow --no-uclibc
-
- gnuconfig_update
-
- # update configure files
- local f
- einfo "Fixing misc issues in configure files"
- for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
- ebegin " Updating ${f/${S}\/} [LANG]"
- patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
- || eerror "Please file a bug about this"
- eend $?
- done
- sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
-
- # Prevent new texinfo from breaking old versions (see #198182, #464008)
- tc_apply_patches "Remove texinfo (bug #198182, bug #464008)" "${FILESDIR}"/gcc-configure-texinfo.patch
-
- # >=gcc-4
- if [[ -x contrib/gcc_update ]] ; then
- einfo "Touching generated files"
- ./contrib/gcc_update --touch | \
- while read f ; do
- einfo " ${f%%...}"
- done
- fi
-}
-
-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
-
- if [[ -n ${MUSL_VER} ]] && [[ ${CTARGET} == *musl* ]] ; then
- if [[ ${CATEGORY} == cross-* ]] ; then
- # We don't want to apply some patches when cross-compiling.
- if [[ -d "${WORKDIR}"/musl/nocross ]] ; then
- rm -fv "${WORKDIR}"/musl/nocross/*.patch || die
- fi
- fi
-
- tc_apply_patches "Applying musl patches ..." "${WORKDIR}"/musl/{,nocross/}*.patch
- fi
- fi
-}
-
-do_gcc_PIE_patches() {
- want_pie || return 0
- use vanilla && return 0
-
- tc_apply_patches "Applying pie patches ..." "${WORKDIR}"/piepatch/*.patch
-
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
-}
-
-do_gcc_CYGWINPORTS_patches() {
- [[ -n ${CYGWINPORTS_GITREV} ]] || return 0
- use elibc_Cygwin || return 0
-
- local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
- # readarray -t is available since bash-4.4 only, #690686
- 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
- if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
- einfo "Disabling PIE in stage1 (only) ..."
- sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
- fi
-
- # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
- if tc_version_is_at_least 6.0 ; then
- if _tc_use_if_iuse pie ; then
- einfo "Updating gcc to use automatic PIE building ..."
- fi
- if _tc_use_if_iuse ssp ; then
- einfo "Updating gcc to use automatic SSP building ..."
- fi
- if _tc_use_if_iuse hardened ; then
- # Will add some hardened options as default, like:
- # -fstack-clash-protection
- # -z now
- # see *_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}
- fi
- else
- if _tc_use_if_iuse hardened ; then
- # rebrand to make bug reports easier
- BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
- if hardened_gcc_works ; then
- einfo "Updating gcc to use automatic PIE + SSP building ..."
- gcc_hard_flags+=" -DEFAULT_PIE_SSP"
- elif hardened_gcc_works pie ; then
- einfo "Updating gcc to use automatic PIE building ..."
- ewarn "SSP has not been enabled by default"
- gcc_hard_flags+=" -DEFAULT_PIE"
- elif hardened_gcc_works ssp ; then
- einfo "Updating gcc to use automatic SSP building ..."
- ewarn "PIE has not been enabled by default"
- gcc_hard_flags+=" -DEFAULT_SSP"
- else
- # do nothing if hardened isn't supported, but don't die either
- ewarn "hardened is not supported for this arch in this gcc version"
- return 0
- fi
- else
- if hardened_gcc_works ssp ; then
- einfo "Updating gcc to use automatic SSP building ..."
- gcc_hard_flags+=" -DEFAULT_SSP"
- fi
- fi
- fi
-
- # we want to be able to control the pie patch logic via something other
- # than ALL_CFLAGS...
- sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
- -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
- -i "${S}"/gcc/Makefile.in
- # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
- if tc_version_is_at_least 4.7 ; then
- sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
- -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
- -i "${S}"/gcc/Makefile.in
- fi
-
- sed -i \
- -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
- "${S}"/gcc/Makefile.in || die
-
-}
-
-# This is a historical wart. The original Gentoo/amd64 port used:
-# lib32 - 32bit binaries (x86)
-# lib64 - 64bit binaries (x86_64)
-# lib - "native" binaries (a symlink to lib64)
-# Most other distros use the logic (including mainline gcc):
-# lib - 32bit binaries (x86)
-# lib64 - 64bit binaries (x86_64)
-# Over time, Gentoo is migrating to the latter form.
-#
-# Unfortunately, due to distros picking the lib32 behavior, newer gcc
-# versions will dynamically detect whether to use lib or lib32 for its
-# 32bit multilib. So, to keep the automagic from getting things wrong
-# while people are transitioning from the old style to the new style,
-# we always set the MULTILIB_OSDIRNAMES var for relevant targets.
-setup_multilib_osdirnames() {
- is_multilib || return 0
-
- local config
- local libdirs="../lib64 ../lib32"
-
- # this only makes sense for some Linux targets
- case ${CTARGET} in
- x86_64*-linux*) config="i386" ;;
- powerpc64*-linux*) config="rs6000" ;;
- sparc64*-linux*) config="sparc" ;;
- s390x*-linux*) config="s390" ;;
- *) return 0 ;;
- esac
- config+="/t-linux64"
-
- local sed_args=()
- if tc_version_is_at_least 4.6 ; then
- sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
- fi
- if [[ ${SYMLINK_LIB} == "yes" ]] ; then
- einfo "updating multilib directories to be: ${libdirs}"
- if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
- sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
- else
- sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
- fi
- else
- einfo "using upstream multilib; disabling lib32 autodetection"
- sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
- fi
- sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
-}
-
-gcc_version_patch() {
- # gcc-4.3+ has configure flags (whoo!)
- tc_version_is_at_least 4.3 && return 0
-
- local version_string=${GCC_RELEASE_VER}
-
- einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
-
- local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
- if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
- gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
- else
- version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
- gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
- fi
- sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
-}
-
-#---->> src_configure <<----
-
-toolchain_src_configure() {
- downgrade_arch_flags
- gcc_do_filter_flags
-
- einfo "CFLAGS=\"${CFLAGS}\""
- einfo "CXXFLAGS=\"${CXXFLAGS}\""
- einfo "LDFLAGS=\"${LDFLAGS}\""
-
- # Force internal zip based jar script to avoid random
- # issues with 3rd party jar implementations. #384291
- export JAR=no
-
- # For hardened gcc 4.3 piepatchset to build the hardened specs
- # file (build.specs) to use when building gcc.
- if ! tc_version_is_at_least 4.4 && want_minispecs ; then
- setup_minispecs_gcc_build_specs
- fi
-
- local confgcc=( --host=${CHOST} )
-
- if is_crosscompile || tc-is-cross-compiler ; then
- # Straight from the GCC install doc:
- # "GCC has code to correctly determine the correct value for target
- # for nearly all native systems. Therefore, we highly recommend you
- # not provide a configure target when configuring a native compiler."
- confgcc+=( --target=${CTARGET} )
- fi
- [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
-
- confgcc+=(
- --prefix="${PREFIX}"
- --bindir="${BINPATH}"
- --includedir="${INCLUDEPATH}"
- --datadir="${DATAPATH}"
- --mandir="${DATAPATH}/man"
- --infodir="${DATAPATH}/info"
- --with-gxx-include-dir="${STDCXX_INCDIR}"
- )
-
- # Stick the python scripts in their own slotted directory (bug #279252)
- #
- # --with-python-dir=DIR
- # Specifies where to install the Python modules used for aot-compile. DIR
- # should not include the prefix used in installation. For example, if the
- # Python modules are to be installed in /usr/lib/python2.5/site-packages,
- # then --with-python-dir=/lib/python2.5/site-packages should be passed.
- #
- # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
- if tc_version_is_at_least 4.4 ; then
- confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
- fi
-
- ### language options
-
- local GCC_LANG="c"
- is_cxx && GCC_LANG+=",c++"
- is_d && GCC_LANG+=",d"
- is_gcj && GCC_LANG+=",java"
- is_go && GCC_LANG+=",go"
- is_jit && GCC_LANG+=",jit"
- if is_objc || is_objcxx ; then
- GCC_LANG+=",objc"
- use objc-gc && confgcc+=( --enable-objc-gc )
- is_objcxx && GCC_LANG+=",obj-c++"
- fi
-
- # fortran support just got sillier! the lang value can be f77 for
- # fortran77, f95 for fortran95, or just plain old fortran for the
- # currently supported standard depending on gcc version.
- is_fortran && GCC_LANG+=",fortran"
- is_f77 && GCC_LANG+=",f77"
- is_f95 && GCC_LANG+=",f95"
-
- is_ada && GCC_LANG+=",ada"
-
- confgcc+=( --enable-languages=${GCC_LANG} )
-
- ### general options
-
- confgcc+=(
- --enable-obsolete
- --enable-secureplt
- --disable-werror
- --with-system-zlib
- )
-
- if use nls ; then
- confgcc+=( --enable-nls --without-included-gettext )
- else
- confgcc+=( --disable-nls )
- fi
-
- confgcc+=( --disable-libunwind-exceptions )
-
- # Use the default ("release") checking because upstream usually neglects
- # to test "disabled" so it has a history of breaking. bug #317217
- if in_iuse debug ; then
- # The "release" keyword is new to 4.0. bug #551636
- local off=$(tc_version_is_at_least 4.0 && echo release || echo no)
- confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes ${off})}" )
- fi
-
- # Branding
- tc_version_is_at_least 4.3 && confgcc+=(
- --with-bugurl=https://bugs.gentoo.org/
- --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
- )
-
- # If we want hardened support with the newer piepatchset for >=gcc 4.4
- if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then
- confgcc+=( $(use_enable hardened esp) )
- fi
-
- # allow gcc to search for clock funcs in the main C lib.
- # if it can't find them, then tough cookies -- we aren't
- # going to link in -lrt to all C++ apps. bug #411681
- if tc_version_is_at_least 4.4 && is_cxx ; then
- confgcc+=( --enable-libstdcxx-time )
- fi
-
- # Build compiler itself using LTO
- if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then
- confgcc+=( --with-build-config=bootstrap-lto )
- fi
-
- # Support to disable pch when building libstdcxx
- if tc_version_is_at_least 6.0 && ! _tc_use_if_iuse pch ; then
- confgcc+=( --disable-libstdcxx-pch )
- fi
-
- # The jit language requires this.
- is_jit && confgcc+=( --enable-host-shared )
-
- # build-id was disabled for file collisions: bug #526144
- #
- # # Turn on the -Wl,--build-id flag by default for ELF targets. bug #525942
- # # This helps with locating debug files.
- # case ${CTARGET} in
- # *-linux-*|*-elf|*-eabi)
- # tc_version_is_at_least 4.5 && confgcc+=(
- # --enable-linker-build-id
- # )
- # ;;
- # esac
-
- # newer gcc versions like to bootstrap themselves with C++,
- # so we need to manually disable it ourselves
- if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
- confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
- fi
-
- ### Cross-compiler options
- if is_crosscompile ; then
- # Enable build warnings by default with cross-compilers when system
- # paths are included (e.g. via -I flags).
- confgcc+=( --enable-poison-system-directories )
-
- # When building a stage1 cross-compiler (just C compiler), we have to
- # disable a bunch of features or gcc goes boom
- local needed_libc=""
- case ${CTARGET} in
- *-linux) needed_libc=error-unknown-libc;;
- *-dietlibc) needed_libc=dietlibc;;
- *-elf|*-eabi)
- needed_libc=newlib
- # Bare-metal targets don't have access to clock_gettime()
- # arm-none-eabi example: bug #589672
- # But we explicitly do --enable-libstdcxx-time above.
- # Undoing it here.
- confgcc+=( --disable-libstdcxx-time )
- ;;
- *-freebsd*) needed_libc=freebsd-lib;;
- *-gnu*) needed_libc=glibc;;
- *-klibc) needed_libc=klibc;;
- *-musl*) needed_libc=musl;;
- *-uclibc*)
- # Enable shared library support only on targets
- # that support it: bug #291870
- if ! echo '#include <features.h>' | \
- $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
- grep -q __HAVE_SHARED__
- then
- confgcc+=( --disable-shared )
- fi
- needed_libc=uclibc-ng
- ;;
- *-cygwin) needed_libc=cygwin;;
- x86_64-*-mingw*|\
- *-w64-mingw*) needed_libc=mingw64-runtime;;
- avr) confgcc+=( --enable-shared --disable-threads );;
- esac
- if [[ -n ${needed_libc} ]] ; then
- local confgcc_no_libc=( --disable-shared )
- # requires libc: bug #734820
- tc_version_is_at_least 4.6 && confgcc_no_libc+=( --disable-libquadmath )
- # requires libc
- tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
- if ! has_version ${CATEGORY}/${needed_libc} ; then
- confgcc+=(
- "${confgcc_no_libc[@]}"
- --disable-threads
- --without-headers
- )
- if [[ $needed_libc == glibc ]]; then
- # By default gcc looks at glibc's headers
- # to detect long double support. This does
- # not work for --disable-headers mode.
- # Any >=glibc-2.4 is good enough for float128.
- # The option appeared in gcc-4.2.
- confgcc+=( --with-long-double-128 )
- fi
- elif has_version "${CATEGORY}/${needed_libc}[headers-only(-)]" ; then
- confgcc+=(
- "${confgcc_no_libc[@]}"
- --with-sysroot="${PREFIX}"/${CTARGET}
- )
- else
- confgcc+=( --with-sysroot="${PREFIX}"/${CTARGET} )
- fi
- fi
-
- confgcc+=( --disable-bootstrap )
- else
- if tc-is-static-only ; then
- confgcc+=( --disable-shared )
- else
- confgcc+=( --enable-shared )
- fi
- case ${CHOST} in
- mingw*|*-mingw*)
- confgcc+=( --enable-threads=win32 ) ;;
- *)
- confgcc+=( --enable-threads=posix ) ;;
- esac
- fi
-
- # __cxa_atexit is "essential for fully standards-compliant handling of
- # destructors", but apparently requires glibc.
- case ${CTARGET} in
- *-uclibc*)
- if tc_has_feature nptl ; then
- confgcc+=(
- --disable-__cxa_atexit
- $(use_enable nptl tls)
- )
- fi
- ;;
- *-elf|*-eabi)
- confgcc+=( --with-newlib )
- ;;
- *-musl*)
- confgcc+=( --enable-__cxa_atexit )
- ;;
- *-gnu*)
- confgcc+=(
- --enable-__cxa_atexit
- --enable-clocale=gnu
- )
- ;;
- *-freebsd*)
- confgcc+=( --enable-__cxa_atexit )
- ;;
- *-solaris*)
- confgcc+=( --enable-__cxa_atexit )
- ;;
- esac
-
- ### arch options
-
- gcc-multilib-configure
-
- # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
- # significantly increase compile time by several hours. This will allow
- # users to control this feature in the event they need the support.
- tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
-
- case $(tc-is-softfloat) in
- yes) confgcc+=( --with-float=soft ) ;;
- softfp) confgcc+=( --with-float=softfp ) ;;
- *)
- # If they've explicitly opt-ed in, do hardfloat,
- # otherwise let the gcc default kick in.
- case ${CTARGET//_/-} in
- *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
- esac
- esac
-
- local with_abi_map=()
- case $(tc-arch) in
- arm) #264534 #414395
- local a arm_arch=${CTARGET%%-*}
- # Remove trailing endian variations first: eb el be bl b l
- for a in e{b,l} {b,l}e b l ; do
- if [[ ${arm_arch} == *${a} ]] ; then
- arm_arch=${arm_arch%${a}}
- break
- fi
- done
- # Convert armv7{a,r,m} to armv7-{a,r,m}
- [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
- # See if this is a valid --with-arch flag
- if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
- . "${srcdir}"/config.gcc) &>/dev/null
- then
- confgcc+=( --with-arch=${arm_arch} )
- fi
-
- # Make default mode thumb for microcontroller classes #418209
- [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
-
- # Enable hardvfp
- if [[ $(tc-is-softfloat) == "no" ]] && \
- [[ ${CTARGET} == armv[67]* ]] && \
- tc_version_is_at_least 4.5
- then
- # Follow the new arm hardfp distro standard by default
- confgcc+=( --with-float=hard )
- case ${CTARGET} in
- armv6*) confgcc+=( --with-fpu=vfp ) ;;
- armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
- esac
- fi
- ;;
- mips)
- # Add --with-abi flags to set default ABI
- confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
- ;;
- amd64)
- # drop the older/ABI checks once this get's merged into some
- # version of gcc upstream
- if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
- confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
- fi
- ;;
- x86)
- # Default arch for x86 is normally i386, lets give it a bump
- # since glibc will do so based on CTARGET anyways
- confgcc+=( --with-arch=${CTARGET%%-*} )
- ;;
- hppa)
- # Enable sjlj exceptions for backward compatibility on hppa
- [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
- ;;
- ppc)
- # Set up defaults based on current CFLAGS
- is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
- [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
- ;;
- ppc64)
- # On ppc64 big endian target gcc assumes elfv1 by default,
- # and elfv2 on little endian
- # but musl does not support elfv1 at all on any endian ppc64
- # see https://git.musl-libc.org/cgit/musl/tree/INSTALL
- # https://bugs.gentoo.org/704784
- # https://gcc.gnu.org/PR93157
- [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
- ;;
- riscv)
- # Add --with-abi flags to set default ABI
- confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
- ;;
- esac
-
- # if the target can do biarch (-m32/-m64), enable it. overhead should
- # be small, and should simplify building of 64bit kernels in a 32bit
- # userland by not needing sys-devel/kgcc64. #349405
- case $(tc-arch) in
- ppc|ppc64) confgcc+=( --enable-targets=all ) ;;
- sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
- amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
- esac
-
- # On Darwin we need libdir to be set in order to get correct install names
- # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
- # non-Darwin we screw up the behaviour this eclass relies on. We in
- # particular need this over --libdir for bug #255315.
- [[ ${CTARGET} == *-darwin* ]] && \
- confgcc+=( --enable-version-specific-runtime-libs )
-
- ### library options
-
- if tc_version_is_between 3.0 7.0 ; then
- if is_gcj ; then
- confgcc+=( --disable-gjdoc )
- use awt && confgcc+=( --enable-java-awt=gtk )
- else
- confgcc+=( --disable-libgcj )
- fi
- fi
-
- if in_iuse openmp ; then
- # Make sure target has pthreads support. #326757 #335883
- # There shouldn't be a chicken & egg problem here as openmp won't
- # build without a C library, and you can't build that w/out
- # already having a compiler ...
- if ! is_crosscompile || \
- $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
- then
- confgcc+=( $(use_enable openmp libgomp) )
- else
- # Force disable as the configure script can be dumb #359855
- confgcc+=( --disable-libgomp )
- fi
- else
- # For gcc variants where we don't want openmp (e.g. kgcc)
- confgcc+=( --disable-libgomp )
- fi
-
- if _tc_use_if_iuse libssp ; then
- confgcc+=( --enable-libssp )
- else
- if hardened_gcc_is_stable ssp; then
- export gcc_cv_libc_provides_ssp=yes
- fi
- if _tc_use_if_iuse ssp; then
- # On some targets USE="ssp -libssp" is an invalid
- # configuration as target libc does not provide
- # stack_chk_* functions. Do not disable libssp there.
- case ${CTARGET} in
- mingw*|*-mingw*) ewarn "Not disabling libssp" ;;
- *) confgcc+=( --disable-libssp ) ;;
- esac
- else
- confgcc+=( --disable-libssp )
- fi
- fi
-
- if in_iuse ada ; then
- confgcc+=( --disable-libada )
- fi
-
- if in_iuse cilk ; then
- confgcc+=( $(use_enable cilk libcilkrts) )
- fi
-
- if in_iuse mpx ; then
- confgcc+=( $(use_enable mpx libmpx) )
- fi
-
- if in_iuse systemtap ; then
- confgcc+=( $(use_enable systemtap) )
- fi
-
- if in_iuse valgrind ; then
- confgcc+=( $(use_enable valgrind valgrind-annotations) )
- fi
-
- if in_iuse vtv ; then
- confgcc+=(
- $(use_enable vtv vtable-verify)
- # See Note [implicitly enabled flags]
- $(usex vtv '' --disable-libvtv)
- )
- fi
-
- if in_iuse zstd ; then
- confgcc+=( $(use_with zstd) )
- fi
-
- if tc_version_is_at_least 4.6 ; then
- confgcc+=( --enable-lto )
- elif tc_version_is_at_least 4.5 ; then
- confgcc+=( --disable-lto )
- fi
-
- # graphite was added in 4.4 but we only support it in 6.5+ due to external
- # library issues. #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 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; 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
- confgcc+=( $(use_enable pie default-pie) )
- fi
-
- if tc_version_is_at_least 6.0 && in_iuse ssp ; then
- confgcc+=(
- # This defaults to -fstack-protector-strong.
- $(use_enable ssp default-ssp)
- )
- fi
-
- # Disable gcc info regeneration -- it ships with generated info pages
- # already. Our custom version/urls/etc... trigger it. #464008
- export gcc_cv_prog_makeinfo_modern=no
-
- # Do not let the X detection get in our way. We know things can be found
- # via system paths, so no need to hardcode things that'll break multilib.
- # Older gcc versions will detect ac_x_libraries=/usr/lib64 which ends up
- # killing the 32bit builds which want /usr/lib.
- export ac_cv_have_x='have_x=yes ac_x_includes= ac_x_libraries='
-
- confgcc+=( "$@" ${EXTRA_ECONF} )
-
- # Nothing wrong with a good dose of verbosity
- echo
- einfo "PREFIX: ${PREFIX}"
- einfo "BINPATH: ${BINPATH}"
- einfo "LIBPATH: ${LIBPATH}"
- einfo "DATAPATH: ${DATAPATH}"
- einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
- echo
- einfo "Languages: ${GCC_LANG}"
- echo
- einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}"
- echo
-
- # Build in a separate build tree
- mkdir -p "${WORKDIR}"/build
- pushd "${WORKDIR}"/build > /dev/null
-
- # and now to do the actual configuration
- addwrite /dev/zero
- echo "${S}"/configure "${confgcc[@]}"
- # Older gcc versions did not detect bash and re-exec itself, so force the
- # use of bash. Newer ones will auto-detect, but this is not harmful.
- CONFIG_SHELL="${EPREFIX}/bin/bash" \
- bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
-
- # return to whatever directory we were in before
- popd > /dev/null
-}
-
-# Replace -m flags unsupported by the version being built with the best
-# available equivalent
-downgrade_arch_flags() {
- local arch bver i isa myarch mytune rep ver
-
- bver=${1:-${GCC_BRANCH_VER}}
- # 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)
- mytune=$(get-flag mtune)
-
- # Handle special -mtune flags
- [[ ${mytune} == intel ]] && ! tc_version_is_at_least 4.9 ${bver} && replace-cpu-flags intel generic
- [[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
-
- # "added" "arch" "replacement"
- local archlist=(
- 10 znver3 znver2
- 9 znver2 znver1
- 4.9 bdver4 bdver3
- 4.9 bonnell atom
- 4.9 broadwell core-avx2
- 4.9 haswell core-avx2
- 4.9 ivybridge core-avx-i
- 4.9 nehalem corei7
- 4.9 sandybridge corei7-avx
- 4.9 silvermont corei7
- 4.9 westmere corei7
- 4.8 bdver3 bdver2
- 4.8 btver2 btver1
- 4.7 bdver2 bdver1
- 4.7 core-avx2 core-avx-i
- 4.6 bdver1 amdfam10
- 4.6 btver1 amdfam10
- 4.6 core-avx-i core2
- 4.6 corei7 core2
- 4.6 corei7-avx core2
- 4.5 atom core2
- 4.3 amdfam10 k8
- 4.3 athlon64-sse3 k8
- 4.3 barcelona k8
- 4.3 core2 nocona
- 4.3 geode k6-2 # gcc.gnu.org/PR41989#c22
- 4.3 k8-sse3 k8
- 4.3 opteron-sse3 k8
- )
-
- for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do
- myarch=$(get-flag march)
- mytune=$(get-flag mtune)
-
- ver=${archlist[i]}
- arch=${archlist[i + 1]}
- rep=${archlist[i + 2]}
-
- [[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue
-
- 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
- else
- break
- fi
- done
-
- # we only check -mno* here since -m* get removed by strip-flags later on
- local isalist=(
- 4.9 -mno-sha
- 4.9 -mno-avx512pf
- 4.9 -mno-avx512f
- 4.9 -mno-avx512er
- 4.9 -mno-avx512cd
- 4.8 -mno-xsaveopt
- 4.8 -mno-xsave
- 4.8 -mno-rtm
- 4.8 -mno-fxsr
- 4.7 -mno-lzcnt
- 4.7 -mno-bmi2
- 4.7 -mno-avx2
- 4.6 -mno-tbm
- 4.6 -mno-rdrnd
- 4.6 -mno-fsgsbase
- 4.6 -mno-f16c
- 4.6 -mno-bmi
- 4.5 -mno-xop
- 4.5 -mno-movbe
- 4.5 -mno-lwp
- 4.5 -mno-fma4
- 4.4 -mno-pclmul
- 4.4 -mno-fma
- 4.4 -mno-avx
- 4.4 -mno-aes
- 4.3 -mno-ssse3
- 4.3 -mno-sse4a
- 4.3 -mno-sse4
- 4.3 -mno-sse4.2
- 4.3 -mno-sse4.1
- 4.3 -mno-popcnt
- 4.3 -mno-abm
- )
-
- for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do
- ver=${isalist[i]}
- isa=${isalist[i + 1]}
- tc_version_is_at_least ${ver} ${bver} || filter-flags ${isa} ${isa/-m/-mno-}
- done
-}
-
-gcc_do_filter_flags() {
- # Allow users to explicitly avoid flag sanitization via
- # USE=custom-cflags.
- if ! _tc_use_if_iuse custom-cflags; then
- # Over-zealous CFLAGS can often cause problems. What may work for one
- # person may not work for another. To avoid a large influx of bugs
- # relating to failed builds, we strip most CFLAGS out to ensure as few
- # problems as possible.
- strip-flags
- # Lock gcc at -O2; we want to be conservative here.
- filter-flags '-O?'
- append-flags -O2
- fi
-
- # dont want to funk ourselves
- filter-flags '-mabi*' -m31 -m32 -m64
-
- filter-flags -frecord-gcc-switches # 490738
- filter-flags -mno-rtm -mno-htm # 506202
-
- if tc_version_is_between 6 8 ; then
- # -mstackrealign triggers crashes in exception throwing
- # at least on ada: bug #688580
- # The reason is unknown. Drop the flag for now.
- filter-flags -mstackrealign
- fi
-
- case $(tc-arch) in
- amd64|x86)
- filter-flags '-mcpu=*'
-
- tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287
-
- if tc_version_is_between 4.6 4.7 ; then
- # https://bugs.gentoo.org/411333
- # https://bugs.gentoo.org/466454
- replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
- fi
- ;;
- alpha)
- # https://bugs.gentoo.org/454426
- append-ldflags -Wl,--no-relax
- ;;
- sparc)
- # temporary workaround for random ICEs reproduced by multiple users
- # https://bugs.gentoo.org/457062
- tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
- ;;
- *-macos)
- # http://gcc.gnu.org/PR25127
- tc_version_is_between 4.0 4.2 && \
- filter-flags '-mcpu=*' '-march=*' '-mtune=*'
- ;;
- esac
-
- strip-unsupported-flags
-
- # these are set here so we have something sane at configure time
- if is_crosscompile ; then
- # Set this to something sane for both native and target
- CFLAGS="-O2 -pipe"
- FFLAGS=${CFLAGS}
- FCFLAGS=${CFLAGS}
-
- # "hppa2.0-unknown-linux-gnu" -> hppa2_0_unknown_linux_gnu
- local VAR="CFLAGS_"${CTARGET//[-.]/_}
- CXXFLAGS=${!VAR-${CFLAGS}}
- fi
-
- export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
-}
-
-setup_minispecs_gcc_build_specs() {
- # Setup the "build.specs" file for gcc 4.3 to use when building.
- if hardened_gcc_works pie ; then
- cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
- fi
- if hardened_gcc_works ssp ; then
- for s in ssp sspall ; do
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
- done
- fi
- for s in nostrict znow ; do
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
- done
- export GCC_SPECS="${WORKDIR}"/build.specs
-}
-
-gcc-multilib-configure() {
- if ! is_multilib ; then
- confgcc+=( --disable-multilib )
- # Fun times: if we are building for a target that has multiple
- # possible ABI formats, and the user has told us to pick one
- # that isn't the default, then not specifying it via the list
- # below will break that on us.
- else
- confgcc+=( --enable-multilib )
- fi
-
- # translate our notion of multilibs into gcc's
- local abi list
- for abi in $(get_all_abis TARGET) ; do
- local l=$(gcc-abi-map ${abi})
- [[ -n ${l} ]] && list+=",${l}"
- done
- if [[ -n ${list} ]] ; then
- case ${CTARGET} in
- x86_64*)
- tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} )
- ;;
- esac
- fi
-}
-
-gcc-abi-map() {
- # Convert the ABI name we use in Gentoo to what gcc uses
- local map=()
- case ${CTARGET} in
- mips*) map=("o32 32" "n32 n32" "n64 64") ;;
- riscv*) map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32") ;;
- x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
- esac
-
- local m
- for m in "${map[@]}" ; do
- l=( ${m} )
- [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
- done
-}
-
-#----> src_compile <----
-
-toolchain_src_compile() {
- touch "${S}"/gcc/c-gperf.h
-
- # Do not make manpages if we do not have perl ...
- [[ ! -x /usr/bin/perl ]] \
- && find "${WORKDIR}"/build -name '*.[17]' -exec touch {} +
-
- # To compile ada library standard files special compiler options are passed
- # via ADAFLAGS in the Makefile.
- # Unset ADAFLAGS as setting this override the options
- unset ADAFLAGS
-
- # Older gcc versions did not detect bash and re-exec itself, so force the
- # use of bash. Newer ones will auto-detect, but this is not harmful.
- # This needs to be set for compile as well, as it's used in libtool
- # generation, which will break install otherwise (at least in 3.3.6): #664486
- CONFIG_SHELL="${EPREFIX}/bin/bash" \
- gcc_do_make ${GCC_MAKE_TARGET}
-}
-
-gcc_do_make() {
- # This function accepts one optional argument, the make target to be used.
- # If omitted, gcc_do_make will try to guess whether it should use all,
- # or bootstrap-lean depending on CTARGET and arch.
- # An example of how to use this function:
- #
- # gcc_do_make all-target-libstdc++-v3
-
- [[ -n ${1} ]] && GCC_MAKE_TARGET=${1}
-
- # default target
- if is_crosscompile || tc-is-cross-compiler ; then
- # 3 stage bootstrapping doesnt quite work when you cant run the
- # resulting binaries natively ^^;
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
- else
- if _tc_use_if_iuse pgo; then
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
- else
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
- fi
- fi
-
- # Older versions of GCC could not do profiledbootstrap in parallel due to
- # collisions with profiling info.
- if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]]; then
- ! tc_version_is_at_least 4.6 && export MAKEOPTS="${MAKEOPTS} -j1"
- fi
-
- if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
- elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
- # See bug #79852
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
- fi
-
- if is_crosscompile; then
- # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
- # but I'll leave this in anyways as someone might have had
- # some reason for putting it in here... --eradicator
- BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
- else
- # we only want to use the system's CFLAGS if not building a
- # cross-compiler.
- BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
- fi
-
- einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
-
- pushd "${WORKDIR}"/build >/dev/null
-
- emake \
- LDFLAGS="${LDFLAGS}" \
- STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
- LIBPATH="${LIBPATH}" \
- BOOT_CFLAGS="${BOOT_CFLAGS}" \
- ${GCC_MAKE_TARGET} \
- || die "emake failed with ${GCC_MAKE_TARGET}"
-
- if is_ada; then
- # Without these links it is not getting the good compiler
- # Need to check why
- ln -s gcc ../build/prev-gcc || die
- ln -s ${CHOST} ../build/prev-${CHOST} || die
- # Building standard ada library
- emake -C gcc gnatlib-shared
- # Building gnat toold
- emake -C gcc gnattools
- fi
-
- if ! is_crosscompile && _tc_use_if_iuse cxx && _tc_use_if_iuse doc ; then
- if type -p doxygen > /dev/null ; then
- if tc_version_is_at_least 4.3 ; then
- cd "${CTARGET}"/libstdc++-v3/doc
- emake doc-man-doxygen || ewarn "failed to make docs"
- else
- cd "${CTARGET}"/libstdc++-v3
- emake doxygen-man || ewarn "failed to make docs"
- fi
- # Clean bogus manpages. #113902
- find -name '*_build_*' -delete
- # Blow away generated directory references. Newer versions of gcc
- # have gotten better at this, but not perfect. This is easier than
- # backporting all of the various doxygen patches. #486754
- find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
- xargs rm -f
- else
- ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
- fi
- fi
-
- popd >/dev/null
-}
-
-#---->> src_test <<----
-
-toolchain_src_test() {
- cd "${WORKDIR}"/build
- # 'asan' wants to be preloaded first, so does 'sandbox'.
- # To make asan tests work disable sandbox for all of test suite.
- # 'backtrace' tests also does not like 'libsandbox.so' presence.
- SANDBOX_ON=0 LD_PRELOAD= emake -k check
-}
-
-#---->> src_install <<----
-
-toolchain_src_install() {
- cd "${WORKDIR}"/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
- # build system only expects to install out of the build dir, not the source. #464008
- mkdir -p gcc/doc
- local x=
- for x in "${S}"/gcc/doc/*.info* ; do
- if [[ -f ${x} ]] ; then
- cp "${x}" gcc/doc/ || die
- fi
- done
-
- # We remove the generated fixincludes, as they can cause things to break
- # (ncurses, openssl, etc). We do not prevent them from being built, as
- # in the following commit which we revert:
- # https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
- # This is because bsd userland needs fixedincludes to build gcc, while
- # linux does not. Both can dispose of them afterwards.
- while read x ; do
- grep -q 'It has been auto-edited by fixincludes from' "${x}" \
- && rm -f "${x}"
- done < <(find gcc/include*/ -name '*.h')
-
- # Do the 'make install' from the build directory
- S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
-
- # Punt some tools which are really only useful while building gcc
- find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
- # This one comes with binutils
- find "${ED}" -name libiberty.a -delete
-
- # Move the libraries to the proper location
- gcc_movelibs
-
- # Basic sanity check
- if ! is_crosscompile ; then
- local EXEEXT
- eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
- [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
- fi
-
- 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
-
- # Make sure we dont have stuff lying around that
- # can nuke multiple versions of gcc
- gcc_slot_java
-
- dodir /usr/bin
- 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 gnat* ; do
- # For some reason, g77 gets made instead of ${CTARGET}-g77...
- # this should take care of that
- if [[ -f ${x} ]] ; then
- # In case they're hardlinks, clear out the target first
- # otherwise the mv below will complain.
- rm -f ${CTARGET}-${x}
- mv ${x} ${CTARGET}-${x}
- fi
-
- if [[ -f ${CTARGET}-${x} ]] ; then
- if ! is_crosscompile ; then
- ln -sf ${CTARGET}-${x} ${x}
- dosym ${BINPATH}/${CTARGET}-${x} \
- /usr/bin/${x}-${GCC_CONFIG_VER}
- fi
- # Create versioned symlinks
- dosym ${BINPATH}/${CTARGET}-${x} \
- /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
- fi
-
- if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
- rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
- ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
- fi
- done
-
- # When gcc builds a crosscompiler it does not install unprefixed tools.
- # When cross-building gcc does install native tools.
- if ! is_crosscompile; then
- # Rename the main go binaries as we don't want to clobber dev-lang/go
- # when gcc-config runs. #567806
- if tc_version_is_at_least 5 && is_go ; then
- for x in go gofmt; do
- mv ${x} ${x}-${GCCMAJOR} || die
- done
- fi
- fi
-
- # 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
- rm -rf "${ED}"/usr/share/{man,info}
- rm -rf "${D}"${DATAPATH}/{man,info}
- else
- local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
- if [[ -d ${cxx_mandir} ]] ; then
- cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
- fi
- fi
-
- # portage regenerates 'dir' files on it's own: bug #672408
- # Drop 'dir' files to avoid collisions.
- if [[ -f "${D}${DATAPATH}"/info/dir ]]; then
- einfo "Deleting '${D}${DATAPATH}/info/dir'"
- rm "${D}${DATAPATH}"/info/dir || die
- fi
-
- # prune empty dirs left behind
- find "${ED}" -depth -type d -delete 2>/dev/null
-
- # libstdc++.la: Delete as it doesn't add anything useful: g++ itself
- # handles linkage correctly in the dynamic & static case. It also just
- # causes us pain: any C++ progs/libs linking with libtool will gain a
- # reference to the full libstdc++.la file which is gcc version specific.
- # libstdc++fs.la: It doesn't link against anything useful.
- # 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.
- # libgfortran.la: gfortran itself handles linkage correctly in the
- # dynamic & static case (libgfortran.spec). #573302
- # libgfortranbegin.la: Same as above, and it's an internal lib.
- # libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
- # libmpxwrappers.la: See above.
- # libitm.la: gcc itself handles linkage correctly (libitm.spec).
- # libvtv.la: gcc itself handles linkage correctly.
- # lib*san.la: Sanitizer linkage is handled internally by gcc, and they
- # do not support static linking. #487550 #546700
- find "${D}${LIBPATH}" \
- '(' \
- -name libstdc++.la -o \
- -name libstdc++fs.la -o \
- -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 \
- -name libgfortranbegin.la -o \
- -name libmpx.la -o \
- -name libmpxwrappers.la -o \
- -name libitm.la -o \
- -name libvtv.la -o \
- -name 'lib*san.la' \
- ')' -type f -delete
-
- # Use gid of 0 because some stupid ports don't have
- # the group 'root' set to gid 0. Send to /dev/null
- # for people who are testing as non-root.
- chown -R root:0 "${D}${LIBPATH}" 2>/dev/null
-
- # Installing gdb pretty-printers into gdb-specific location.
- local py gdbdir=/usr/share/gdb/auto-load${LIBPATH}
- pushd "${D}${LIBPATH}" >/dev/null
- for py in $(find . -name '*-gdb.py') ; do
- local multidir=${py%/*}
- insinto "${gdbdir}/${multidir}"
- sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
- doins "${py}" || die
- rm "${py}" || die
- done
- popd >/dev/null
-
- # Don't scan .gox files for executable stacks - false positives
- export QA_EXECSTACK="usr/lib*/go/*/*.gox"
- export QA_WX_LOAD="usr/lib*/go/*/*.gox"
-
- # Disable RANDMMAP so PCH works. #301299
- if tc_version_is_at_least 4.3 ; then
- pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
- pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
- fi
-
- # Disable MPROTECT so java works. #574808
- if is_gcj ; then
- pax-mark -m "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
- pax-mark -m "${D}${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
- fi
-}
-
-# Move around the libs to the right location. For some reason,
-# when installing gcc, it dumps internal libraries into /usr/lib
-# instead of the private gcc lib path
-gcc_movelibs() {
- # For non-target libs which are for CHOST and not CTARGET, we want to
- # move them to the compiler-specific CHOST internal dir. This is stuff
- # that you want to link against when building tools rather than building
- # code to run on the target.
- if tc_version_is_at_least 5 && is_crosscompile ; then
- dodir "${HOSTLIBPATH#${EPREFIX}}"
- mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
- fi
- # libgccjit gets installed to /usr/lib, not /usr/$(get_libdir). Probably
- # due to a bug in gcc build system.
- if is_jit ; then
- dodir "${LIBPATH#${EPREFIX}}"
- mv "${ED}"/usr/lib/libgccjit* "${D}${LIBPATH}" || die
- fi
-
- # For all the libs that are built for CTARGET, move them into the
- # compiler-specific CTARGET internal dir.
- local x multiarg removedirs=""
- for multiarg in $($(XGCC) -print-multi-lib) ; do
- multiarg=${multiarg#*;}
- multiarg=${multiarg//@/ -}
-
- local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
- local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
- local TODIR="${D}${LIBPATH}"/${MULTIDIR}
- local FROMDIR=
-
- [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
-
- for FROMDIR in \
- "${LIBPATH}"/${OS_MULTIDIR} \
- "${LIBPATH}"/../${MULTIDIR} \
- "${PREFIX}"/lib/${OS_MULTIDIR} \
- "${PREFIX}"/${CTARGET}/lib/${OS_MULTIDIR}
- do
- removedirs="${removedirs} ${FROMDIR}"
- FROMDIR=${D}${FROMDIR}
- if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
- local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
- if [[ -n ${files} ]] ; then
- mv ${files} "${TODIR}" || die
- fi
- fi
- done
- fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
-
- # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
- FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
- for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
- [[ -f ${x} ]] || continue
- sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}" || die
- mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
- done
- done
-
- # We remove directories separately to avoid this case:
- # mv SRC/lib/../lib/*.o DEST
- # rmdir SRC/lib/../lib/
- # mv SRC/lib/../lib32/*.o DEST # Bork
- for FROMDIR in ${removedirs} ; do
- rmdir "${D}"${FROMDIR} >& /dev/null
- done
- find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
-}
-
-# make sure the libtool archives have libdir set to where they actually
-# -are-, and not where they -used- to be. also, any dependencies we have
-# on our own .la files need to be updated.
-fix_libtool_libdir_paths() {
- local libpath="$1"
-
- pushd "${D}" >/dev/null
-
- pushd "./${libpath}" >/dev/null
- local dir="${PWD#${D%/}}"
- local allarchives=$(echo *.la)
- allarchives="\(${allarchives// /\\|}\)"
- popd >/dev/null
-
- # The libdir might not have any .la files. #548782
- find "./${dir}" -maxdepth 1 -name '*.la' \
- -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
- # Would be nice to combine these, but -maxdepth can not be specified
- # on sub-expressions.
- find "./${PREFIX}"/lib* -maxdepth 3 -name '*.la' \
- -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
- find "./${dir}/" -maxdepth 1 -name '*.la' \
- -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
-
- popd >/dev/null
-}
-
-create_gcc_env_entry() {
- dodir /etc/env.d/gcc
- local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
-
- local gcc_specs_file
- local gcc_envd_file="${ED}${gcc_envd_base}"
- if [[ -z $1 ]] ; then
- # I'm leaving the following commented out to remind me that it
- # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
- # on chroot or in non-toolchain.eclass gcc ebuilds!
- #gcc_specs_file="${LIBPATH}/specs"
- gcc_specs_file=""
- else
- gcc_envd_file+="-$1"
- gcc_specs_file="${LIBPATH}/$1.specs"
- fi
-
- # We want to list the default ABI's LIBPATH first so libtool
- # searches that directory first. This is a temporary
- # workaround for libtool being stupid and using .la's from
- # conflicting ABIs by using the first one in the search path
- local ldpaths mosdirs
- local mdir mosdir abi ldpath
- for abi in $(get_all_abis TARGET) ; do
- mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
- ldpath=${LIBPATH}
- [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
- ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
-
- mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
- mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
- done
-
- cat <<-EOF > ${gcc_envd_file}
- GCC_PATH="${BINPATH}"
- LDPATH="${ldpaths}"
- MANPATH="${DATAPATH}/man"
- INFOPATH="${DATAPATH}/info"
- STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
- CTARGET="${CTARGET}"
- GCC_SPECS="${gcc_specs_file}"
- MULTIOSDIRS="${mosdirs}"
- 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
- return 0
- fi
-
- # setup the hardenedno* specs files and the vanilla specs file.
- if hardened_gcc_works ; then
- create_gcc_env_entry hardenednopiessp
- fi
- if hardened_gcc_works pie ; then
- create_gcc_env_entry hardenednopie
- fi
- if hardened_gcc_works ssp ; then
- create_gcc_env_entry hardenednossp
- fi
- create_gcc_env_entry vanilla
- insinto ${LIBPATH#${EPREFIX}}
- doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
- # Build system specs file which, if it exists, must be a complete set of
- # specs as it completely and unconditionally overrides the builtin specs.
- if ! tc_version_is_at_least 4.4 ; then
- $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
- cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
- doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
- fi
-}
-
-gcc_slot_java() {
- local x
-
- # Move Java headers to compiler-specific dir
- for x in "${D}${PREFIX}"/include/gc*.h "${D}${PREFIX}"/include/j*.h ; do
- [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/include/
- done
- for x in gcj gnu java javax org ; do
- if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
- dodir /${LIBPATH#${EPREFIX}}/include/${x}
- mv -f "${D}${PREFIX}"/include/${x}/* "${D}${LIBPATH}"/include/${x}/
- rm -rf "${D}${PREFIX}"/include/${x}
- fi
- done
-
- if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
- dodir /${LIBPATH#${EPREFIX}}/security
- mv -f "${D}${PREFIX}"/lib*/security/* "${D}${LIBPATH}"/security
- rm -rf "${D}${PREFIX}"/lib*/security
- fi
-
- # Move random gcj files to compiler-specific directories
- for x in libgcj.spec logging.properties ; do
- x="${D}${PREFIX}/lib/${x}"
- [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/
- done
-
- # Rename jar because it could clash with Kaffe's jar if this gcc is
- # primary compiler (aka don't have the -<version> extension)
- cd "${D}${BINPATH}"
- [[ -f jar ]] && mv -f jar gcj-jar
-}
-
-#---->> pkg_post* <<----
-
-toolchain_pkg_postinst() {
- do_gcc_config
- if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
- eselect compiler-shadow update all
- fi
-
- if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
- # gcc stopped installing .la files fixer in June 2020.
- # Cleaning can be removed in June 2022.
- rm -f "${EROOT%/}"/sbin/fix_libtool_files.sh
- rm -f "${EROOT%/}"/usr/sbin/fix_libtool_files.sh
- rm -f "${EROOT%/}"/usr/share/gcc-data/fixlafiles.awk
- fi
-}
-
-toolchain_pkg_postrm() {
- do_gcc_config
- if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
- eselect compiler-shadow clean all
- fi
-
- # clean up the cruft left behind by cross-compilers
- 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}
- fi
- return 0
- fi
-
- # gcc stopped installing .la files fixer in June 2020.
- # Cleaning can be removed in June 2022.
- rm -f "${EROOT%/}"/sbin/fix_libtool_files.sh
- rm -f "${EROOT%/}"/usr/share/gcc-data/fixlafiles.awk
-}
-
-do_gcc_config() {
- if ! should_we_gcc_config ; then
- gcc-config --use-old --force
- return 0
- fi
-
- local current_gcc_config target
-
- current_gcc_config=$(gcc-config -c ${CTARGET} 2>/dev/null)
- if [[ -n ${current_gcc_config} ]] ; then
- local current_specs use_specs
- # figure out which specs-specific config is active
- current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
- [[ -n ${current_specs} ]] && use_specs=-${current_specs}
-
- if [[ -n ${use_specs} ]] && \
- [[ ! -e ${EROOT%/}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
- then
- ewarn "The currently selected specs-specific gcc config,"
- ewarn "${current_specs}, doesn't exist anymore. This is usually"
- ewarn "due to enabling/disabling hardened or switching to a version"
- ewarn "of gcc that doesnt create multiple specs files. The default"
- ewarn "config will be used, and the previous preference forgotten."
- use_specs=""
- fi
-
- target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
- else
- # The curent target is invalid. Attempt to switch to a valid one.
- # Blindly pick the latest version. #529608
- # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
- # doing a partial grep like this.
- target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
- fi
-
- gcc-config "${target}"
-}
-
-should_we_gcc_config() {
- # if the current config is invalid, we definitely want a new one
- # Note: due to bash quirkiness, the following must not be 1 line
- local curr_config
- curr_config=$(gcc-config -c ${CTARGET} 2>&1) || return 0
-
- # if the previously selected config has the same major.minor (branch) as
- # the version we are installing, then it will probably be uninstalled
- # for being in the same SLOT, make sure we run gcc-config.
- local curr_config_ver=$(gcc-config -S ${curr_config} | awk '{print $2}')
-
- local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver})
-
- if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
- return 0
- else
- # if we're installing a genuinely different compiler version,
- # we should probably tell the user -how- to switch to the new
- # gcc version, since we're not going to do it for him/her.
- # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
- # the middle of an emerge operation (like an 'emerge -e world'
- # which could install multiple gcc versions).
- # Only warn if we're installing a pkg as we might be called from
- # the pkg_{pre,post}rm steps. #446830
- if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
- einfo "The current gcc config appears valid, so it will not be"
- einfo "automatically switched for you. If you would like to"
- einfo "switch to the newly installed gcc version, do the"
- einfo "following:"
- echo
- einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
- einfo "source /etc/profile"
- echo
- fi
- return 1
- fi
-}
-
-#---->> support and misc functions <<----
-
-# This is to make sure we don't accidentally try to enable support for a
-# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
-#
-# Also add a hook so special ebuilds (kgcc64) can control which languages
-# exactly get enabled
-gcc-lang-supported() {
- grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
- [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
- has $1 ${TOOLCHAIN_ALLOWED_LANGS}
-}
-
-_tc_use_if_iuse() {
- in_iuse $1 && use $1
-}
-
-is_ada() {
- gcc-lang-supported ada || return 1
- _tc_use_if_iuse ada
-}
-
-is_cxx() {
- gcc-lang-supported 'c++' || return 1
- _tc_use_if_iuse cxx
-}
-
-is_d() {
- gcc-lang-supported d || return 1
- _tc_use_if_iuse d
-}
-
-is_f77() {
- gcc-lang-supported f77 || return 1
- _tc_use_if_iuse fortran
-}
-
-is_f95() {
- gcc-lang-supported f95 || return 1
- _tc_use_if_iuse fortran
-}
-
-is_fortran() {
- gcc-lang-supported fortran || return 1
- _tc_use_if_iuse fortran
-}
-
-is_gcj() {
- gcc-lang-supported java || return 1
- _tc_use_if_iuse cxx && _tc_use_if_iuse gcj
-}
-
-is_go() {
- gcc-lang-supported go || return 1
- _tc_use_if_iuse cxx && _tc_use_if_iuse go
-}
-
-is_jit() {
- gcc-lang-supported jit || return 1
- # cross-compiler does not really support jit as it has
- # to generate code for a target. On target like avr
- # libgcclit.so can't link at all: bug #594572
- is_crosscompile && return 1
- _tc_use_if_iuse jit
-}
-
-is_multilib() {
- _tc_use_if_iuse multilib
-}
-
-is_objc() {
- gcc-lang-supported objc || return 1
- _tc_use_if_iuse objc
-}
-
-is_objcxx() {
- gcc-lang-supported 'obj-c++' || return 1
- _tc_use_if_iuse cxx && _tc_use_if_iuse objc++
-}
-
-# Grab a variable from the build system (taken from linux-info.eclass)
-get_make_var() {
- local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
- echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
- r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
-}
-
-XGCC() { get_make_var GCC_FOR_TARGET ; }
-
-# The gentoo piessp patches allow for 3 configurations:
-# 1) PIE+SSP by default
-# 2) PIE by default
-# 3) SSP by default
-hardened_gcc_works() {
- if [[ $1 == "pie" ]] ; then
- # $gcc_cv_ld_pie is unreliable as it simply take the output of
- # `ld --help | grep -- -pie`, that reports the option in all cases, also if
- # the loader doesn't actually load the resulting executables.
- # To avoid breakage, blacklist FreeBSD here at least
- [[ ${CTARGET} == *-freebsd* ]] && return 1
-
- want_pie || return 1
- _tc_use_if_iuse nopie && return 1
- hardened_gcc_is_stable pie
- return $?
- elif [[ $1 == "ssp" ]] ; then
- [[ -n ${SPECS_VER} ]] || return 1
- _tc_use_if_iuse nossp && return 1
- hardened_gcc_is_stable ssp
- return $?
- else
- # laziness ;)
- hardened_gcc_works pie || return 1
- hardened_gcc_works ssp || return 1
- return 0
- fi
-}
-
-hardened_gcc_is_stable() {
- local tocheck
- if [[ $1 == "pie" ]] ; then
- if [[ ${CTARGET} == *-uclibc* ]] ; then
- tocheck=${PIE_UCLIBC_STABLE}
- else
- tocheck=${PIE_GLIBC_STABLE}
- fi
- elif [[ $1 == "ssp" ]] ; then
- if [[ ${CTARGET} == *-uclibc* ]] ; then
- tocheck=${SSP_UCLIBC_STABLE}
- elif [[ ${CTARGET} == *-gnu* ]] ; then
- tocheck=${SSP_STABLE}
- fi
- else
- die "hardened_gcc_stable needs to be called with pie or ssp"
- fi
-
- has $(tc-arch) ${tocheck} && return 0
- return 1
-}
-
-want_minispecs() {
- # on gcc 6 we don't need minispecs
- if tc_version_is_at_least 6.0 ; then
- return 0
- fi
- if tc_version_is_at_least 4.3.2 && _tc_use_if_iuse hardened ; then
- if ! want_pie ; then
- ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
- elif use vanilla ; then
- ewarn "You will not get hardened features if you have the vanilla USE-flag."
- elif _tc_use_if_iuse nopie && _tc_use_if_iuse nossp ; then
- ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
- elif ! hardened_gcc_works ; then
- ewarn "Your $(tc-arch) arch is not supported."
- else
- return 0
- fi
- ewarn "Hope you know what you are doing. Hardened will not work."
- return 0
- fi
- return 1
-}
-
-want_pie() {
- ! _tc_use_if_iuse hardened && [[ -n ${PIE_VER} ]] \
- && _tc_use_if_iuse nopie && return 1
- [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
- tc_version_is_at_least 4.3.2 && return 1
- [[ -z ${PIE_VER} ]] && return 1
- _tc_use_if_iuse nopie || return 0
- return 1
-}
-
-has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
-toolchain_death_notice() {
- if [[ -e "${WORKDIR}"/build ]] ; then
- pushd "${WORKDIR}"/build >/dev/null
- (echo '' | $(tc-getCC ${CTARGET}) ${CFLAGS} -v -E - 2>&1) > gccinfo.log
- [[ -e "${T}"/build.log ]] && cp "${T}"/build.log .
- tar jcf "${WORKDIR}"/gcc-build-logs.tar.bz2 \
- gccinfo.log build.log $(find -name config.log)
- rm gccinfo.log build.log
- eerror
- eerror "Please include ${WORKDIR}/gcc-build-logs.tar.bz2 in your bug report."
- eerror
- popd >/dev/null
- fi
-}
-
-# Note [implicitly enabled flags]
-# -------------------------------
-# Usually configure-based packages handle explicit feature requests
-# like
-# ./configure --enable-foo
-# as explicit request to check for support of 'foo' and bail out at
-# configure time.
-#
-# GCC does not follow this pattern and instead overrides autodetection
-# of the feature and enables it unconditionally.
-# See bugs:
-# https://gcc.gnu.org/PR85663 (libsanitizer on mips)
-# https://bugs.gentoo.org/661252 (libvtv on powerpc64)
-#
-# Thus safer way to enable/disable the feature is to rely on implicit
-# enabled-by-default state:
-# econf $(usex foo '' --disable-foo)
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2021-11-17 11:48 Sam James
0 siblings, 0 replies; 24+ messages in thread
From: Sam James @ 2021-11-17 11:48 UTC (permalink / raw
To: gentoo-commits
commit: 93ac8864bfa76c8376f0aaaf0c1c00023fd5eb50
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 17 11:48:39 2021 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Nov 17 11:48:39 2021 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=93ac8864
toolchain.eclass: only apply patches if CTARGET is musl
Signed-off-by: Sam James <sam <AT> gentoo.org>
eclass/toolchain.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 39466996..627531f2 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -556,7 +556,7 @@ do_gcc_gentoo_patches() {
tc_apply_patches "Applying uClibc patches ..." "${WORKDIR}"/uclibc/*.patch
fi
- if [[ -n ${MUSL_VER} ]] ; then #&& [[ ${CTARGET} == *musl* ]] ; then
+ if [[ -n ${MUSL_VER} ]] && [[ ${CTARGET} == *musl* ]] ; then
if [[ ${CATEGORY} == cross-* ]] ; then
# We don't want to apply some patches when cross-compiling.
if [[ -d "${WORKDIR}"/musl/nocross ]] ; then
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2021-11-17 11:47 Sam James
0 siblings, 0 replies; 24+ messages in thread
From: Sam James @ 2021-11-17 11:47 UTC (permalink / raw
To: gentoo-commits
commit: 0ac64cdad64f51dd81e34f9d4eb279d570670a73
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 17 11:44:04 2021 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Nov 17 11:46:32 2021 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=0ac64cda
toolchain.eclass: import eclass with proposed ::gentoo changes (musl patchset)
Introduce a MUSL_VER patch variable and apply a patchset like we used to
for uclibc. This is in preparation for moving GCC from ::musl to
::gentoo.
The patchset has a nocross/ dir for patches which must
be applied only for native builds.
The patches were/are identical for each version in ::musl
which makes life easier:
```
musl/
musl/gcc-pure64.patch
musl/posix_memalign.patch
musl/nocross/
musl/nocross/gcc-6.1-musl-libssp.patch
musl/cpu_indicator.patch
```
Signed-off-by: Sam James <sam <AT> gentoo.org>
eclass/toolchain.eclass | 2391 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 2391 insertions(+)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
new file mode 100644
index 00000000..39466996
--- /dev/null
+++ b/eclass/toolchain.eclass
@@ -0,0 +1,2391 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: toolchain.eclass
+# @MAINTAINER:
+# Toolchain Ninjas <toolchain@gentoo.org>
+# @SUPPORTED_EAPIS: 5 6 7 8
+# @BLURB: Common code for sys-devel/gcc ebuilds
+
+DESCRIPTION="The GNU Compiler Collection"
+HOMEPAGE="https://gcc.gnu.org/"
+
+inherit flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
+
+tc_is_live() {
+ [[ ${PV} == *9999* ]]
+}
+
+if tc_is_live ; then
+ EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git"
+ # naming style:
+ # 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="releases/${PN}-${PV%.?.?_pre9999}"
+ EGIT_BRANCH=${EGIT_BRANCH//./_}
+ inherit git-r3
+fi
+
+FEATURES=${FEATURES/multilib-strict/}
+
+case ${EAPI} in
+ 5|6) inherit eapi7-ver eutils ;;
+ 7) inherit eutils ;;
+ 8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
+ src_compile src_test src_install pkg_postinst pkg_postrm
+
+#---->> globals <<----
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+: ${TARGET_ABI:=${ABI}}
+: ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
+: ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
+
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+
+# General purpose version check. Without a second arg matches up to minor version (x.x.x)
+tc_version_is_at_least() {
+ ver_test "${2:-${GCC_RELEASE_VER}}" -ge "$1"
+}
+
+# General purpose version range check
+# Note that it matches up to but NOT including the second version
+tc_version_is_between() {
+ tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}"
+}
+
+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})
+
+# 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
+
+# Require minimum gcc version to simplify assumptions.
+# Normally we would require gcc-6+ (based on sys-devel/gcc)
+# but we still have sys-devel/gcc-apple-4.2.1_p5666.
+tc_version_is_at_least 4.2.1 || die "${ECLASS}: ${GCC_RELEASE_VER} is too old."
+
+PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
+
+LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
+INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
+
+if is_crosscompile ; then
+ BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
+ HOSTLIBPATH=${PREFIX}/${CHOST}/${CTARGET}/lib/${GCC_CONFIG_VER}
+else
+ BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
+fi
+
+DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
+
+# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
+# We will handle /usr/include/g++-v3/ with gcc-config ...
+STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
+
+#---->> LICENSE+SLOT+IUSE logic <<----
+
+LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
+IUSE="test vanilla +nls"
+RESTRICT="!test? ( test )"
+
+tc_supports_dostrip() {
+ case ${EAPI} in
+ 5|6) return 1 ;;
+ 7|8) return 0 ;;
+ *) die "Update apply_patches() for ${EAPI}." ;;
+ esac
+}
+
+tc_supports_dostrip || RESTRICT+=" strip" # cross-compilers need controlled stripping
+
+TC_FEATURES=()
+
+tc_has_feature() {
+ has "$1" "${TC_FEATURES[@]}"
+}
+
+if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
+ IUSE+=" debug +cxx +nptl" TC_FEATURES+=(nptl)
+ [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
+ [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
+ IUSE+=" +fortran" TC_FEATURES+=(fortran)
+ IUSE+=" doc hardened multilib objc"
+ tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=(gcj)
+ IUSE+=" pgo"
+ IUSE+=" objc-gc" TC_FEATURES+=(objc-gc)
+ IUSE+=" libssp objc++"
+ IUSE+=" +openmp"
+ tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
+ tc_version_is_at_least 4.7 && IUSE+=" go"
+ # sanitizer support appeared in gcc-4.8, but <gcc-5 does not
+ # support modern glibc.
+ tc_version_is_at_least 5 && IUSE+=" +sanitize" TC_FEATURES+=(sanitize)
+ # Note:
+ # <gcc-4.8 supported graphite, it required forked ppl
+ # versions which we dropped. Since graphite was also experimental in
+ # the older versions, we don't want to bother supporting it. #448024
+ # <gcc-5 supported graphite, it required cloog
+ # <gcc-6.5 supported graphite, it required old incompatible isl
+ tc_version_is_at_least 6.5 &&
+ IUSE+=" graphite" TC_FEATURES+=(graphite)
+ tc_version_is_between 4.9 8 && IUSE+=" cilk"
+ tc_version_is_at_least 4.9 && IUSE+=" ada"
+ tc_version_is_at_least 4.9 && IUSE+=" vtv"
+ tc_version_is_at_least 5.0 && IUSE+=" jit"
+ tc_version_is_between 5.0 9 && IUSE+=" mpx"
+ tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
+ # systemtap is a gentoo-specific switch: bug #654748
+ tc_version_is_at_least 8.0 &&
+ IUSE+=" systemtap" TC_FEATURES+=(systemtap)
+ tc_version_is_at_least 9.0 && IUSE+=" d"
+ tc_version_is_at_least 9.1 && IUSE+=" lto"
+ tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=(zstd)
+ tc_version_is_at_least 11 && IUSE+=" valgrind" TC_FEATURES+=(valgrind)
+ tc_version_is_at_least 11 && IUSE+=" custom-cflags"
+fi
+
+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 <<----
+
+RDEPEND="sys-libs/zlib
+ virtual/libiconv
+ nls? ( virtual/libintl )
+"
+
+GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0= >=dev-libs/mpfr-2.4.2:0="
+if tc_version_is_at_least 4.3 ; then
+ RDEPEND+=" ${GMP_MPFR_DEPS}"
+elif tc_has_feature fortran ; then
+ RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
+fi
+
+tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
+
+if tc_has_feature objc-gc ; then
+ if tc_version_is_at_least 7 ; then
+ RDEPEND+=" objc-gc? ( >=dev-libs/boehm-gc-7.4.2 )"
+ fi
+fi
+
+if tc_has_feature graphite ; then
+ RDEPEND+=" graphite? ( >=dev-libs/isl-0.14:0= )"
+fi
+
+BDEPEND="
+ >=sys-devel/bison-1.875
+ >=sys-devel/flex-2.5.4
+ nls? ( sys-devel/gettext )
+ test? (
+ >=dev-util/dejagnu-1.4.4
+ >=sys-devel/autogen-5.5.4
+ )"
+DEPEND="${RDEPEND}"
+
+if tc_has_feature gcj ; then
+ DEPEND+="
+ gcj? (
+ awt? (
+ x11-base/xorg-proto
+ x11-libs/libXt
+ x11-libs/libX11
+ x11-libs/libXtst
+ =x11-libs/gtk+-2*
+ x11-libs/pango
+ virtual/pkgconfig
+ )
+ >=media-libs/libart_lgpl-2.1
+ app-arch/zip
+ app-arch/unzip
+ )
+ "
+fi
+
+if tc_has_feature sanitize ; then
+ # libsanitizer relies on 'crypt.h' to be present
+ # on target. glibc user to provide it unconditionally.
+ # Nowadays it's a standalone library: #802648
+ DEPEND+=" sanitize? ( virtual/libcrypt )"
+fi
+
+if tc_has_feature systemtap ; then
+ # gcc needs sys/sdt.h headers on target
+ DEPEND+=" systemtap? ( dev-util/systemtap )"
+fi
+
+if tc_has_feature zstd ; then
+ DEPEND+=" zstd? ( app-arch/zstd )"
+fi
+
+if tc_has_feature valgrind; then
+ BDEPEND+=" valgrind? ( dev-util/valgrind )"
+fi
+
+case ${EAPI} in
+ 5|6) DEPEND+=" ${BDEPEND}" ;;
+esac
+
+PDEPEND=">=sys-devel/gcc-config-2.3"
+
+#---->> S + SRC_URI essentials <<----
+
+# Set the source directory depending on whether we're using
+# a live git tree, snapshot, or release tarball.
+S=$(
+ if tc_is_live ; then
+ echo ${EGIT_CHECKOUT_DIR}
+ elif [[ -n ${SNAPSHOT} ]] ; then
+ echo ${WORKDIR}/gcc-${SNAPSHOT}
+ else
+ echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
+ fi
+)
+
+gentoo_urls() {
+ local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
+ HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI
+ HTTP~tamiko/distfiles/URI HTTP~sam/distfiles/URI
+ HTTP~sam/distfiles/sys-devel/gcc/URI HTTP~slyfox/distfiles/URI"
+ devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
+ echo mirror://gentoo/$1 ${devspace//URI/$1}
+}
+
+# This function handles the basics of setting the SRC_URI for a gcc ebuild.
+# To use, set SRC_URI with:
+#
+# SRC_URI="$(get_gcc_src_uri)"
+#
+# 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.
+#
+# PATCH_VER
+# PATCH_GCC_VER
+# This should be set to the version of the gentoo patch tarball.
+# The resulting filename of this tarball will be:
+# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+#
+# PIE_VER
+# PIE_GCC_VER
+# These variables control patching in various updates for the logic
+# controlling Position Independant Executables. PIE_VER is expected
+# to be the version of this patch, and PIE_GCC_VER the gcc version of
+# the patch:
+# An example:
+# PIE_VER="8.7.6.5"
+# PIE_GCC_VER="3.4.0"
+# The resulting filename of this tarball will be:
+# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
+#
+# SPECS_VER
+# SPECS_GCC_VER
+# This is for the minispecs files included in the hardened gcc-4.x
+# The specs files for hardenedno*, vanilla and for building the "specs" file.
+# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
+# the gcc version of the patch.
+# An example:
+# SPECS_VER="8.7.6.5"
+# SPECS_GCC_VER="3.4.0"
+# The resulting filename of this tarball will be:
+# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
+#
+# CYGWINPORTS_GITREV
+# If set, this variable signals that we should apply additional patches
+# maintained by upstream Cygwin developers at github/cygwinports/gcc,
+# using the specified git commit id there. The list of patches to
+# apply is extracted from gcc.cygport, maintained there as well.
+# This is done for compilers running on Cygwin, not for cross compilers
+# with a Cygwin target.
+get_gcc_src_uri() {
+ export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
+ export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
+ export MUSL_GCC_VER=${MUSL_GCC_VER:-${PATCH_GCC_VER}}
+ export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
+ export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
+ export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
+
+ # Set where to download gcc itself depending on whether we're using a
+ # 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
+ 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
+ fi
+
+ [[ -n ${UCLIBC_VER} ]] && \
+ GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
+ [[ -n ${PATCH_VER} ]] && \
+ GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
+ [[ -n ${MUSL_VER} ]] && \
+ GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.bz2)"
+
+ [[ -n ${PIE_VER} ]] && \
+ PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
+ GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
+
+ # gcc minispec for the hardened gcc 4 compiler
+ [[ -n ${SPECS_VER} ]] && \
+ GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
+
+ if tc_has_feature gcj ; then
+ if tc_version_is_at_least 4.5 ; then
+ GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
+ elif tc_version_is_at_least 4.3 ; then
+ GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
+ fi
+ fi
+
+ # Cygwin patches from https://github.com/cygwinports/gcc
+ [[ -n ${CYGWINPORTS_GITREV} ]] && \
+ GCC_SRC_URI+=" elibc_Cygwin? ( https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.tar.gz
+ -> gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz )"
+
+ echo "${GCC_SRC_URI}"
+}
+
+SRC_URI=$(get_gcc_src_uri)
+
+#---->> pkg_pretend <<----
+
+toolchain_pkg_pretend() {
+ if ! _tc_use_if_iuse cxx ; then
+ _tc_use_if_iuse go && \
+ ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
+ _tc_use_if_iuse objc++ && \
+ ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
+ _tc_use_if_iuse gcj && \
+ ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
+ fi
+
+ want_minispecs
+}
+
+#---->> pkg_setup <<----
+
+toolchain_pkg_setup() {
+ # we dont want to use the installed compiler's specs to build gcc
+ unset GCC_SPECS
+ unset LANGUAGES #265283
+}
+
+#---->> src_unpack <<----
+
+toolchain_src_unpack() {
+ if tc_is_live ; then
+ git-r3_src_unpack
+ fi
+
+ default_src_unpack
+}
+
+#---->> src_prepare <<----
+
+# 'epatch' is not available in EAPI=7. Abstract away patchset application
+# until we eventually get all gcc ebuilds on EAPI=7 or later.
+tc_apply_patches() {
+ [[ ${#@} -lt 2 ]] && die "usage: tc_apply_patches <message> <patches...>"
+
+ einfo "$1"; shift
+
+ case ${EAPI} 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|8) eapply "$@" ;;
+ *) die "Update apply_patches() for ${EAPI}." ;;
+ esac
+}
+
+toolchain_src_prepare() {
+ export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
+ cd "${S}"
+
+ do_gcc_gentoo_patches
+ do_gcc_PIE_patches
+ do_gcc_CYGWINPORTS_patches
+
+ if tc_is_live ; then
+ BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, commit ${EGIT_VERSION}"
+ fi
+
+ case ${EAPI} in
+ 5) epatch_user;;
+ 6|7|8) eapply_user ;;
+ *) die "Update toolchain_src_prepare() for ${EAPI}." ;;
+ esac
+
+ if ( tc_version_is_at_least 4.8.2 || _tc_use_if_iuse hardened ) \
+ && ! use vanilla ; then
+ make_gcc_hard
+ fi
+
+ # make sure the pkg config files install into multilib dirs.
+ # since we configure with just one --libdir, we can't use that
+ # (as gcc itself takes care of building multilibs). #435728
+ find "${S}" -name Makefile.in \
+ -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
+
+ setup_multilib_osdirnames
+ gcc_version_patch
+
+ 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
+
+ # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
+ if tc_version_is_at_least 4.3 && _tc_use_if_iuse gcj ; then
+ if tc_version_is_at_least 4.5 ; then
+ einfo "Copying ecj-4.5.jar"
+ cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
+ else
+ einfo "Copying ecj-4.3.jar"
+ cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
+ fi
+ fi
+
+ # Prevent libffi from being installed
+ if tc_version_is_between 3.0 4.8 ; then
+ sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in || die
+ sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in || die
+ fi
+
+ # Fixup libtool to correctly generate .la files with portage
+ elibtoolize --portage --shallow --no-uclibc
+
+ gnuconfig_update
+
+ # update configure files
+ local f
+ einfo "Fixing misc issues in configure files"
+ for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
+ ebegin " Updating ${f/${S}\/} [LANG]"
+ patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
+ || eerror "Please file a bug about this"
+ eend $?
+ done
+ sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
+
+ # Prevent new texinfo from breaking old versions (see #198182, #464008)
+ tc_apply_patches "Remove texinfo (bug #198182, bug #464008)" "${FILESDIR}"/gcc-configure-texinfo.patch
+
+ # >=gcc-4
+ if [[ -x contrib/gcc_update ]] ; then
+ einfo "Touching generated files"
+ ./contrib/gcc_update --touch | \
+ while read f ; do
+ einfo " ${f%%...}"
+ done
+ fi
+}
+
+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
+
+ if [[ -n ${MUSL_VER} ]] ; then #&& [[ ${CTARGET} == *musl* ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ # We don't want to apply some patches when cross-compiling.
+ if [[ -d "${WORKDIR}"/musl/nocross ]] ; then
+ rm -fv "${WORKDIR}"/musl/nocross/*.patch || die
+ fi
+ fi
+
+ tc_apply_patches "Applying musl patches ..." "${WORKDIR}"/musl/{,nocross/}*.patch
+ fi
+ fi
+}
+
+do_gcc_PIE_patches() {
+ want_pie || return 0
+ use vanilla && return 0
+
+ tc_apply_patches "Applying pie patches ..." "${WORKDIR}"/piepatch/*.patch
+
+ BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
+}
+
+do_gcc_CYGWINPORTS_patches() {
+ [[ -n ${CYGWINPORTS_GITREV} ]] || return 0
+ use elibc_Cygwin || return 0
+
+ local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
+ # readarray -t is available since bash-4.4 only, #690686
+ 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
+ if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
+ einfo "Disabling PIE in stage1 (only) ..."
+ sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
+ fi
+
+ # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
+ if tc_version_is_at_least 6.0 ; then
+ if _tc_use_if_iuse pie ; then
+ einfo "Updating gcc to use automatic PIE building ..."
+ fi
+ if _tc_use_if_iuse ssp ; then
+ einfo "Updating gcc to use automatic SSP building ..."
+ fi
+ if _tc_use_if_iuse hardened ; then
+ # Will add some hardened options as default, like:
+ # -fstack-clash-protection
+ # -z now
+ # see *_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}
+ fi
+ else
+ if _tc_use_if_iuse hardened ; then
+ # rebrand to make bug reports easier
+ BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
+ if hardened_gcc_works ; then
+ einfo "Updating gcc to use automatic PIE + SSP building ..."
+ gcc_hard_flags+=" -DEFAULT_PIE_SSP"
+ elif hardened_gcc_works pie ; then
+ einfo "Updating gcc to use automatic PIE building ..."
+ ewarn "SSP has not been enabled by default"
+ gcc_hard_flags+=" -DEFAULT_PIE"
+ elif hardened_gcc_works ssp ; then
+ einfo "Updating gcc to use automatic SSP building ..."
+ ewarn "PIE has not been enabled by default"
+ gcc_hard_flags+=" -DEFAULT_SSP"
+ else
+ # do nothing if hardened isn't supported, but don't die either
+ ewarn "hardened is not supported for this arch in this gcc version"
+ return 0
+ fi
+ else
+ if hardened_gcc_works ssp ; then
+ einfo "Updating gcc to use automatic SSP building ..."
+ gcc_hard_flags+=" -DEFAULT_SSP"
+ fi
+ fi
+ fi
+
+ # we want to be able to control the pie patch logic via something other
+ # than ALL_CFLAGS...
+ sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
+ -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
+ -i "${S}"/gcc/Makefile.in
+ # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
+ if tc_version_is_at_least 4.7 ; then
+ sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
+ -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
+ -i "${S}"/gcc/Makefile.in
+ fi
+
+ sed -i \
+ -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
+ "${S}"/gcc/Makefile.in || die
+
+}
+
+# This is a historical wart. The original Gentoo/amd64 port used:
+# lib32 - 32bit binaries (x86)
+# lib64 - 64bit binaries (x86_64)
+# lib - "native" binaries (a symlink to lib64)
+# Most other distros use the logic (including mainline gcc):
+# lib - 32bit binaries (x86)
+# lib64 - 64bit binaries (x86_64)
+# Over time, Gentoo is migrating to the latter form.
+#
+# Unfortunately, due to distros picking the lib32 behavior, newer gcc
+# versions will dynamically detect whether to use lib or lib32 for its
+# 32bit multilib. So, to keep the automagic from getting things wrong
+# while people are transitioning from the old style to the new style,
+# we always set the MULTILIB_OSDIRNAMES var for relevant targets.
+setup_multilib_osdirnames() {
+ is_multilib || return 0
+
+ local config
+ local libdirs="../lib64 ../lib32"
+
+ # this only makes sense for some Linux targets
+ case ${CTARGET} in
+ x86_64*-linux*) config="i386" ;;
+ powerpc64*-linux*) config="rs6000" ;;
+ sparc64*-linux*) config="sparc" ;;
+ s390x*-linux*) config="s390" ;;
+ *) return 0 ;;
+ esac
+ config+="/t-linux64"
+
+ local sed_args=()
+ if tc_version_is_at_least 4.6 ; then
+ sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
+ fi
+ if [[ ${SYMLINK_LIB} == "yes" ]] ; then
+ einfo "updating multilib directories to be: ${libdirs}"
+ if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
+ sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
+ else
+ sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
+ fi
+ else
+ einfo "using upstream multilib; disabling lib32 autodetection"
+ sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
+ fi
+ sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
+}
+
+gcc_version_patch() {
+ # gcc-4.3+ has configure flags (whoo!)
+ tc_version_is_at_least 4.3 && return 0
+
+ local version_string=${GCC_RELEASE_VER}
+
+ einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
+
+ local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
+ if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
+ gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
+ else
+ version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
+ gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
+ fi
+ sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
+}
+
+#---->> src_configure <<----
+
+toolchain_src_configure() {
+ downgrade_arch_flags
+ gcc_do_filter_flags
+
+ einfo "CFLAGS=\"${CFLAGS}\""
+ einfo "CXXFLAGS=\"${CXXFLAGS}\""
+ einfo "LDFLAGS=\"${LDFLAGS}\""
+
+ # Force internal zip based jar script to avoid random
+ # issues with 3rd party jar implementations. #384291
+ export JAR=no
+
+ # For hardened gcc 4.3 piepatchset to build the hardened specs
+ # file (build.specs) to use when building gcc.
+ if ! tc_version_is_at_least 4.4 && want_minispecs ; then
+ setup_minispecs_gcc_build_specs
+ fi
+
+ local confgcc=( --host=${CHOST} )
+
+ if is_crosscompile || tc-is-cross-compiler ; then
+ # Straight from the GCC install doc:
+ # "GCC has code to correctly determine the correct value for target
+ # for nearly all native systems. Therefore, we highly recommend you
+ # not provide a configure target when configuring a native compiler."
+ confgcc+=( --target=${CTARGET} )
+ fi
+ [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
+
+ confgcc+=(
+ --prefix="${PREFIX}"
+ --bindir="${BINPATH}"
+ --includedir="${INCLUDEPATH}"
+ --datadir="${DATAPATH}"
+ --mandir="${DATAPATH}/man"
+ --infodir="${DATAPATH}/info"
+ --with-gxx-include-dir="${STDCXX_INCDIR}"
+ )
+
+ # Stick the python scripts in their own slotted directory (bug #279252)
+ #
+ # --with-python-dir=DIR
+ # Specifies where to install the Python modules used for aot-compile. DIR
+ # should not include the prefix used in installation. For example, if the
+ # Python modules are to be installed in /usr/lib/python2.5/site-packages,
+ # then --with-python-dir=/lib/python2.5/site-packages should be passed.
+ #
+ # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
+ if tc_version_is_at_least 4.4 ; then
+ confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
+ fi
+
+ ### language options
+
+ local GCC_LANG="c"
+ is_cxx && GCC_LANG+=",c++"
+ is_d && GCC_LANG+=",d"
+ is_gcj && GCC_LANG+=",java"
+ is_go && GCC_LANG+=",go"
+ is_jit && GCC_LANG+=",jit"
+ if is_objc || is_objcxx ; then
+ GCC_LANG+=",objc"
+ use objc-gc && confgcc+=( --enable-objc-gc )
+ is_objcxx && GCC_LANG+=",obj-c++"
+ fi
+
+ # fortran support just got sillier! the lang value can be f77 for
+ # fortran77, f95 for fortran95, or just plain old fortran for the
+ # currently supported standard depending on gcc version.
+ is_fortran && GCC_LANG+=",fortran"
+ is_f77 && GCC_LANG+=",f77"
+ is_f95 && GCC_LANG+=",f95"
+
+ is_ada && GCC_LANG+=",ada"
+
+ confgcc+=( --enable-languages=${GCC_LANG} )
+
+ ### general options
+
+ confgcc+=(
+ --enable-obsolete
+ --enable-secureplt
+ --disable-werror
+ --with-system-zlib
+ )
+
+ if use nls ; then
+ confgcc+=( --enable-nls --without-included-gettext )
+ else
+ confgcc+=( --disable-nls )
+ fi
+
+ confgcc+=( --disable-libunwind-exceptions )
+
+ # Use the default ("release") checking because upstream usually neglects
+ # to test "disabled" so it has a history of breaking. bug #317217
+ if in_iuse debug ; then
+ # The "release" keyword is new to 4.0. bug #551636
+ local off=$(tc_version_is_at_least 4.0 && echo release || echo no)
+ confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes ${off})}" )
+ fi
+
+ # Branding
+ tc_version_is_at_least 4.3 && confgcc+=(
+ --with-bugurl=https://bugs.gentoo.org/
+ --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
+ )
+
+ # If we want hardened support with the newer piepatchset for >=gcc 4.4
+ if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then
+ confgcc+=( $(use_enable hardened esp) )
+ fi
+
+ # allow gcc to search for clock funcs in the main C lib.
+ # if it can't find them, then tough cookies -- we aren't
+ # going to link in -lrt to all C++ apps. bug #411681
+ if tc_version_is_at_least 4.4 && is_cxx ; then
+ confgcc+=( --enable-libstdcxx-time )
+ fi
+
+ # Build compiler itself using LTO
+ if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then
+ confgcc+=( --with-build-config=bootstrap-lto )
+ fi
+
+ # Support to disable pch when building libstdcxx
+ if tc_version_is_at_least 6.0 && ! _tc_use_if_iuse pch ; then
+ confgcc+=( --disable-libstdcxx-pch )
+ fi
+
+ # The jit language requires this.
+ is_jit && confgcc+=( --enable-host-shared )
+
+ # build-id was disabled for file collisions: bug #526144
+ #
+ # # Turn on the -Wl,--build-id flag by default for ELF targets. bug #525942
+ # # This helps with locating debug files.
+ # case ${CTARGET} in
+ # *-linux-*|*-elf|*-eabi)
+ # tc_version_is_at_least 4.5 && confgcc+=(
+ # --enable-linker-build-id
+ # )
+ # ;;
+ # esac
+
+ # newer gcc versions like to bootstrap themselves with C++,
+ # so we need to manually disable it ourselves
+ if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
+ confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
+ fi
+
+ ### Cross-compiler options
+ if is_crosscompile ; then
+ # Enable build warnings by default with cross-compilers when system
+ # paths are included (e.g. via -I flags).
+ confgcc+=( --enable-poison-system-directories )
+
+ # When building a stage1 cross-compiler (just C compiler), we have to
+ # disable a bunch of features or gcc goes boom
+ local needed_libc=""
+ case ${CTARGET} in
+ *-linux) needed_libc=error-unknown-libc;;
+ *-dietlibc) needed_libc=dietlibc;;
+ *-elf|*-eabi)
+ needed_libc=newlib
+ # Bare-metal targets don't have access to clock_gettime()
+ # arm-none-eabi example: bug #589672
+ # But we explicitly do --enable-libstdcxx-time above.
+ # Undoing it here.
+ confgcc+=( --disable-libstdcxx-time )
+ ;;
+ *-freebsd*) needed_libc=freebsd-lib;;
+ *-gnu*) needed_libc=glibc;;
+ *-klibc) needed_libc=klibc;;
+ *-musl*) needed_libc=musl;;
+ *-uclibc*)
+ # Enable shared library support only on targets
+ # that support it: bug #291870
+ if ! echo '#include <features.h>' | \
+ $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
+ grep -q __HAVE_SHARED__
+ then
+ confgcc+=( --disable-shared )
+ fi
+ needed_libc=uclibc-ng
+ ;;
+ *-cygwin) needed_libc=cygwin;;
+ x86_64-*-mingw*|\
+ *-w64-mingw*) needed_libc=mingw64-runtime;;
+ avr) confgcc+=( --enable-shared --disable-threads );;
+ esac
+ if [[ -n ${needed_libc} ]] ; then
+ local confgcc_no_libc=( --disable-shared )
+ # requires libc: bug #734820
+ tc_version_is_at_least 4.6 && confgcc_no_libc+=( --disable-libquadmath )
+ # requires libc
+ tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
+ if ! has_version ${CATEGORY}/${needed_libc} ; then
+ confgcc+=(
+ "${confgcc_no_libc[@]}"
+ --disable-threads
+ --without-headers
+ )
+ if [[ $needed_libc == glibc ]]; then
+ # By default gcc looks at glibc's headers
+ # to detect long double support. This does
+ # not work for --disable-headers mode.
+ # Any >=glibc-2.4 is good enough for float128.
+ # The option appeared in gcc-4.2.
+ confgcc+=( --with-long-double-128 )
+ fi
+ elif has_version "${CATEGORY}/${needed_libc}[headers-only(-)]" ; then
+ confgcc+=(
+ "${confgcc_no_libc[@]}"
+ --with-sysroot="${PREFIX}"/${CTARGET}
+ )
+ else
+ confgcc+=( --with-sysroot="${PREFIX}"/${CTARGET} )
+ fi
+ fi
+
+ confgcc+=( --disable-bootstrap )
+ else
+ if tc-is-static-only ; then
+ confgcc+=( --disable-shared )
+ else
+ confgcc+=( --enable-shared )
+ fi
+ case ${CHOST} in
+ mingw*|*-mingw*)
+ confgcc+=( --enable-threads=win32 ) ;;
+ *)
+ confgcc+=( --enable-threads=posix ) ;;
+ esac
+ fi
+
+ # __cxa_atexit is "essential for fully standards-compliant handling of
+ # destructors", but apparently requires glibc.
+ case ${CTARGET} in
+ *-uclibc*)
+ if tc_has_feature nptl ; then
+ confgcc+=(
+ --disable-__cxa_atexit
+ $(use_enable nptl tls)
+ )
+ fi
+ ;;
+ *-elf|*-eabi)
+ confgcc+=( --with-newlib )
+ ;;
+ *-musl*)
+ confgcc+=( --enable-__cxa_atexit )
+ ;;
+ *-gnu*)
+ confgcc+=(
+ --enable-__cxa_atexit
+ --enable-clocale=gnu
+ )
+ ;;
+ *-freebsd*)
+ confgcc+=( --enable-__cxa_atexit )
+ ;;
+ *-solaris*)
+ confgcc+=( --enable-__cxa_atexit )
+ ;;
+ esac
+
+ ### arch options
+
+ gcc-multilib-configure
+
+ # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
+ # significantly increase compile time by several hours. This will allow
+ # users to control this feature in the event they need the support.
+ tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
+
+ case $(tc-is-softfloat) in
+ yes) confgcc+=( --with-float=soft ) ;;
+ softfp) confgcc+=( --with-float=softfp ) ;;
+ *)
+ # If they've explicitly opt-ed in, do hardfloat,
+ # otherwise let the gcc default kick in.
+ case ${CTARGET//_/-} in
+ *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
+ esac
+ esac
+
+ local with_abi_map=()
+ case $(tc-arch) in
+ arm) #264534 #414395
+ local a arm_arch=${CTARGET%%-*}
+ # Remove trailing endian variations first: eb el be bl b l
+ for a in e{b,l} {b,l}e b l ; do
+ if [[ ${arm_arch} == *${a} ]] ; then
+ arm_arch=${arm_arch%${a}}
+ break
+ fi
+ done
+ # Convert armv7{a,r,m} to armv7-{a,r,m}
+ [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
+ # See if this is a valid --with-arch flag
+ if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
+ . "${srcdir}"/config.gcc) &>/dev/null
+ then
+ confgcc+=( --with-arch=${arm_arch} )
+ fi
+
+ # Make default mode thumb for microcontroller classes #418209
+ [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
+
+ # Enable hardvfp
+ if [[ $(tc-is-softfloat) == "no" ]] && \
+ [[ ${CTARGET} == armv[67]* ]] && \
+ tc_version_is_at_least 4.5
+ then
+ # Follow the new arm hardfp distro standard by default
+ confgcc+=( --with-float=hard )
+ case ${CTARGET} in
+ armv6*) confgcc+=( --with-fpu=vfp ) ;;
+ armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
+ esac
+ fi
+ ;;
+ mips)
+ # Add --with-abi flags to set default ABI
+ confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
+ ;;
+ amd64)
+ # drop the older/ABI checks once this get's merged into some
+ # version of gcc upstream
+ if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
+ confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
+ fi
+ ;;
+ x86)
+ # Default arch for x86 is normally i386, lets give it a bump
+ # since glibc will do so based on CTARGET anyways
+ confgcc+=( --with-arch=${CTARGET%%-*} )
+ ;;
+ hppa)
+ # Enable sjlj exceptions for backward compatibility on hppa
+ [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
+ ;;
+ ppc)
+ # Set up defaults based on current CFLAGS
+ is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
+ [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
+ ;;
+ ppc64)
+ # On ppc64 big endian target gcc assumes elfv1 by default,
+ # and elfv2 on little endian
+ # but musl does not support elfv1 at all on any endian ppc64
+ # see https://git.musl-libc.org/cgit/musl/tree/INSTALL
+ # https://bugs.gentoo.org/704784
+ # https://gcc.gnu.org/PR93157
+ [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
+ ;;
+ riscv)
+ # Add --with-abi flags to set default ABI
+ confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
+ ;;
+ esac
+
+ # if the target can do biarch (-m32/-m64), enable it. overhead should
+ # be small, and should simplify building of 64bit kernels in a 32bit
+ # userland by not needing sys-devel/kgcc64. #349405
+ case $(tc-arch) in
+ ppc|ppc64) confgcc+=( --enable-targets=all ) ;;
+ sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
+ amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
+ esac
+
+ # On Darwin we need libdir to be set in order to get correct install names
+ # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
+ # non-Darwin we screw up the behaviour this eclass relies on. We in
+ # particular need this over --libdir for bug #255315.
+ [[ ${CTARGET} == *-darwin* ]] && \
+ confgcc+=( --enable-version-specific-runtime-libs )
+
+ ### library options
+
+ if tc_version_is_between 3.0 7.0 ; then
+ if is_gcj ; then
+ confgcc+=( --disable-gjdoc )
+ use awt && confgcc+=( --enable-java-awt=gtk )
+ else
+ confgcc+=( --disable-libgcj )
+ fi
+ fi
+
+ if in_iuse openmp ; then
+ # Make sure target has pthreads support. #326757 #335883
+ # There shouldn't be a chicken & egg problem here as openmp won't
+ # build without a C library, and you can't build that w/out
+ # already having a compiler ...
+ if ! is_crosscompile || \
+ $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
+ then
+ confgcc+=( $(use_enable openmp libgomp) )
+ else
+ # Force disable as the configure script can be dumb #359855
+ confgcc+=( --disable-libgomp )
+ fi
+ else
+ # For gcc variants where we don't want openmp (e.g. kgcc)
+ confgcc+=( --disable-libgomp )
+ fi
+
+ if _tc_use_if_iuse libssp ; then
+ confgcc+=( --enable-libssp )
+ else
+ if hardened_gcc_is_stable ssp; then
+ export gcc_cv_libc_provides_ssp=yes
+ fi
+ if _tc_use_if_iuse ssp; then
+ # On some targets USE="ssp -libssp" is an invalid
+ # configuration as target libc does not provide
+ # stack_chk_* functions. Do not disable libssp there.
+ case ${CTARGET} in
+ mingw*|*-mingw*) ewarn "Not disabling libssp" ;;
+ *) confgcc+=( --disable-libssp ) ;;
+ esac
+ else
+ confgcc+=( --disable-libssp )
+ fi
+ fi
+
+ if in_iuse ada ; then
+ confgcc+=( --disable-libada )
+ fi
+
+ if in_iuse cilk ; then
+ confgcc+=( $(use_enable cilk libcilkrts) )
+ fi
+
+ if in_iuse mpx ; then
+ confgcc+=( $(use_enable mpx libmpx) )
+ fi
+
+ if in_iuse systemtap ; then
+ confgcc+=( $(use_enable systemtap) )
+ fi
+
+ if in_iuse valgrind ; then
+ confgcc+=( $(use_enable valgrind valgrind-annotations) )
+ fi
+
+ if in_iuse vtv ; then
+ confgcc+=(
+ $(use_enable vtv vtable-verify)
+ # See Note [implicitly enabled flags]
+ $(usex vtv '' --disable-libvtv)
+ )
+ fi
+
+ if in_iuse zstd ; then
+ confgcc+=( $(use_with zstd) )
+ fi
+
+ if tc_version_is_at_least 4.6 ; then
+ confgcc+=( --enable-lto )
+ elif tc_version_is_at_least 4.5 ; then
+ confgcc+=( --disable-lto )
+ fi
+
+ # graphite was added in 4.4 but we only support it in 6.5+ due to external
+ # library issues. #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 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; 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
+ confgcc+=( $(use_enable pie default-pie) )
+ fi
+
+ if tc_version_is_at_least 6.0 && in_iuse ssp ; then
+ confgcc+=(
+ # This defaults to -fstack-protector-strong.
+ $(use_enable ssp default-ssp)
+ )
+ fi
+
+ # Disable gcc info regeneration -- it ships with generated info pages
+ # already. Our custom version/urls/etc... trigger it. #464008
+ export gcc_cv_prog_makeinfo_modern=no
+
+ # Do not let the X detection get in our way. We know things can be found
+ # via system paths, so no need to hardcode things that'll break multilib.
+ # Older gcc versions will detect ac_x_libraries=/usr/lib64 which ends up
+ # killing the 32bit builds which want /usr/lib.
+ export ac_cv_have_x='have_x=yes ac_x_includes= ac_x_libraries='
+
+ confgcc+=( "$@" ${EXTRA_ECONF} )
+
+ # Nothing wrong with a good dose of verbosity
+ echo
+ einfo "PREFIX: ${PREFIX}"
+ einfo "BINPATH: ${BINPATH}"
+ einfo "LIBPATH: ${LIBPATH}"
+ einfo "DATAPATH: ${DATAPATH}"
+ einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
+ echo
+ einfo "Languages: ${GCC_LANG}"
+ echo
+ einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}"
+ echo
+
+ # Build in a separate build tree
+ mkdir -p "${WORKDIR}"/build
+ pushd "${WORKDIR}"/build > /dev/null
+
+ # and now to do the actual configuration
+ addwrite /dev/zero
+ echo "${S}"/configure "${confgcc[@]}"
+ # Older gcc versions did not detect bash and re-exec itself, so force the
+ # use of bash. Newer ones will auto-detect, but this is not harmful.
+ CONFIG_SHELL="${EPREFIX}/bin/bash" \
+ bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
+
+ # return to whatever directory we were in before
+ popd > /dev/null
+}
+
+# Replace -m flags unsupported by the version being built with the best
+# available equivalent
+downgrade_arch_flags() {
+ local arch bver i isa myarch mytune rep ver
+
+ bver=${1:-${GCC_BRANCH_VER}}
+ # 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)
+ mytune=$(get-flag mtune)
+
+ # Handle special -mtune flags
+ [[ ${mytune} == intel ]] && ! tc_version_is_at_least 4.9 ${bver} && replace-cpu-flags intel generic
+ [[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
+
+ # "added" "arch" "replacement"
+ local archlist=(
+ 10 znver3 znver2
+ 9 znver2 znver1
+ 4.9 bdver4 bdver3
+ 4.9 bonnell atom
+ 4.9 broadwell core-avx2
+ 4.9 haswell core-avx2
+ 4.9 ivybridge core-avx-i
+ 4.9 nehalem corei7
+ 4.9 sandybridge corei7-avx
+ 4.9 silvermont corei7
+ 4.9 westmere corei7
+ 4.8 bdver3 bdver2
+ 4.8 btver2 btver1
+ 4.7 bdver2 bdver1
+ 4.7 core-avx2 core-avx-i
+ 4.6 bdver1 amdfam10
+ 4.6 btver1 amdfam10
+ 4.6 core-avx-i core2
+ 4.6 corei7 core2
+ 4.6 corei7-avx core2
+ 4.5 atom core2
+ 4.3 amdfam10 k8
+ 4.3 athlon64-sse3 k8
+ 4.3 barcelona k8
+ 4.3 core2 nocona
+ 4.3 geode k6-2 # gcc.gnu.org/PR41989#c22
+ 4.3 k8-sse3 k8
+ 4.3 opteron-sse3 k8
+ )
+
+ for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do
+ myarch=$(get-flag march)
+ mytune=$(get-flag mtune)
+
+ ver=${archlist[i]}
+ arch=${archlist[i + 1]}
+ rep=${archlist[i + 2]}
+
+ [[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue
+
+ 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
+ else
+ break
+ fi
+ done
+
+ # we only check -mno* here since -m* get removed by strip-flags later on
+ local isalist=(
+ 4.9 -mno-sha
+ 4.9 -mno-avx512pf
+ 4.9 -mno-avx512f
+ 4.9 -mno-avx512er
+ 4.9 -mno-avx512cd
+ 4.8 -mno-xsaveopt
+ 4.8 -mno-xsave
+ 4.8 -mno-rtm
+ 4.8 -mno-fxsr
+ 4.7 -mno-lzcnt
+ 4.7 -mno-bmi2
+ 4.7 -mno-avx2
+ 4.6 -mno-tbm
+ 4.6 -mno-rdrnd
+ 4.6 -mno-fsgsbase
+ 4.6 -mno-f16c
+ 4.6 -mno-bmi
+ 4.5 -mno-xop
+ 4.5 -mno-movbe
+ 4.5 -mno-lwp
+ 4.5 -mno-fma4
+ 4.4 -mno-pclmul
+ 4.4 -mno-fma
+ 4.4 -mno-avx
+ 4.4 -mno-aes
+ 4.3 -mno-ssse3
+ 4.3 -mno-sse4a
+ 4.3 -mno-sse4
+ 4.3 -mno-sse4.2
+ 4.3 -mno-sse4.1
+ 4.3 -mno-popcnt
+ 4.3 -mno-abm
+ )
+
+ for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do
+ ver=${isalist[i]}
+ isa=${isalist[i + 1]}
+ tc_version_is_at_least ${ver} ${bver} || filter-flags ${isa} ${isa/-m/-mno-}
+ done
+}
+
+gcc_do_filter_flags() {
+ # Allow users to explicitly avoid flag sanitization via
+ # USE=custom-cflags.
+ if ! _tc_use_if_iuse custom-cflags; then
+ # Over-zealous CFLAGS can often cause problems. What may work for one
+ # person may not work for another. To avoid a large influx of bugs
+ # relating to failed builds, we strip most CFLAGS out to ensure as few
+ # problems as possible.
+ strip-flags
+ # Lock gcc at -O2; we want to be conservative here.
+ filter-flags '-O?'
+ append-flags -O2
+ fi
+
+ # dont want to funk ourselves
+ filter-flags '-mabi*' -m31 -m32 -m64
+
+ filter-flags -frecord-gcc-switches # 490738
+ filter-flags -mno-rtm -mno-htm # 506202
+
+ if tc_version_is_between 6 8 ; then
+ # -mstackrealign triggers crashes in exception throwing
+ # at least on ada: bug #688580
+ # The reason is unknown. Drop the flag for now.
+ filter-flags -mstackrealign
+ fi
+
+ case $(tc-arch) in
+ amd64|x86)
+ filter-flags '-mcpu=*'
+
+ tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287
+
+ if tc_version_is_between 4.6 4.7 ; then
+ # https://bugs.gentoo.org/411333
+ # https://bugs.gentoo.org/466454
+ replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
+ fi
+ ;;
+ alpha)
+ # https://bugs.gentoo.org/454426
+ append-ldflags -Wl,--no-relax
+ ;;
+ sparc)
+ # temporary workaround for random ICEs reproduced by multiple users
+ # https://bugs.gentoo.org/457062
+ tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
+ ;;
+ *-macos)
+ # http://gcc.gnu.org/PR25127
+ tc_version_is_between 4.0 4.2 && \
+ filter-flags '-mcpu=*' '-march=*' '-mtune=*'
+ ;;
+ esac
+
+ strip-unsupported-flags
+
+ # these are set here so we have something sane at configure time
+ if is_crosscompile ; then
+ # Set this to something sane for both native and target
+ CFLAGS="-O2 -pipe"
+ FFLAGS=${CFLAGS}
+ FCFLAGS=${CFLAGS}
+
+ # "hppa2.0-unknown-linux-gnu" -> hppa2_0_unknown_linux_gnu
+ local VAR="CFLAGS_"${CTARGET//[-.]/_}
+ CXXFLAGS=${!VAR-${CFLAGS}}
+ fi
+
+ export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
+}
+
+setup_minispecs_gcc_build_specs() {
+ # Setup the "build.specs" file for gcc 4.3 to use when building.
+ if hardened_gcc_works pie ; then
+ cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
+ fi
+ if hardened_gcc_works ssp ; then
+ for s in ssp sspall ; do
+ cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
+ done
+ fi
+ for s in nostrict znow ; do
+ cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
+ done
+ export GCC_SPECS="${WORKDIR}"/build.specs
+}
+
+gcc-multilib-configure() {
+ if ! is_multilib ; then
+ confgcc+=( --disable-multilib )
+ # Fun times: if we are building for a target that has multiple
+ # possible ABI formats, and the user has told us to pick one
+ # that isn't the default, then not specifying it via the list
+ # below will break that on us.
+ else
+ confgcc+=( --enable-multilib )
+ fi
+
+ # translate our notion of multilibs into gcc's
+ local abi list
+ for abi in $(get_all_abis TARGET) ; do
+ local l=$(gcc-abi-map ${abi})
+ [[ -n ${l} ]] && list+=",${l}"
+ done
+ if [[ -n ${list} ]] ; then
+ case ${CTARGET} in
+ x86_64*)
+ tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} )
+ ;;
+ esac
+ fi
+}
+
+gcc-abi-map() {
+ # Convert the ABI name we use in Gentoo to what gcc uses
+ local map=()
+ case ${CTARGET} in
+ mips*) map=("o32 32" "n32 n32" "n64 64") ;;
+ riscv*) map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32") ;;
+ x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
+ esac
+
+ local m
+ for m in "${map[@]}" ; do
+ l=( ${m} )
+ [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
+ done
+}
+
+#----> src_compile <----
+
+toolchain_src_compile() {
+ touch "${S}"/gcc/c-gperf.h
+
+ # Do not make manpages if we do not have perl ...
+ [[ ! -x /usr/bin/perl ]] \
+ && find "${WORKDIR}"/build -name '*.[17]' -exec touch {} +
+
+ # To compile ada library standard files special compiler options are passed
+ # via ADAFLAGS in the Makefile.
+ # Unset ADAFLAGS as setting this override the options
+ unset ADAFLAGS
+
+ # Older gcc versions did not detect bash and re-exec itself, so force the
+ # use of bash. Newer ones will auto-detect, but this is not harmful.
+ # This needs to be set for compile as well, as it's used in libtool
+ # generation, which will break install otherwise (at least in 3.3.6): #664486
+ CONFIG_SHELL="${EPREFIX}/bin/bash" \
+ gcc_do_make ${GCC_MAKE_TARGET}
+}
+
+gcc_do_make() {
+ # This function accepts one optional argument, the make target to be used.
+ # If omitted, gcc_do_make will try to guess whether it should use all,
+ # or bootstrap-lean depending on CTARGET and arch.
+ # An example of how to use this function:
+ #
+ # gcc_do_make all-target-libstdc++-v3
+
+ [[ -n ${1} ]] && GCC_MAKE_TARGET=${1}
+
+ # default target
+ if is_crosscompile || tc-is-cross-compiler ; then
+ # 3 stage bootstrapping doesnt quite work when you cant run the
+ # resulting binaries natively ^^;
+ GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
+ else
+ if _tc_use_if_iuse pgo; then
+ GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
+ else
+ GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
+ fi
+ fi
+
+ # Older versions of GCC could not do profiledbootstrap in parallel due to
+ # collisions with profiling info.
+ if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]]; then
+ ! tc_version_is_at_least 4.6 && export MAKEOPTS="${MAKEOPTS} -j1"
+ fi
+
+ if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
+ STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
+ elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
+ # See bug #79852
+ STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
+ fi
+
+ if is_crosscompile; then
+ # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
+ # but I'll leave this in anyways as someone might have had
+ # some reason for putting it in here... --eradicator
+ BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
+ else
+ # we only want to use the system's CFLAGS if not building a
+ # cross-compiler.
+ BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
+ fi
+
+ einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
+
+ pushd "${WORKDIR}"/build >/dev/null
+
+ emake \
+ LDFLAGS="${LDFLAGS}" \
+ STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
+ LIBPATH="${LIBPATH}" \
+ BOOT_CFLAGS="${BOOT_CFLAGS}" \
+ ${GCC_MAKE_TARGET} \
+ || die "emake failed with ${GCC_MAKE_TARGET}"
+
+ if is_ada; then
+ # Without these links it is not getting the good compiler
+ # Need to check why
+ ln -s gcc ../build/prev-gcc || die
+ ln -s ${CHOST} ../build/prev-${CHOST} || die
+ # Building standard ada library
+ emake -C gcc gnatlib-shared
+ # Building gnat toold
+ emake -C gcc gnattools
+ fi
+
+ if ! is_crosscompile && _tc_use_if_iuse cxx && _tc_use_if_iuse doc ; then
+ if type -p doxygen > /dev/null ; then
+ if tc_version_is_at_least 4.3 ; then
+ cd "${CTARGET}"/libstdc++-v3/doc
+ emake doc-man-doxygen || ewarn "failed to make docs"
+ else
+ cd "${CTARGET}"/libstdc++-v3
+ emake doxygen-man || ewarn "failed to make docs"
+ fi
+ # Clean bogus manpages. #113902
+ find -name '*_build_*' -delete
+ # Blow away generated directory references. Newer versions of gcc
+ # have gotten better at this, but not perfect. This is easier than
+ # backporting all of the various doxygen patches. #486754
+ find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
+ xargs rm -f
+ else
+ ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
+ fi
+ fi
+
+ popd >/dev/null
+}
+
+#---->> src_test <<----
+
+toolchain_src_test() {
+ cd "${WORKDIR}"/build
+ # 'asan' wants to be preloaded first, so does 'sandbox'.
+ # To make asan tests work disable sandbox for all of test suite.
+ # 'backtrace' tests also does not like 'libsandbox.so' presence.
+ SANDBOX_ON=0 LD_PRELOAD= emake -k check
+}
+
+#---->> src_install <<----
+
+toolchain_src_install() {
+ cd "${WORKDIR}"/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
+ # build system only expects to install out of the build dir, not the source. #464008
+ mkdir -p gcc/doc
+ local x=
+ for x in "${S}"/gcc/doc/*.info* ; do
+ if [[ -f ${x} ]] ; then
+ cp "${x}" gcc/doc/ || die
+ fi
+ done
+
+ # We remove the generated fixincludes, as they can cause things to break
+ # (ncurses, openssl, etc). We do not prevent them from being built, as
+ # in the following commit which we revert:
+ # https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
+ # This is because bsd userland needs fixedincludes to build gcc, while
+ # linux does not. Both can dispose of them afterwards.
+ while read x ; do
+ grep -q 'It has been auto-edited by fixincludes from' "${x}" \
+ && rm -f "${x}"
+ done < <(find gcc/include*/ -name '*.h')
+
+ # Do the 'make install' from the build directory
+ S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
+
+ # Punt some tools which are really only useful while building gcc
+ find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
+ # This one comes with binutils
+ find "${ED}" -name libiberty.a -delete
+
+ # Move the libraries to the proper location
+ gcc_movelibs
+
+ # Basic sanity check
+ if ! is_crosscompile ; then
+ local EXEEXT
+ eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
+ [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
+ fi
+
+ 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
+
+ # Make sure we dont have stuff lying around that
+ # can nuke multiple versions of gcc
+ gcc_slot_java
+
+ dodir /usr/bin
+ 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 gnat* ; do
+ # For some reason, g77 gets made instead of ${CTARGET}-g77...
+ # this should take care of that
+ if [[ -f ${x} ]] ; then
+ # In case they're hardlinks, clear out the target first
+ # otherwise the mv below will complain.
+ rm -f ${CTARGET}-${x}
+ mv ${x} ${CTARGET}-${x}
+ fi
+
+ if [[ -f ${CTARGET}-${x} ]] ; then
+ if ! is_crosscompile ; then
+ ln -sf ${CTARGET}-${x} ${x}
+ dosym ${BINPATH}/${CTARGET}-${x} \
+ /usr/bin/${x}-${GCC_CONFIG_VER}
+ fi
+ # Create versioned symlinks
+ dosym ${BINPATH}/${CTARGET}-${x} \
+ /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
+ fi
+
+ if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
+ rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
+ ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
+ fi
+ done
+
+ # When gcc builds a crosscompiler it does not install unprefixed tools.
+ # When cross-building gcc does install native tools.
+ if ! is_crosscompile; then
+ # Rename the main go binaries as we don't want to clobber dev-lang/go
+ # when gcc-config runs. #567806
+ if tc_version_is_at_least 5 && is_go ; then
+ for x in go gofmt; do
+ mv ${x} ${x}-${GCCMAJOR} || die
+ done
+ fi
+ fi
+
+ # 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
+ rm -rf "${ED}"/usr/share/{man,info}
+ rm -rf "${D}"${DATAPATH}/{man,info}
+ else
+ local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
+ if [[ -d ${cxx_mandir} ]] ; then
+ cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
+ fi
+ fi
+
+ # portage regenerates 'dir' files on it's own: bug #672408
+ # Drop 'dir' files to avoid collisions.
+ if [[ -f "${D}${DATAPATH}"/info/dir ]]; then
+ einfo "Deleting '${D}${DATAPATH}/info/dir'"
+ rm "${D}${DATAPATH}"/info/dir || die
+ fi
+
+ # prune empty dirs left behind
+ find "${ED}" -depth -type d -delete 2>/dev/null
+
+ # libstdc++.la: Delete as it doesn't add anything useful: g++ itself
+ # handles linkage correctly in the dynamic & static case. It also just
+ # causes us pain: any C++ progs/libs linking with libtool will gain a
+ # reference to the full libstdc++.la file which is gcc version specific.
+ # libstdc++fs.la: It doesn't link against anything useful.
+ # 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.
+ # libgfortran.la: gfortran itself handles linkage correctly in the
+ # dynamic & static case (libgfortran.spec). #573302
+ # libgfortranbegin.la: Same as above, and it's an internal lib.
+ # libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
+ # libmpxwrappers.la: See above.
+ # libitm.la: gcc itself handles linkage correctly (libitm.spec).
+ # libvtv.la: gcc itself handles linkage correctly.
+ # lib*san.la: Sanitizer linkage is handled internally by gcc, and they
+ # do not support static linking. #487550 #546700
+ find "${D}${LIBPATH}" \
+ '(' \
+ -name libstdc++.la -o \
+ -name libstdc++fs.la -o \
+ -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 \
+ -name libgfortranbegin.la -o \
+ -name libmpx.la -o \
+ -name libmpxwrappers.la -o \
+ -name libitm.la -o \
+ -name libvtv.la -o \
+ -name 'lib*san.la' \
+ ')' -type f -delete
+
+ # Use gid of 0 because some stupid ports don't have
+ # the group 'root' set to gid 0. Send to /dev/null
+ # for people who are testing as non-root.
+ chown -R root:0 "${D}${LIBPATH}" 2>/dev/null
+
+ # Installing gdb pretty-printers into gdb-specific location.
+ local py gdbdir=/usr/share/gdb/auto-load${LIBPATH}
+ pushd "${D}${LIBPATH}" >/dev/null
+ for py in $(find . -name '*-gdb.py') ; do
+ local multidir=${py%/*}
+ insinto "${gdbdir}/${multidir}"
+ sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
+ doins "${py}" || die
+ rm "${py}" || die
+ done
+ popd >/dev/null
+
+ # Don't scan .gox files for executable stacks - false positives
+ export QA_EXECSTACK="usr/lib*/go/*/*.gox"
+ export QA_WX_LOAD="usr/lib*/go/*/*.gox"
+
+ # Disable RANDMMAP so PCH works. #301299
+ if tc_version_is_at_least 4.3 ; then
+ pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
+ pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
+ fi
+
+ # Disable MPROTECT so java works. #574808
+ if is_gcj ; then
+ pax-mark -m "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
+ pax-mark -m "${D}${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
+ fi
+}
+
+# Move around the libs to the right location. For some reason,
+# when installing gcc, it dumps internal libraries into /usr/lib
+# instead of the private gcc lib path
+gcc_movelibs() {
+ # For non-target libs which are for CHOST and not CTARGET, we want to
+ # move them to the compiler-specific CHOST internal dir. This is stuff
+ # that you want to link against when building tools rather than building
+ # code to run on the target.
+ if tc_version_is_at_least 5 && is_crosscompile ; then
+ dodir "${HOSTLIBPATH#${EPREFIX}}"
+ mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
+ fi
+ # libgccjit gets installed to /usr/lib, not /usr/$(get_libdir). Probably
+ # due to a bug in gcc build system.
+ if is_jit ; then
+ dodir "${LIBPATH#${EPREFIX}}"
+ mv "${ED}"/usr/lib/libgccjit* "${D}${LIBPATH}" || die
+ fi
+
+ # For all the libs that are built for CTARGET, move them into the
+ # compiler-specific CTARGET internal dir.
+ local x multiarg removedirs=""
+ for multiarg in $($(XGCC) -print-multi-lib) ; do
+ multiarg=${multiarg#*;}
+ multiarg=${multiarg//@/ -}
+
+ local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
+ local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
+ local TODIR="${D}${LIBPATH}"/${MULTIDIR}
+ local FROMDIR=
+
+ [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
+
+ for FROMDIR in \
+ "${LIBPATH}"/${OS_MULTIDIR} \
+ "${LIBPATH}"/../${MULTIDIR} \
+ "${PREFIX}"/lib/${OS_MULTIDIR} \
+ "${PREFIX}"/${CTARGET}/lib/${OS_MULTIDIR}
+ do
+ removedirs="${removedirs} ${FROMDIR}"
+ FROMDIR=${D}${FROMDIR}
+ if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
+ local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
+ if [[ -n ${files} ]] ; then
+ mv ${files} "${TODIR}" || die
+ fi
+ fi
+ done
+ fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
+
+ # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
+ FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
+ for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
+ [[ -f ${x} ]] || continue
+ sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}" || die
+ mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
+ done
+ done
+
+ # We remove directories separately to avoid this case:
+ # mv SRC/lib/../lib/*.o DEST
+ # rmdir SRC/lib/../lib/
+ # mv SRC/lib/../lib32/*.o DEST # Bork
+ for FROMDIR in ${removedirs} ; do
+ rmdir "${D}"${FROMDIR} >& /dev/null
+ done
+ find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
+}
+
+# make sure the libtool archives have libdir set to where they actually
+# -are-, and not where they -used- to be. also, any dependencies we have
+# on our own .la files need to be updated.
+fix_libtool_libdir_paths() {
+ local libpath="$1"
+
+ pushd "${D}" >/dev/null
+
+ pushd "./${libpath}" >/dev/null
+ local dir="${PWD#${D%/}}"
+ local allarchives=$(echo *.la)
+ allarchives="\(${allarchives// /\\|}\)"
+ popd >/dev/null
+
+ # The libdir might not have any .la files. #548782
+ find "./${dir}" -maxdepth 1 -name '*.la' \
+ -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
+ # Would be nice to combine these, but -maxdepth can not be specified
+ # on sub-expressions.
+ find "./${PREFIX}"/lib* -maxdepth 3 -name '*.la' \
+ -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
+ find "./${dir}/" -maxdepth 1 -name '*.la' \
+ -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
+
+ popd >/dev/null
+}
+
+create_gcc_env_entry() {
+ dodir /etc/env.d/gcc
+ local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
+
+ local gcc_specs_file
+ local gcc_envd_file="${ED}${gcc_envd_base}"
+ if [[ -z $1 ]] ; then
+ # I'm leaving the following commented out to remind me that it
+ # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
+ # on chroot or in non-toolchain.eclass gcc ebuilds!
+ #gcc_specs_file="${LIBPATH}/specs"
+ gcc_specs_file=""
+ else
+ gcc_envd_file+="-$1"
+ gcc_specs_file="${LIBPATH}/$1.specs"
+ fi
+
+ # We want to list the default ABI's LIBPATH first so libtool
+ # searches that directory first. This is a temporary
+ # workaround for libtool being stupid and using .la's from
+ # conflicting ABIs by using the first one in the search path
+ local ldpaths mosdirs
+ local mdir mosdir abi ldpath
+ for abi in $(get_all_abis TARGET) ; do
+ mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
+ ldpath=${LIBPATH}
+ [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
+ ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
+
+ mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
+ mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
+ done
+
+ cat <<-EOF > ${gcc_envd_file}
+ GCC_PATH="${BINPATH}"
+ LDPATH="${ldpaths}"
+ MANPATH="${DATAPATH}/man"
+ INFOPATH="${DATAPATH}/info"
+ STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
+ CTARGET="${CTARGET}"
+ GCC_SPECS="${gcc_specs_file}"
+ MULTIOSDIRS="${mosdirs}"
+ 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
+ return 0
+ fi
+
+ # setup the hardenedno* specs files and the vanilla specs file.
+ if hardened_gcc_works ; then
+ create_gcc_env_entry hardenednopiessp
+ fi
+ if hardened_gcc_works pie ; then
+ create_gcc_env_entry hardenednopie
+ fi
+ if hardened_gcc_works ssp ; then
+ create_gcc_env_entry hardenednossp
+ fi
+ create_gcc_env_entry vanilla
+ insinto ${LIBPATH#${EPREFIX}}
+ doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
+ # Build system specs file which, if it exists, must be a complete set of
+ # specs as it completely and unconditionally overrides the builtin specs.
+ if ! tc_version_is_at_least 4.4 ; then
+ $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
+ cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
+ doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
+ fi
+}
+
+gcc_slot_java() {
+ local x
+
+ # Move Java headers to compiler-specific dir
+ for x in "${D}${PREFIX}"/include/gc*.h "${D}${PREFIX}"/include/j*.h ; do
+ [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/include/
+ done
+ for x in gcj gnu java javax org ; do
+ if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
+ dodir /${LIBPATH#${EPREFIX}}/include/${x}
+ mv -f "${D}${PREFIX}"/include/${x}/* "${D}${LIBPATH}"/include/${x}/
+ rm -rf "${D}${PREFIX}"/include/${x}
+ fi
+ done
+
+ if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
+ dodir /${LIBPATH#${EPREFIX}}/security
+ mv -f "${D}${PREFIX}"/lib*/security/* "${D}${LIBPATH}"/security
+ rm -rf "${D}${PREFIX}"/lib*/security
+ fi
+
+ # Move random gcj files to compiler-specific directories
+ for x in libgcj.spec logging.properties ; do
+ x="${D}${PREFIX}/lib/${x}"
+ [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/
+ done
+
+ # Rename jar because it could clash with Kaffe's jar if this gcc is
+ # primary compiler (aka don't have the -<version> extension)
+ cd "${D}${BINPATH}"
+ [[ -f jar ]] && mv -f jar gcj-jar
+}
+
+#---->> pkg_post* <<----
+
+toolchain_pkg_postinst() {
+ do_gcc_config
+ if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
+ eselect compiler-shadow update all
+ fi
+
+ if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
+ # gcc stopped installing .la files fixer in June 2020.
+ # Cleaning can be removed in June 2022.
+ rm -f "${EROOT%/}"/sbin/fix_libtool_files.sh
+ rm -f "${EROOT%/}"/usr/sbin/fix_libtool_files.sh
+ rm -f "${EROOT%/}"/usr/share/gcc-data/fixlafiles.awk
+ fi
+}
+
+toolchain_pkg_postrm() {
+ do_gcc_config
+ if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
+ eselect compiler-shadow clean all
+ fi
+
+ # clean up the cruft left behind by cross-compilers
+ 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}
+ fi
+ return 0
+ fi
+
+ # gcc stopped installing .la files fixer in June 2020.
+ # Cleaning can be removed in June 2022.
+ rm -f "${EROOT%/}"/sbin/fix_libtool_files.sh
+ rm -f "${EROOT%/}"/usr/share/gcc-data/fixlafiles.awk
+}
+
+do_gcc_config() {
+ if ! should_we_gcc_config ; then
+ gcc-config --use-old --force
+ return 0
+ fi
+
+ local current_gcc_config target
+
+ current_gcc_config=$(gcc-config -c ${CTARGET} 2>/dev/null)
+ if [[ -n ${current_gcc_config} ]] ; then
+ local current_specs use_specs
+ # figure out which specs-specific config is active
+ current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
+ [[ -n ${current_specs} ]] && use_specs=-${current_specs}
+
+ if [[ -n ${use_specs} ]] && \
+ [[ ! -e ${EROOT%/}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
+ then
+ ewarn "The currently selected specs-specific gcc config,"
+ ewarn "${current_specs}, doesn't exist anymore. This is usually"
+ ewarn "due to enabling/disabling hardened or switching to a version"
+ ewarn "of gcc that doesnt create multiple specs files. The default"
+ ewarn "config will be used, and the previous preference forgotten."
+ use_specs=""
+ fi
+
+ target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
+ else
+ # The curent target is invalid. Attempt to switch to a valid one.
+ # Blindly pick the latest version. #529608
+ # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
+ # doing a partial grep like this.
+ target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
+ fi
+
+ gcc-config "${target}"
+}
+
+should_we_gcc_config() {
+ # if the current config is invalid, we definitely want a new one
+ # Note: due to bash quirkiness, the following must not be 1 line
+ local curr_config
+ curr_config=$(gcc-config -c ${CTARGET} 2>&1) || return 0
+
+ # if the previously selected config has the same major.minor (branch) as
+ # the version we are installing, then it will probably be uninstalled
+ # for being in the same SLOT, make sure we run gcc-config.
+ local curr_config_ver=$(gcc-config -S ${curr_config} | awk '{print $2}')
+
+ local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver})
+
+ if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
+ return 0
+ else
+ # if we're installing a genuinely different compiler version,
+ # we should probably tell the user -how- to switch to the new
+ # gcc version, since we're not going to do it for him/her.
+ # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
+ # the middle of an emerge operation (like an 'emerge -e world'
+ # which could install multiple gcc versions).
+ # Only warn if we're installing a pkg as we might be called from
+ # the pkg_{pre,post}rm steps. #446830
+ if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
+ einfo "The current gcc config appears valid, so it will not be"
+ einfo "automatically switched for you. If you would like to"
+ einfo "switch to the newly installed gcc version, do the"
+ einfo "following:"
+ echo
+ einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
+ einfo "source /etc/profile"
+ echo
+ fi
+ return 1
+ fi
+}
+
+#---->> support and misc functions <<----
+
+# This is to make sure we don't accidentally try to enable support for a
+# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
+#
+# Also add a hook so special ebuilds (kgcc64) can control which languages
+# exactly get enabled
+gcc-lang-supported() {
+ grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
+ [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
+ has $1 ${TOOLCHAIN_ALLOWED_LANGS}
+}
+
+_tc_use_if_iuse() {
+ in_iuse $1 && use $1
+}
+
+is_ada() {
+ gcc-lang-supported ada || return 1
+ _tc_use_if_iuse ada
+}
+
+is_cxx() {
+ gcc-lang-supported 'c++' || return 1
+ _tc_use_if_iuse cxx
+}
+
+is_d() {
+ gcc-lang-supported d || return 1
+ _tc_use_if_iuse d
+}
+
+is_f77() {
+ gcc-lang-supported f77 || return 1
+ _tc_use_if_iuse fortran
+}
+
+is_f95() {
+ gcc-lang-supported f95 || return 1
+ _tc_use_if_iuse fortran
+}
+
+is_fortran() {
+ gcc-lang-supported fortran || return 1
+ _tc_use_if_iuse fortran
+}
+
+is_gcj() {
+ gcc-lang-supported java || return 1
+ _tc_use_if_iuse cxx && _tc_use_if_iuse gcj
+}
+
+is_go() {
+ gcc-lang-supported go || return 1
+ _tc_use_if_iuse cxx && _tc_use_if_iuse go
+}
+
+is_jit() {
+ gcc-lang-supported jit || return 1
+ # cross-compiler does not really support jit as it has
+ # to generate code for a target. On target like avr
+ # libgcclit.so can't link at all: bug #594572
+ is_crosscompile && return 1
+ _tc_use_if_iuse jit
+}
+
+is_multilib() {
+ _tc_use_if_iuse multilib
+}
+
+is_objc() {
+ gcc-lang-supported objc || return 1
+ _tc_use_if_iuse objc
+}
+
+is_objcxx() {
+ gcc-lang-supported 'obj-c++' || return 1
+ _tc_use_if_iuse cxx && _tc_use_if_iuse objc++
+}
+
+# Grab a variable from the build system (taken from linux-info.eclass)
+get_make_var() {
+ local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
+ echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
+ r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
+}
+
+XGCC() { get_make_var GCC_FOR_TARGET ; }
+
+# The gentoo piessp patches allow for 3 configurations:
+# 1) PIE+SSP by default
+# 2) PIE by default
+# 3) SSP by default
+hardened_gcc_works() {
+ if [[ $1 == "pie" ]] ; then
+ # $gcc_cv_ld_pie is unreliable as it simply take the output of
+ # `ld --help | grep -- -pie`, that reports the option in all cases, also if
+ # the loader doesn't actually load the resulting executables.
+ # To avoid breakage, blacklist FreeBSD here at least
+ [[ ${CTARGET} == *-freebsd* ]] && return 1
+
+ want_pie || return 1
+ _tc_use_if_iuse nopie && return 1
+ hardened_gcc_is_stable pie
+ return $?
+ elif [[ $1 == "ssp" ]] ; then
+ [[ -n ${SPECS_VER} ]] || return 1
+ _tc_use_if_iuse nossp && return 1
+ hardened_gcc_is_stable ssp
+ return $?
+ else
+ # laziness ;)
+ hardened_gcc_works pie || return 1
+ hardened_gcc_works ssp || return 1
+ return 0
+ fi
+}
+
+hardened_gcc_is_stable() {
+ local tocheck
+ if [[ $1 == "pie" ]] ; then
+ if [[ ${CTARGET} == *-uclibc* ]] ; then
+ tocheck=${PIE_UCLIBC_STABLE}
+ else
+ tocheck=${PIE_GLIBC_STABLE}
+ fi
+ elif [[ $1 == "ssp" ]] ; then
+ if [[ ${CTARGET} == *-uclibc* ]] ; then
+ tocheck=${SSP_UCLIBC_STABLE}
+ elif [[ ${CTARGET} == *-gnu* ]] ; then
+ tocheck=${SSP_STABLE}
+ fi
+ else
+ die "hardened_gcc_stable needs to be called with pie or ssp"
+ fi
+
+ has $(tc-arch) ${tocheck} && return 0
+ return 1
+}
+
+want_minispecs() {
+ # on gcc 6 we don't need minispecs
+ if tc_version_is_at_least 6.0 ; then
+ return 0
+ fi
+ if tc_version_is_at_least 4.3.2 && _tc_use_if_iuse hardened ; then
+ if ! want_pie ; then
+ ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
+ elif use vanilla ; then
+ ewarn "You will not get hardened features if you have the vanilla USE-flag."
+ elif _tc_use_if_iuse nopie && _tc_use_if_iuse nossp ; then
+ ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
+ elif ! hardened_gcc_works ; then
+ ewarn "Your $(tc-arch) arch is not supported."
+ else
+ return 0
+ fi
+ ewarn "Hope you know what you are doing. Hardened will not work."
+ return 0
+ fi
+ return 1
+}
+
+want_pie() {
+ ! _tc_use_if_iuse hardened && [[ -n ${PIE_VER} ]] \
+ && _tc_use_if_iuse nopie && return 1
+ [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
+ tc_version_is_at_least 4.3.2 && return 1
+ [[ -z ${PIE_VER} ]] && return 1
+ _tc_use_if_iuse nopie || return 0
+ return 1
+}
+
+has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
+toolchain_death_notice() {
+ if [[ -e "${WORKDIR}"/build ]] ; then
+ pushd "${WORKDIR}"/build >/dev/null
+ (echo '' | $(tc-getCC ${CTARGET}) ${CFLAGS} -v -E - 2>&1) > gccinfo.log
+ [[ -e "${T}"/build.log ]] && cp "${T}"/build.log .
+ tar jcf "${WORKDIR}"/gcc-build-logs.tar.bz2 \
+ gccinfo.log build.log $(find -name config.log)
+ rm gccinfo.log build.log
+ eerror
+ eerror "Please include ${WORKDIR}/gcc-build-logs.tar.bz2 in your bug report."
+ eerror
+ popd >/dev/null
+ fi
+}
+
+# Note [implicitly enabled flags]
+# -------------------------------
+# Usually configure-based packages handle explicit feature requests
+# like
+# ./configure --enable-foo
+# as explicit request to check for support of 'foo' and bail out at
+# configure time.
+#
+# GCC does not follow this pattern and instead overrides autodetection
+# of the feature and enables it unconditionally.
+# See bugs:
+# https://gcc.gnu.org/PR85663 (libsanitizer on mips)
+# https://bugs.gentoo.org/661252 (libvtv on powerpc64)
+#
+# Thus safer way to enable/disable the feature is to rely on implicit
+# enabled-by-default state:
+# econf $(usex foo '' --disable-foo)
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2019-08-28 21:29 Jory Pratt
0 siblings, 0 replies; 24+ messages in thread
From: Jory Pratt @ 2019-08-28 21:29 UTC (permalink / raw
To: gentoo-commits
commit: 5ed6117d4a4f392d6ac52cbdfc4b9a3a4f966d53
Author: Jory Pratt <anarchy <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 28 21:28:32 2019 +0000
Commit: Jory Pratt <anarchy <AT> gentoo <DOT> org>
CommitDate: Wed Aug 28 21:28:32 2019 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=5ed6117d
eclass/toolchain.eclass: drop eclass from overlay as
changes have been merged into the tree
Signed-off-by: Jory Pratt <anarchy <AT> gentoo.org>
eclass/toolchain.eclass | 2558 -----------------------------------------------
1 file changed, 2558 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
deleted file mode 100644
index 91297c0..0000000
--- a/eclass/toolchain.eclass
+++ /dev/null
@@ -1,2558 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
-# @SUPPORTED_EAPIS: 5 6
-
-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
- EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"
- # naming style:
- # gcc-4.7.1_pre9999 -> gcc-4_7-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=${EGIT_BRANCH//./_}
- inherit git-2
-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 ;;
- *) die "I don't speak EAPI ${EAPI}." ;;
-esac
-EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
- src_compile src_test src_install pkg_postinst pkg_postrm
-
-#---->> globals <<----
-
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} = ${CHOST} ]] ; then
- if [[ ${CATEGORY} == cross-* ]] ; then
- export CTARGET=${CATEGORY#cross-}
- fi
-fi
-: ${TARGET_ABI:=${ABI}}
-: ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
-: ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
-
-is_crosscompile() {
- [[ ${CHOST} != ${CTARGET} ]]
-}
-
-# General purpose version check. Without a second arg matches up to minor version (x.x.x)
-tc_version_is_at_least() {
- ver_test "${2:-${GCC_RELEASE_VER}}" -ge "$1"
-}
-
-# General purpose version range check
-# Note that it matches up to but NOT including the second version
-tc_version_is_between() {
- tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}"
-}
-
-GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
-GCC_PVR=${GCC_PV}
-[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
-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}
-elif [[ ${GCC_PV} == *_rc* ]] ; then
- 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
- LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
-else
- LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}}
-fi
-INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
-
-if is_crosscompile ; then
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
- HOSTLIBPATH=${PREFIX}/${CHOST}/${CTARGET}/lib/${GCC_CONFIG_VER}
-else
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
-fi
-
-DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
-
-# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
-# We will handle /usr/include/g++-v3/ with gcc-config ...
-STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
-
-#---->> LICENSE+SLOT+IUSE logic <<----
-
-if tc_version_is_at_least 4.6 ; then
- LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
-elif tc_version_is_at_least 4.4 ; then
- LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.2+"
-elif tc_version_is_at_least 4.3 ; then
- LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+"
-elif tc_version_is_at_least 4.2 ; then
- LICENSE="GPL-3+ LGPL-2.1+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+"
-elif tc_version_is_at_least 3.3 ; then
- LICENSE="GPL-2+ LGPL-2.1+ FDL-1.2+"
-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"
-
-TC_FEATURES=()
-
-tc_has_feature() {
- has "$1" "${TC_FEATURES[@]}"
-}
-
-if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
- IUSE+=" altivec debug +cxx +fortran" TC_FEATURES+=(fortran)
- [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
- [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
- [[ -n ${D_VER} ]] && IUSE+=" d"
- [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
- tc_version_is_at_least 3 && IUSE+=" doc hardened multilib objc"
- tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=(gcj)
- tc_version_is_at_least 3.3 && IUSE+=" pgo"
- tc_version_is_at_least 4.0 &&
- IUSE+=" objc-gc" TC_FEATURES+=(objc-gc)
- tc_version_is_between 4.0 4.9 && IUSE+=" mudflap"
- tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
- 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)
- 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"
- tc_version_is_between 5.0 9 && IUSE+=" mpx"
- tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
- # systemtap is a gentoo-specific switch: bug #654748
- tc_version_is_at_least 8.0 &&
- IUSE+=" systemtap" TC_FEATURES+=(systemtap)
- tc_version_is_at_least 9.0 && IUSE+=" d"
- tc_version_is_at_least 9.1 && IUSE+=" lto"
-fi
-
-SLOT="${GCC_CONFIG_VER}"
-
-#---->> DEPEND <<----
-
-RDEPEND="sys-libs/zlib
- nls? ( virtual/libintl )"
-
-tc_version_is_at_least 3 && RDEPEND+=" virtual/libiconv"
-
-if tc_version_is_at_least 4 ; then
- GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0= >=dev-libs/mpfr-2.4.2:0="
- if tc_version_is_at_least 4.3 ; then
- RDEPEND+=" ${GMP_MPFR_DEPS}"
- elif tc_has_feature fortran ; then
- RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
- fi
-fi
-
-tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
-
-if tc_has_feature objc-gc ; then
- if tc_version_is_at_least 7 ; then
- RDEPEND+=" objc-gc? ( >=dev-libs/boehm-gc-7.4.2 )"
- fi
-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
-fi
-
-DEPEND="${RDEPEND}
- >=sys-devel/bison-1.875
- >=sys-devel/flex-2.5.4
- nls? ( sys-devel/gettext )
- ${GCC_EBUILD_TEST_FLAG}? (
- >=dev-util/dejagnu-1.4.4
- >=sys-devel/autogen-5.5.4
- )"
-
-if tc_has_feature gcj ; then
- GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
- GCJ_GTK_DEPS="
- x11-base/xorg-proto
- x11-libs/libXt
- x11-libs/libX11
- x11-libs/libXtst
- =x11-libs/gtk+-2*
- virtual/pkgconfig
- "
- tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
- tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
- DEPEND+=" gcj? ( awt? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
-fi
-
-if tc_has_feature 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 <<----
-
-# Set the source directory depending on whether we're using
-# a prerelease, snapshot, or release tarball.
-S=$(
- if [[ -n ${PRERELEASE} ]] ; then
- echo ${WORKDIR}/gcc-${PRERELEASE}
- elif [[ -n ${SNAPSHOT} ]] ; then
- echo ${WORKDIR}/gcc-${SNAPSHOT}
- else
- echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
- fi
-)
-
-gentoo_urls() {
- local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
- HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI
- HTTP~tamiko/distfiles/URI HTTP~slyfox/distfiles/URI"
- devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
- echo mirror://gentoo/$1 ${devspace//URI/$1}
-}
-
-# This function handles the basics of setting the SRC_URI for a gcc ebuild.
-# To use, set SRC_URI with:
-#
-# SRC_URI="$(get_gcc_src_uri)"
-#
-# Other than the variables normally set by portage, this function's behavior
-# can be altered by setting the following:
-#
-# 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.
-# The resulting filename of this tarball will be:
-# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
-#
-# PIE_VER
-# PIE_GCC_VER
-# These variables control patching in various updates for the logic
-# controlling Position Independant Executables. PIE_VER is expected
-# to be the version of this patch, and PIE_GCC_VER the gcc version of
-# the patch:
-# An example:
-# PIE_VER="8.7.6.5"
-# PIE_GCC_VER="3.4.0"
-# The resulting filename of this tarball will be:
-# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
-#
-# SPECS_VER
-# SPECS_GCC_VER
-# This is for the minispecs files included in the hardened gcc-4.x
-# The specs files for hardenedno*, vanilla and for building the "specs" file.
-# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
-# the gcc version of the patch.
-# An example:
-# SPECS_VER="8.7.6.5"
-# SPECS_GCC_VER="3.4.0"
-# The resulting filename of this tarball will be:
-# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
-#
-# HTB_VER
-# HTB_GCC_VER
-# These variables control whether or not an ebuild supports Herman
-# ten Brugge's bounds-checking patches. If you want to use a patch
-# for an older gcc version with a new gcc, make sure you set
-# HTB_GCC_VER to that version of gcc.
-#
-# CYGWINPORTS_GITREV
-# If set, this variable signals that we should apply additional patches
-# maintained by upstream Cygwin developers at github/cygwinports/gcc,
-# using the specified git commit id there. The list of patches to
-# apply is extracted from gcc.cygport, maintained there as well.
-# This is done for compilers running on Cygwin, not for cross compilers
-# with a Cygwin target.
-get_gcc_src_uri() {
- export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
- export 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}}
-
- # 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"
- 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
- 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} ]] && \
- GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
- [[ -n ${PATCH_VER} ]] && \
- GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
-
- # 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})"
-
- # gcc minispec for the hardened gcc 4 compiler
- [[ -n ${SPECS_VER} ]] && \
- GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
-
- # gcc bounds checking patch
- if [[ -n ${HTB_VER} ]] ; then
- local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
- GCC_SRC_URI+="
- boundschecking? (
- mirror://sourceforge/boundschecking/${HTBFILE}
- $(gentoo_urls ${HTBFILE})
- )"
- fi
-
- [[ -n ${D_VER} ]] && \
- GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )"
-
- if tc_has_feature gcj ; then
- if tc_version_is_at_least 4.5 ; then
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
- elif tc_version_is_at_least 4.3 ; then
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
- fi
- fi
-
- # Cygwin patches from https://github.com/cygwinports/gcc
- [[ -n ${CYGWINPORTS_GITREV} ]] && \
- GCC_SRC_URI+=" elibc_Cygwin? ( https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.tar.gz
- -> gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz )"
-
- echo "${GCC_SRC_URI}"
-}
-
-SRC_URI=$(get_gcc_src_uri)
-
-#---->> 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"'
- use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
- fi
-
- want_minispecs
-}
-
-#---->> pkg_setup <<----
-
-toolchain_pkg_setup() {
- # we dont want to use the installed compiler's specs to build gcc
- unset GCC_SPECS
- unset LANGUAGES #265283
-}
-
-#---->> src_unpack <<----
-
-toolchain_src_unpack() {
- if [[ ${PV} == *9999* ]]; then
- git-2_src_unpack
- else
- gcc_quick_unpack
- fi
-}
-
-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}}
-
- 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
-
- if [[ -n ${D_VER} ]] && use d ; then
- pushd "${S}"/gcc > /dev/null
- unpack gdc-${D_VER}-src.tar.bz2
- cd ..
- ebegin "Adding support for the D language"
- ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
- if ! eend $? ; then
- eerror "The D GCC package failed to apply"
- eerror "Please include this log file when posting a bug report:"
- 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_HTB_patches
- do_gcc_PIE_patches
- do_gcc_CYGWINPORTS_patches
-
- case ${EAPI:-0} in
- 5*) epatch_user;;
- 6) eapply_user ;;
- *) die "Update toolchain_src_prepare() for ${EAPI}." ;;
- esac
-
- if ( tc_version_is_at_least 4.8.2 || use_if_iuse hardened ) && ! use vanilla ; then
- make_gcc_hard
- fi
-
- # install the libstdc++ python into the right location
- # http://gcc.gnu.org/PR51368
- if tc_version_is_between 4.5 4.7 ; then
- sed -i \
- '/^pythondir =/s:=.*:= $(datadir)/python:' \
- "${S}"/libstdc++-v3/python/Makefile.in || die
- fi
-
- # make sure the pkg config files install into multilib dirs.
- # since we configure with just one --libdir, we can't use that
- # (as gcc itself takes care of building multilibs). #435728
- find "${S}" -name Makefile.in \
- -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
-
- # No idea when this first started being fixed, but let's go with 4.3.x for now
- if ! tc_version_is_at_least 4.3 ; then
- fix_files=""
- for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do
- [[ -e ${x} ]] && fix_files="${fix_files} ${x}"
- done
- ht_fix_file ${fix_files} */configure *.sh */Makefile.in
- fi
-
- setup_multilib_osdirnames
- 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
- fi
- fi
-
- # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
- 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
- else
- einfo "Copying ecj-4.3.jar"
- cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
- fi
- fi
-
- # disable --as-needed from being compiled into gcc specs
- # natively when using a gcc version < 3.4.4
- # http://gcc.gnu.org/PR14992
- if ! tc_version_is_at_least 3.4.4 ; then
- sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in
- fi
-
- # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names
- # in line with gcc-4.
- if tc_version_is_between 3.3 4.0 ; then
- do_gcc_rename_java_bins
- fi
-
- # Prevent libffi from being installed
- if tc_version_is_between 3.0 4.8 ; then
- sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in || die
- sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in || die
- fi
-
- # Fixup libtool to correctly generate .la files with portage
- elibtoolize --portage --shallow --no-uclibc
-
- gnuconfig_update
-
- # update configure files
- local f
- einfo "Fixing misc issues in configure files"
- for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
- ebegin " Updating ${f/${S}\/} [LANG]"
- patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
- || eerror "Please file a bug about this"
- eend $?
- done
- 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 [[ -x contrib/gcc_update ]] ; then
- einfo "Touching generated files"
- ./contrib/gcc_update --touch | \
- while read f ; do
- einfo " ${f%%...}"
- done
- fi
-}
-
-guess_patch_type_in_dir() {
- [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
- && EPATCH_SUFFIX="patch.bz2" \
- || EPATCH_SUFFIX="patch"
-}
-
-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"
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}"
-}
-
-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
-
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
-}
-
-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
-}
-
-# configure to build with the hardened GCC specs as the default
-make_gcc_hard() {
-
- local gcc_hard_flags=""
-
- # If we use gcc-6 or newer with pie enable to compile older gcc we need to pass -no-pie
- # to stage1; bug 618908
- if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
- einfo "Disabling PIE in stage1 (only) ..."
- sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
- fi
-
- # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
- if tc_version_is_at_least 6.0 ; then
- if use_if_iuse pie ; then
- einfo "Updating gcc to use automatic PIE building ..."
- fi
- if use_if_iuse ssp ; then
- einfo "Updating gcc to use automatic SSP building ..."
- fi
- 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_if_iuse hardened ; then
- # rebrand to make bug reports easier
- BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
- if hardened_gcc_works ; then
- einfo "Updating gcc to use automatic PIE + SSP building ..."
- gcc_hard_flags+=" -DEFAULT_PIE_SSP"
- elif hardened_gcc_works pie ; then
- einfo "Updating gcc to use automatic PIE building ..."
- ewarn "SSP has not been enabled by default"
- gcc_hard_flags+=" -DEFAULT_PIE"
- elif hardened_gcc_works ssp ; then
- einfo "Updating gcc to use automatic SSP building ..."
- ewarn "PIE has not been enabled by default"
- gcc_hard_flags+=" -DEFAULT_SSP"
- else
- # do nothing if hardened isn't supported, but don't die either
- ewarn "hardened is not supported for this arch in this gcc version"
- return 0
- fi
- else
- if hardened_gcc_works ssp ; then
- einfo "Updating gcc to use automatic SSP building ..."
- gcc_hard_flags+=" -DEFAULT_SSP"
- fi
- fi
- fi
-
- # we want to be able to control the pie patch logic via something other
- # than ALL_CFLAGS...
- sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
- -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
- -i "${S}"/gcc/Makefile.in
- # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
- if tc_version_is_at_least 4.7 ; then
- sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
- -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
- -i "${S}"/gcc/Makefile.in
- fi
-
- sed -i \
- -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
- "${S}"/gcc/Makefile.in || die
-
-}
-
-# This is a historical wart. The original Gentoo/amd64 port used:
-# lib32 - 32bit binaries (x86)
-# lib64 - 64bit binaries (x86_64)
-# lib - "native" binaries (a symlink to lib64)
-# Most other distros use the logic (including mainline gcc):
-# lib - 32bit binaries (x86)
-# lib64 - 64bit binaries (x86_64)
-# Over time, Gentoo is migrating to the latter form.
-#
-# Unfortunately, due to distros picking the lib32 behavior, newer gcc
-# versions will dynamically detect whether to use lib or lib32 for its
-# 32bit multilib. So, to keep the automagic from getting things wrong
-# while people are transitioning from the old style to the new style,
-# we always set the MULTILIB_OSDIRNAMES var for relevant targets.
-setup_multilib_osdirnames() {
- is_multilib || return 0
-
- local config
- local libdirs="../lib64 ../lib32"
-
- # this only makes sense for some Linux targets
- case ${CTARGET} in
- x86_64*-linux*) config="i386" ;;
- powerpc64*-linux*) config="rs6000" ;;
- sparc64*-linux*) config="sparc" ;;
- s390x*-linux*) config="s390" ;;
- *) return 0 ;;
- esac
- config+="/t-linux64"
-
- local sed_args=()
- if tc_version_is_at_least 4.6 ; then
- sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
- fi
- if [[ ${SYMLINK_LIB} == "yes" ]] ; then
- einfo "updating multilib directories to be: ${libdirs}"
- if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
- sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
- else
- sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
- fi
- else
- einfo "using upstream multilib; disabling lib32 autodetection"
- sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
- fi
- sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
-}
-
-gcc_version_patch() {
- # gcc-4.3+ has configure flags (whoo!)
- tc_version_is_at_least 4.3 && return 0
-
- local version_string=${GCC_CONFIG_VER}
- [[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}"
-
- einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
-
- local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
- if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
- gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
- else
- version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
- gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
- fi
- sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
-}
-
-do_gcc_rename_java_bins() {
- # bug #139918 - conflict between gcc and java-config-2 for ownership of
- # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch
- # because patches would be large (thanks to the rename of man files),
- # and it's clear from the sed invocations that all that changes is the
- # rmi{c,registry} names to grmi{c,registry} names.
- # Kevin F. Quinn 2006-07-12
- einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry."
- # 1) Move the man files if present (missing prior to gcc-3.4)
- for manfile in rmic rmiregistry ; do
- [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue
- mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1
- done
- # 2) Fixup references in the docs if present (mission prior to gcc-3.4)
- for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi ; do
- [[ -f ${S}/${jfile} ]] || continue
- sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
- die "Failed to fixup file ${jfile} for rename to grmiregistry"
- sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} ||
- die "Failed to fixup file ${jfile} for rename to grmic"
- done
- # 3) Fixup Makefiles to build the changed executable names
- # These are present in all 3.x versions, and are the important bit
- # to get gcc to build with the new names.
- for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in ; do
- sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
- die "Failed to fixup file ${jfile} for rename to grmiregistry"
- # Careful with rmic on these files; it's also the name of a directory
- # which should be left unchanged. Replace occurrences of 'rmic$',
- # 'rmic_' and 'rmic '.
- sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} ||
- die "Failed to fixup file ${jfile} for rename to grmic"
- done
-}
-
-#---->> src_configure <<----
-
-toolchain_src_configure() {
- downgrade_arch_flags
- gcc_do_filter_flags
-
- einfo "CFLAGS=\"${CFLAGS}\""
- einfo "CXXFLAGS=\"${CXXFLAGS}\""
- einfo "LDFLAGS=\"${LDFLAGS}\""
-
- # Force internal zip based jar script to avoid random
- # issues with 3rd party jar implementations. #384291
- export JAR=no
-
- # For hardened gcc 4.3 piepatchset to build the hardened specs
- # file (build.specs) to use when building gcc.
- if ! tc_version_is_at_least 4.4 && want_minispecs ; then
- setup_minispecs_gcc_build_specs
- fi
-
- local confgcc=( --host=${CHOST} )
-
- if is_crosscompile || tc-is-cross-compiler ; then
- # Straight from the GCC install doc:
- # "GCC has code to correctly determine the correct value for target
- # for nearly all native systems. Therefore, we highly recommend you
- # not provide a configure target when configuring a native compiler."
- confgcc+=( --target=${CTARGET} )
- fi
- [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
-
- confgcc+=(
- --prefix="${PREFIX}"
- --bindir="${BINPATH}"
- --includedir="${INCLUDEPATH}"
- --datadir="${DATAPATH}"
- --mandir="${DATAPATH}/man"
- --infodir="${DATAPATH}/info"
- --with-gxx-include-dir="${STDCXX_INCDIR}"
- )
-
- # Stick the python scripts in their own slotted directory (bug #279252)
- #
- # --with-python-dir=DIR
- # Specifies where to install the Python modules used for aot-compile. DIR
- # should not include the prefix used in installation. For example, if the
- # Python modules are to be installed in /usr/lib/python2.5/site-packages,
- # then --with-python-dir=/lib/python2.5/site-packages should be passed.
- #
- # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
- if tc_version_is_at_least 4.4 ; then
- confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
- fi
-
- ### language options
-
- local GCC_LANG="c"
- is_cxx && GCC_LANG+=",c++"
- is_d && GCC_LANG+=",d"
- is_gcj && GCC_LANG+=",java"
- is_go && GCC_LANG+=",go"
- is_jit && GCC_LANG+=",jit"
- if is_objc || is_objcxx ; then
- GCC_LANG+=",objc"
- if tc_version_is_at_least 4 ; then
- use objc-gc && confgcc+=( --enable-objc-gc )
- fi
- is_objcxx && GCC_LANG+=",obj-c++"
- fi
-
- # fortran support just got sillier! the lang value can be f77 for
- # fortran77, f95 for fortran95, or just plain old fortran for the
- # currently supported standard depending on gcc version.
- is_fortran && GCC_LANG+=",fortran"
- is_f77 && GCC_LANG+=",f77"
- is_f95 && GCC_LANG+=",f95"
-
- # We do NOT want 'ADA support' in here!
- # is_ada && GCC_LANG+=",ada"
-
- confgcc+=( --enable-languages=${GCC_LANG} )
-
- ### general options
-
- confgcc+=(
- --enable-obsolete
- --enable-secureplt
- --disable-werror
- --with-system-zlib
- )
-
- if use nls ; then
- confgcc+=( --enable-nls --without-included-gettext )
- else
- confgcc+=( --disable-nls )
- fi
-
- 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
- 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})}" )
- fi
-
- # Branding
- tc_version_is_at_least 4.3 && confgcc+=(
- --with-bugurl=https://bugs.gentoo.org/
- --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
- )
-
- # If we want hardened support with the newer piepatchset for >=gcc 4.4
- if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then
- confgcc+=( $(use_enable hardened esp) )
- fi
-
- # allow gcc to search for clock funcs in the main C lib.
- # if it can't find them, then tough cookies -- we aren't
- # going to link in -lrt to all C++ apps. #411681
- if tc_version_is_at_least 4.4 && is_cxx ; then
- confgcc+=( --enable-libstdcxx-time )
- fi
-
- # Build compiler using LTO
- if tc_version_is_at_least 9.1 && use_if_iuse lto ; then
- confgcc+=( --with-build-config=bootstrap-lto )
- fi
-
- # Support to disable pch when building libstdcxx
- if tc_version_is_at_least 6.0 && ! use_if_iuse pch ; then
- confgcc+=( --disable-libstdcxx-pch )
- 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
- # # This helps with locating debug files.
- # case ${CTARGET} in
- # *-linux-*|*-elf|*-eabi)
- # tc_version_is_at_least 4.5 && confgcc+=(
- # --enable-linker-build-id
- # )
- # ;;
- # esac
-
- # newer gcc versions like to bootstrap themselves with C++,
- # so we need to manually disable it ourselves
- if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
- confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
- fi
-
- ### Cross-compiler options
- if is_crosscompile ; then
- # Enable build warnings by default with cross-compilers when system
- # paths are included (e.g. via -I flags).
- confgcc+=( --enable-poison-system-directories )
-
- # When building a stage1 cross-compiler (just C compiler), we have to
- # disable a bunch of features or gcc goes boom
- local needed_libc=""
- case ${CTARGET} in
- *-linux) needed_libc=no-fucking-clue;;
- *-dietlibc) needed_libc=dietlibc;;
- *-elf|*-eabi)
- needed_libc=newlib
- # Bare-metal targets don't have access to clock_gettime()
- # arm-none-eabi example: bug #589672
- # But we explicitly do --enable-libstdcxx-time above.
- # Undoing it here.
- confgcc+=( --disable-libstdcxx-time )
- ;;
- *-freebsd*) needed_libc=freebsd-lib;;
- *-gnu*) needed_libc=glibc;;
- *-klibc) needed_libc=klibc;;
- *-musl*) needed_libc=musl;;
- *-uclibc*)
- if ! echo '#include <features.h>' | \
- $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
- grep -q __HAVE_SHARED__
- then #291870
- 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
- local confgcc_no_libc=( --disable-shared )
- tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
- if ! has_version ${CATEGORY}/${needed_libc} ; then
- confgcc+=(
- "${confgcc_no_libc[@]}"
- --disable-threads
- --without-headers
- )
- elif has_version "${CATEGORY}/${needed_libc}[headers-only(-)]" ; then
- confgcc+=(
- "${confgcc_no_libc[@]}"
- --with-sysroot="${PREFIX}"/${CTARGET}
- )
- else
- confgcc+=( --with-sysroot="${PREFIX}"/${CTARGET} )
- fi
- fi
-
- tc_version_is_at_least 4.2 && confgcc+=( --disable-bootstrap )
- else
- if tc-is-static-only ; then
- confgcc+=( --disable-shared )
- else
- confgcc+=( --enable-shared )
- fi
- case ${CHOST} in
- mingw*|*-mingw*)
- confgcc+=( --enable-threads=win32 ) ;;
- *)
- confgcc+=( --enable-threads=posix ) ;;
- esac
- fi
-
- # __cxa_atexit is "essential for fully standards-compliant handling of
- # destructors", but apparently requires glibc.
- case ${CTARGET} in
- *-uclibc*)
- confgcc+=(
- --disable-__cxa_atexit
- $(use_enable nptl tls)
- )
- tc_version_is_between 3.3 3.4 && confgcc+=( --enable-sjlj-exceptions )
- if tc_version_is_between 3.4 4.3 ; then
- confgcc+=( --enable-clocale=uclibc )
- fi
- ;;
- *-elf|*-eabi)
- confgcc+=( --with-newlib )
- ;;
- *-musl*)
- confgcc+=( --enable-__cxa_atexit )
- ;;
- *-gnu*)
- confgcc+=(
- --enable-__cxa_atexit
- --enable-clocale=gnu
- )
- ;;
- *-freebsd*)
- confgcc+=( --enable-__cxa_atexit )
- ;;
- *-solaris*)
- confgcc+=( --enable-__cxa_atexit )
- ;;
- esac
-
- ### arch options
-
- gcc-multilib-configure
-
- # ppc altivec support
- 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 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
-
- case $(tc-is-softfloat) in
- yes) confgcc+=( --with-float=soft ) ;;
- softfp) confgcc+=( --with-float=softfp ) ;;
- *)
- # If they've explicitly opt-ed in, do hardfloat,
- # otherwise let the gcc default kick in.
- case ${CTARGET//_/-} in
- *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
- esac
- esac
-
- local with_abi_map=()
- case $(tc-arch) in
- arm) #264534 #414395
- local a arm_arch=${CTARGET%%-*}
- # Remove trailing endian variations first: eb el be bl b l
- for a in e{b,l} {b,l}e b l ; do
- if [[ ${arm_arch} == *${a} ]] ; then
- arm_arch=${arm_arch%${a}}
- break
- fi
- done
- # Convert armv7{a,r,m} to armv7-{a,r,m}
- [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
- # See if this is a valid --with-arch flag
- if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
- . "${srcdir}"/config.gcc) &>/dev/null
- then
- confgcc+=( --with-arch=${arm_arch} )
- fi
-
- # Make default mode thumb for microcontroller classes #418209
- [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
-
- # Enable hardvfp
- if [[ $(tc-is-softfloat) == "no" ]] && \
- [[ ${CTARGET} == armv[67]* ]] && \
- tc_version_is_at_least 4.5
- then
- # Follow the new arm hardfp distro standard by default
- confgcc+=( --with-float=hard )
- case ${CTARGET} in
- armv6*) confgcc+=( --with-fpu=vfp ) ;;
- armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
- esac
- fi
- ;;
- mips)
- # Add --with-abi flags to set default ABI
- confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
- ;;
- amd64)
- # drop the older/ABI checks once this get's merged into some
- # version of gcc upstream
- if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
- confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
- fi
- ;;
- x86)
- # Default arch for x86 is normally i386, lets give it a bump
- # since glibc will do so based on CTARGET anyways
- confgcc+=( --with-arch=${CTARGET%%-*} )
- ;;
- hppa)
- # Enable sjlj exceptions for backward compatibility on hppa
- [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
- ;;
- ppc)
- # Set up defaults based on current CFLAGS
- is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
- [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
- ;;
- esac
-
- # if the target can do biarch (-m32/-m64), enable it. overhead should
- # be small, and should simplify building of 64bit kernels in a 32bit
- # userland by not needing sys-devel/kgcc64. #349405
- case $(tc-arch) in
- ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=( --enable-targets=all ) ;;
- sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
- amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
- esac
-
- # On Darwin we need libdir to be set in order to get correct install names
- # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
- # non-Darwin we screw up the behaviour this eclass relies on. We in
- # particular need this over --libdir for bug #255315.
- [[ ${CTARGET} == *-darwin* ]] && \
- confgcc+=( --enable-version-specific-runtime-libs )
-
- ### library options
-
- if tc_version_is_between 3.0 7.0 ; then
- if ! is_gcj ; then
- confgcc+=( --disable-libgcj )
- elif use awt ; then
- confgcc+=( --enable-java-awt=gtk )
- fi
- fi
-
- if tc_version_is_at_least 4.2 ; then
- if in_iuse openmp ; then
- # Make sure target has pthreads support. #326757 #335883
- # There shouldn't be a chicken & egg problem here as openmp won't
- # build without a C library, and you can't build that w/out
- # already having a compiler ...
- if ! is_crosscompile || \
- $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
- then
- confgcc+=( $(use_enable openmp libgomp) )
- else
- # Force disable as the configure script can be dumb #359855
- confgcc+=( --disable-libgomp )
- fi
- else
- # For gcc variants where we don't want openmp (e.g. kgcc)
- confgcc+=( --disable-libgomp )
- fi
- fi
-
- if tc_version_is_at_least 4.0 ; then
- if in_iuse mudflap ; then
- confgcc+=( $(use_enable mudflap libmudflap) )
- else
- confgcc+=( --disable-libmudflap )
- fi
-
- if use_if_iuse libssp ; then
- confgcc+=( --enable-libssp )
- else
- if hardened_gcc_is_stable ssp; then
- export gcc_cv_libc_provides_ssp=yes
- fi
- if 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
-
- if in_iuse cilk ; then
- confgcc+=( $(use_enable cilk libcilkrts) )
- fi
-
- if in_iuse mpx ; then
- 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)
- # See Note [implicitly enabled flags]
- $(usex vtv '' --disable-libvtv)
- )
- 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-libquadmath )
- fi
-
- if tc_version_is_at_least 4.6 ; then
- confgcc+=( --enable-lto )
- elif tc_version_is_at_least 4.5 ; then
- confgcc+=( --disable-lto )
- fi
-
- # graphite was added in 4.4 but we only support it in 4.8+ due to external
- # library issues. #448024
- 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 && 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 && in_iuse sanitize ; then
- # See Note [implicitly enabled flags]
- confgcc+=( $(usex sanitize '' --disable-libsanitizer) )
- fi
-
- 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+=(
- # This defaults to -fstack-protector-strong.
- $(use_enable ssp default-ssp)
- )
- fi
-
- # Disable gcc info regeneration -- it ships with generated info pages
- # already. Our custom version/urls/etc... trigger it. #464008
- export gcc_cv_prog_makeinfo_modern=no
-
- # Do not let the X detection get in our way. We know things can be found
- # via system paths, so no need to hardcode things that'll break multilib.
- # Older gcc versions will detect ac_x_libraries=/usr/lib64 which ends up
- # killing the 32bit builds which want /usr/lib.
- export ac_cv_have_x='have_x=yes ac_x_includes= ac_x_libraries='
-
- confgcc+=( "$@" ${EXTRA_ECONF} )
-
- # Nothing wrong with a good dose of verbosity
- echo
- einfo "PREFIX: ${PREFIX}"
- einfo "BINPATH: ${BINPATH}"
- einfo "LIBPATH: ${LIBPATH}"
- einfo "DATAPATH: ${DATAPATH}"
- einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
- echo
- einfo "Languages: ${GCC_LANG}"
- echo
- einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}"
- echo
-
- # Build in a separate build tree
- mkdir -p "${WORKDIR}"/build
- pushd "${WORKDIR}"/build > /dev/null
-
- # and now to do the actual configuration
- addwrite /dev/zero
- echo "${S}"/configure "${confgcc[@]}"
- # Older gcc versions did not detect bash and re-exec itself, so force the
- # use of bash. Newer ones will auto-detect, but this is not harmful.
- CONFIG_SHELL="${EPREFIX}/bin/bash" \
- bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
-
- # return to whatever directory we were in before
- popd > /dev/null
-}
-
-# Replace -m flags unsupported by the version being built with the best
-# available equivalent
-downgrade_arch_flags() {
- local arch bver i isa myarch mytune rep ver
-
- bver=${1:-${GCC_BRANCH_VER}}
- [[ $(gcc-version) < ${bver} ]] && return 0
- [[ $(tc-arch) != amd64 && $(tc-arch) != x86 ]] && return 0
-
- myarch=$(get-flag march)
- mytune=$(get-flag mtune)
-
- # If -march=native isn't supported we have to tease out the actual arch
- if [[ ${myarch} == native || ${mytune} == native ]] ; then
- if [[ ${bver} < 4.2 ]] ; then
- arch=$($(tc-getCC) -march=native -v -E -P - </dev/null 2>&1 \
- | sed -rn "/cc1.*-march/s:.*-march=([^ ']*).*:\1:p")
- replace-cpu-flags native ${arch}
- fi
- fi
-
- # Handle special -mtune flags
- [[ ${mytune} == intel && ${bver} < 4.9 ]] && replace-cpu-flags intel generic
- [[ ${mytune} == generic && ${bver} < 4.2 ]] && filter-flags '-mtune=*'
- [[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
- [[ ${bver} < 3.4 ]] && filter-flags '-mtune=*'
-
- # "added" "arch" "replacement"
- local archlist=(
- 4.9 bdver4 bdver3
- 4.9 bonnell atom
- 4.9 broadwell core-avx2
- 4.9 haswell core-avx2
- 4.9 ivybridge core-avx-i
- 4.9 nehalem corei7
- 4.9 sandybridge corei7-avx
- 4.9 silvermont corei7
- 4.9 westmere corei7
- 4.8 bdver3 bdver2
- 4.8 btver2 btver1
- 4.7 bdver2 bdver1
- 4.7 core-avx2 core-avx-i
- 4.6 bdver1 amdfam10
- 4.6 btver1 amdfam10
- 4.6 core-avx-i core2
- 4.6 corei7 core2
- 4.6 corei7-avx core2
- 4.5 atom core2
- 4.3 amdfam10 k8
- 4.3 athlon64-sse3 k8
- 4.3 barcelona k8
- 4.3 core2 nocona
- 4.3 geode k6-2 # gcc.gnu.org/PR41989#c22
- 4.3 k8-sse3 k8
- 4.3 opteron-sse3 k8
- 3.4 athlon-fx x86-64
- 3.4 athlon64 x86-64
- 3.4 c3-2 c3
- 3.4 k8 x86-64
- 3.4 opteron x86-64
- 3.4 pentium-m pentium3
- 3.4 pentium3m pentium3
- 3.4 pentium4m pentium4
- )
-
- for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do
- myarch=$(get-flag march)
- mytune=$(get-flag mtune)
-
- ver=${archlist[i]}
- arch=${archlist[i + 1]}
- rep=${archlist[i + 2]}
-
- [[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue
-
- if [[ ${ver} > ${bver} ]] ; then
- einfo "Replacing ${myarch} (added in gcc ${ver}) with ${rep}..."
- [[ ${myarch} == ${arch} ]] && replace-cpu-flags ${myarch} ${rep}
- [[ ${mytune} == ${arch} ]] && replace-cpu-flags ${mytune} ${rep}
- continue
- else
- break
- fi
- done
-
- # we only check -mno* here since -m* get removed by strip-flags later on
- local isalist=(
- 4.9 -mno-sha
- 4.9 -mno-avx512pf
- 4.9 -mno-avx512f
- 4.9 -mno-avx512er
- 4.9 -mno-avx512cd
- 4.8 -mno-xsaveopt
- 4.8 -mno-xsave
- 4.8 -mno-rtm
- 4.8 -mno-fxsr
- 4.7 -mno-lzcnt
- 4.7 -mno-bmi2
- 4.7 -mno-avx2
- 4.6 -mno-tbm
- 4.6 -mno-rdrnd
- 4.6 -mno-fsgsbase
- 4.6 -mno-f16c
- 4.6 -mno-bmi
- 4.5 -mno-xop
- 4.5 -mno-movbe
- 4.5 -mno-lwp
- 4.5 -mno-fma4
- 4.4 -mno-pclmul
- 4.4 -mno-fma
- 4.4 -mno-avx
- 4.4 -mno-aes
- 4.3 -mno-ssse3
- 4.3 -mno-sse4a
- 4.3 -mno-sse4
- 4.3 -mno-sse4.2
- 4.3 -mno-sse4.1
- 4.3 -mno-popcnt
- 4.3 -mno-abm
- )
-
- for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do
- ver=${isalist[i]}
- isa=${isalist[i + 1]}
- [[ ${ver} > ${bver} ]] && filter-flags ${isa} ${isa/-m/-mno-}
- done
-}
-
-gcc_do_filter_flags() {
- strip-flags
- replace-flags -O? -O2
-
- # dont want to funk ourselves
- filter-flags '-mabi*' -m31 -m32 -m64
-
- filter-flags -frecord-gcc-switches # 490738
- filter-flags -mno-rtm -mno-htm # 506202
-
- if tc_version_is_between 3.2 3.4 ; then
- # XXX: this is so outdated it's barely useful, but it don't hurt...
- replace-cpu-flags G3 750
- replace-cpu-flags G4 7400
- replace-cpu-flags G5 7400
-
- # XXX: should add a sed or something to query all supported flags
- # from the gcc source and trim everything else ...
- filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
- filter-flags -f{no-,}stack-protector{,-all}
- filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
- # and warning options
- filter-flags -Wextra -Wstack-protector
- fi
- if ! tc_version_is_at_least 4.1 ; then
- filter-flags -fdiagnostics-show-option
- filter-flags -Wstack-protector
- fi
-
- if tc_version_is_at_least 3.4 ; then
- case $(tc-arch) in
- amd64|x86)
- filter-flags '-mcpu=*'
-
- tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287
-
- if tc_version_is_between 4.6 4.7 ; then
- # https://bugs.gentoo.org/411333
- # https://bugs.gentoo.org/466454
- replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
- fi
- ;;
- alpha)
- # https://bugs.gentoo.org/454426
- append-ldflags -Wl,--no-relax
- ;;
- sparc)
- # temporary workaround for random ICEs reproduced by multiple users
- # https://bugs.gentoo.org/457062
- tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
- ;;
- *-macos)
- # http://gcc.gnu.org/PR25127
- tc_version_is_between 4.0 4.2 && \
- filter-flags '-mcpu=*' '-march=*' '-mtune=*'
- ;;
- esac
- fi
-
- strip-unsupported-flags
-
- # these are set here so we have something sane at configure time
- if is_crosscompile ; then
- # Set this to something sane for both native and target
- CFLAGS="-O2 -pipe"
- FFLAGS=${CFLAGS}
- FCFLAGS=${CFLAGS}
-
- # "hppa2.0-unknown-linux-gnu" -> hppa2_0_unknown_linux_gnu
- local VAR="CFLAGS_"${CTARGET//[-.]/_}
- CXXFLAGS=${!VAR-${CFLAGS}}
- fi
-
- export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
-}
-
-setup_minispecs_gcc_build_specs() {
- # Setup the "build.specs" file for gcc 4.3 to use when building.
- if hardened_gcc_works pie ; then
- cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
- fi
- if hardened_gcc_works ssp ; then
- for s in ssp sspall ; do
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
- done
- fi
- for s in nostrict znow ; do
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
- done
- export GCC_SPECS="${WORKDIR}"/build.specs
-}
-
-gcc-multilib-configure() {
- if ! is_multilib ; then
- confgcc+=( --disable-multilib )
- # Fun times: if we are building for a target that has multiple
- # possible ABI formats, and the user has told us to pick one
- # that isn't the default, then not specifying it via the list
- # below will break that on us.
- else
- confgcc+=( --enable-multilib )
- fi
-
- # translate our notion of multilibs into gcc's
- local abi list
- for abi in $(get_all_abis TARGET) ; do
- local l=$(gcc-abi-map ${abi})
- [[ -n ${l} ]] && list+=",${l}"
- done
- if [[ -n ${list} ]] ; then
- case ${CTARGET} in
- x86_64*)
- tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} )
- ;;
- esac
- fi
-}
-
-gcc-abi-map() {
- # Convert the ABI name we use in Gentoo to what gcc uses
- local map=()
- case ${CTARGET} in
- mips*) map=("o32 32" "n32 n32" "n64 64") ;;
- x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
- esac
-
- local m
- for m in "${map[@]}" ; do
- l=( ${m} )
- [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
- done
-}
-
-#----> src_compile <----
-
-toolchain_src_compile() {
- touch "${S}"/gcc/c-gperf.h
-
- # Do not make manpages if we do not have perl ...
- [[ ! -x /usr/bin/perl ]] \
- && find "${WORKDIR}"/build -name '*.[17]' -exec touch {} +
-
- # Older gcc versions did not detect bash and re-exec itself, so force the
- # use of bash. Newer ones will auto-detect, but this is not harmful.
- # This needs to be set for compile as well, as it's used in libtool
- # generation, which will break install otherwise (at least in 3.3.6): #664486
- CONFIG_SHELL="${EPREFIX}/bin/bash" \
- gcc_do_make ${GCC_MAKE_TARGET}
-}
-
-gcc_do_make() {
- # This function accepts one optional argument, the make target to be used.
- # If omitted, gcc_do_make will try to guess whether it should use all,
- # or bootstrap-lean depending on CTARGET and arch.
- # An example of how to use this function:
- #
- # gcc_do_make all-target-libstdc++-v3
-
- [[ -n ${1} ]] && GCC_MAKE_TARGET=${1}
-
- # default target
- if is_crosscompile || tc-is-cross-compiler ; then
- # 3 stage bootstrapping doesnt quite work when you cant run the
- # resulting binaries natively ^^;
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
- else
- 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}
- fi
- fi
-
- # Older versions of GCC could not do profiledbootstrap in parallel due to
- # collisions with profiling info.
- # boundschecking also seems to introduce parallel build issues.
- if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] || use_if_iuse boundschecking ; then
- ! tc_version_is_at_least 4.6 && export MAKEOPTS="${MAKEOPTS} -j1"
- fi
-
- if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
- elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
- # See bug #79852
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
- fi
-
- if is_crosscompile; then
- # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
- # but I'll leave this in anyways as someone might have had
- # some reason for putting it in here... --eradicator
- BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
- else
- # we only want to use the system's CFLAGS if not building a
- # cross-compiler.
- BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
- fi
-
- einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
-
- pushd "${WORKDIR}"/build >/dev/null
-
- emake \
- LDFLAGS="${LDFLAGS}" \
- STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
- LIBPATH="${LIBPATH}" \
- BOOT_CFLAGS="${BOOT_CFLAGS}" \
- ${GCC_MAKE_TARGET} \
- || die "emake failed with ${GCC_MAKE_TARGET}"
-
- 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
- emake doc-man-doxygen || ewarn "failed to make docs"
- elif tc_version_is_at_least 3.0 ; then
- cd "${CTARGET}"/libstdc++-v3
- emake doxygen-man || ewarn "failed to make docs"
- fi
- # Clean bogus manpages. #113902
- find -name '*_build_*' -delete
- # Blow away generated directory references. Newer versions of gcc
- # have gotten better at this, but not perfect. This is easier than
- # backporting all of the various doxygen patches. #486754
- find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
- xargs rm -f
- else
- ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
- fi
- fi
-
- popd >/dev/null
-}
-
-#---->> 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
-}
-
-#---->> src_install <<----
-
-toolchain_src_install() {
- cd "${WORKDIR}"/build
-
- # Do 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
- # build system only expects to install out of the build dir, not the source. #464008
- mkdir -p gcc/doc
- local x=
- for x in "${S}"/gcc/doc/*.info* ; do
- if [[ -f ${x} ]] ; then
- cp "${x}" gcc/doc/ || die
- fi
- done
-
- # We remove the generated fixincludes, as they can cause things to break
- # (ncurses, openssl, etc). We do not prevent them from being built, as
- # in the following commit which we revert:
- # https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
- # This is because bsd userland needs fixedincludes to build gcc, while
- # linux does not. Both can dispose of them afterwards.
- while read x ; do
- grep -q 'It has been auto-edited by fixincludes from' "${x}" \
- && rm -f "${x}"
- done < <(find gcc/include*/ -name '*.h')
-
- # Do the 'make install' from the build directory
- S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
-
- # Punt some tools which are really only useful while building gcc
- find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
- # This one comes with binutils
- find "${ED}" -name libiberty.a -delete
-
- # Move the libraries to the proper location
- gcc_movelibs
-
- # Basic sanity check
- if ! is_crosscompile ; then
- local EXEEXT
- eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
- [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
- fi
-
- dodir /etc/env.d/gcc
- create_gcc_env_entry
-
- # Setup the gcc_env_entry for hardened gcc 4 with minispecs
- want_minispecs && copy_minispecs_gcc_specs
-
- # Make sure we dont have stuff lying around that
- # can nuke multiple versions of gcc
- gcc_slot_java
-
- dodir /usr/bin
- 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 some reason, g77 gets made instead of ${CTARGET}-g77...
- # this should take care of that
- if [[ -f ${x} ]] ; then
- # In case they're hardlinks, clear out the target first
- # otherwise the mv below will complain.
- rm -f ${CTARGET}-${x}
- mv ${x} ${CTARGET}-${x}
- fi
-
- if [[ -f ${CTARGET}-${x} ]] ; then
- if ! is_crosscompile ; then
- ln -sf ${CTARGET}-${x} ${x}
- dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
- /usr/bin/${x}-${GCC_CONFIG_VER}
- fi
- # Create versioned symlinks
- dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
- /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
- fi
-
- if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
- rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
- ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
- fi
- done
-
- # When gcc builds a crosscompiler it does not install unprefixed tools.
- # When cross-building gcc does install native tools.
- if ! is_crosscompile; then
- # Rename the main go binaries as we don't want to clobber dev-lang/go
- # when gcc-config runs. #567806
- if tc_version_is_at_least 5 && is_go ; then
- for x in go gofmt; do
- mv ${x} ${x}-${GCCMAJOR} || die
- done
- 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:
- # Using ${CHOST} tools:
- # - "${D}${BINPATH}"
- # - (for is_crosscompile) "${D}${HOSTLIBPATH}"
- # - "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
- # Using ${CTARGET} tools:
- # - "${D}${LIBPATH}"
-
- cd "${S}"
- if is_crosscompile; then
- rm -rf "${ED}"/usr/share/{man,info}
- rm -rf "${D}"${DATAPATH}/{man,info}
- else
- if tc_version_is_at_least 3.0 ; then
- local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
- if [[ -d ${cxx_mandir} ]] ; then
- cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
- fi
- fi
- fi
-
- # portage regenerates 'dir' files on it's own: bug #672408
- # Drop 'dir' files to avoid collisions.
- if [[ -f "${D}${DATAPATH}"/info/dir ]]; then
- einfo "Deleting '${D}${DATAPATH}/info/dir'"
- rm "${D}${DATAPATH}"/info/dir || die
- fi
-
- # prune empty dirs left behind
- 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
- insinto "${DATAPATH#${EPREFIX}}"
- newins "$(prefixify_ro "${FILESDIR}"/awk/fixlafiles.awk-no_gcc_la)" fixlafiles.awk || die
- exeinto "${DATAPATH#${EPREFIX}}"
- doexe "$(prefixify_ro "${FILESDIR}"/fix_libtool_files.sh)" || die
- doexe "${FILESDIR}"/c{89,99} || die
- fi
-
- # libstdc++.la: Delete as it doesn't add anything useful: g++ itself
- # handles linkage correctly in the dynamic & static case. It also just
- # causes us pain: any C++ progs/libs linking with libtool will gain a
- # reference to the full libstdc++.la file which is gcc version specific.
- # libstdc++fs.la: It doesn't link against anything useful.
- # 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.
- # libgfortran.la: gfortran itself handles linkage correctly in the
- # dynamic & static case (libgfortran.spec). #573302
- # libgfortranbegin.la: Same as above, and it's an internal lib.
- # libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
- # libmpxwrappers.la: See above.
- # libitm.la: gcc itself handles linkage correctly (libitm.spec).
- # libvtv.la: gcc itself handles linkage correctly.
- # lib*san.la: Sanitizer linkage is handled internally by gcc, and they
- # do not support static linking. #487550 #546700
- find "${D}${LIBPATH}" \
- '(' \
- -name libstdc++.la -o \
- -name libstdc++fs.la -o \
- -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 \
- -name libgfortranbegin.la -o \
- -name libmpx.la -o \
- -name libmpxwrappers.la -o \
- -name libitm.la -o \
- -name libvtv.la -o \
- -name 'lib*san.la' \
- ')' -type f -delete
-
- # Use gid of 0 because some stupid ports don't have
- # the group 'root' set to gid 0. Send to /dev/null
- # for people who are testing as non-root.
- chown -R root:0 "${D}${LIBPATH}" 2>/dev/null
-
- # Move pretty-printers to gdb datadir to shut ldconfig up
- 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
- local multidir=${py%/*}
- insinto "${gdbdir}/${multidir}"
- sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
- doins "${py}" || die
- rm "${py}" || die
- done
- popd >/dev/null
-
- # Don't scan .gox files for executable stacks - false positives
- export QA_EXECSTACK="usr/lib*/go/*/*.gox"
- export QA_WX_LOAD="usr/lib*/go/*/*.gox"
-
- # Disable RANDMMAP so PCH works. #301299
- if tc_version_is_at_least 4.3 ; then
- pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
- pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
- fi
-
- # Disable MPROTECT so java works. #574808
- if is_gcj ; then
- pax-mark -m "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
- pax-mark -m "${D}${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
- fi
-}
-
-# Move around the libs to the right location. For some reason,
-# when installing gcc, it dumps internal libraries into /usr/lib
-# instead of the private gcc lib path
-gcc_movelibs() {
- # older versions of gcc did not support --print-multi-os-directory
- tc_version_is_at_least 3.2 || return 0
-
- # For non-target libs which are for CHOST and not CTARGET, we want to
- # move them to the compiler-specific CHOST internal dir. This is stuff
- # that you want to link against when building tools rather than building
- # code to run on the target.
- if tc_version_is_at_least 5 && is_crosscompile ; then
- dodir "${HOSTLIBPATH#${EPREFIX}}"
- mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
- fi
-
- # For all the libs that are built for CTARGET, move them into the
- # compiler-specific CTARGET internal dir.
- local x multiarg removedirs=""
- for multiarg in $($(XGCC) -print-multi-lib) ; do
- multiarg=${multiarg#*;}
- multiarg=${multiarg//@/ -}
-
- local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
- local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
- local TODIR="${D}${LIBPATH}"/${MULTIDIR}
- local FROMDIR=
-
- [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
-
- for FROMDIR in \
- "${LIBPATH}"/${OS_MULTIDIR} \
- "${LIBPATH}"/../${MULTIDIR} \
- "${PREFIX}"/lib/${OS_MULTIDIR} \
- "${PREFIX}"/${CTARGET}/lib/${OS_MULTIDIR}
- do
- removedirs="${removedirs} ${FROMDIR}"
- FROMDIR=${D}${FROMDIR}
- if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
- local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
- if [[ -n ${files} ]] ; then
- mv ${files} "${TODIR}" || die
- fi
- fi
- done
- fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
-
- # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
- FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
- for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
- [[ -f ${x} ]] || continue
- sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}" || die
- mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
- done
- done
-
- # We remove directories separately to avoid this case:
- # mv SRC/lib/../lib/*.o DEST
- # rmdir SRC/lib/../lib/
- # mv SRC/lib/../lib32/*.o DEST # Bork
- for FROMDIR in ${removedirs} ; do
- rmdir "${D}"${FROMDIR} >& /dev/null
- done
- find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
-}
-
-# make sure the libtool archives have libdir set to where they actually
-# -are-, and not where they -used- to be. also, any dependencies we have
-# on our own .la files need to be updated.
-fix_libtool_libdir_paths() {
- local libpath="$1"
-
- pushd "${D}" >/dev/null
-
- pushd "./${libpath}" >/dev/null
- local dir="${PWD#${D%/}}"
- local allarchives=$(echo *.la)
- allarchives="\(${allarchives// /\\|}\)"
- popd >/dev/null
-
- # The libdir might not have any .la files. #548782
- find "./${dir}" -maxdepth 1 -name '*.la' \
- -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
- # Would be nice to combine these, but -maxdepth can not be specified
- # on sub-expressions.
- find "./${PREFIX}"/lib* -maxdepth 3 -name '*.la' \
- -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
- find "./${dir}/" -maxdepth 1 -name '*.la' \
- -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
-
- popd >/dev/null
-}
-
-create_gcc_env_entry() {
- dodir /etc/env.d/gcc
- local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
-
- local gcc_specs_file
- local gcc_envd_file="${ED}${gcc_envd_base}"
- if [[ -z $1 ]] ; then
- # I'm leaving the following commented out to remind me that it
- # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
- # on chroot or in non-toolchain.eclass gcc ebuilds!
- #gcc_specs_file="${LIBPATH}/specs"
- gcc_specs_file=""
- else
- gcc_envd_file+="-$1"
- gcc_specs_file="${LIBPATH}/$1.specs"
- fi
-
- # We want to list the default ABI's LIBPATH first so libtool
- # searches that directory first. This is a temporary
- # workaround for libtool being stupid and using .la's from
- # conflicting ABIs by using the first one in the search path
- local ldpaths mosdirs
- if tc_version_is_at_least 3.2 ; then
- local mdir mosdir abi ldpath
- for abi in $(get_all_abis TARGET) ; do
- mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
- ldpath=${LIBPATH}
- [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
- ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
-
- mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
- mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
- done
- else
- # Older gcc's didn't do multilib, so logic is simple.
- ldpaths=${LIBPATH}
- fi
-
- cat <<-EOF > ${gcc_envd_file}
- PATH="${BINPATH}"
- ROOTPATH="${BINPATH}"
- GCC_PATH="${BINPATH}"
- LDPATH="${ldpaths}"
- MANPATH="${DATAPATH}/man"
- INFOPATH="${DATAPATH}/info"
- STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
- CTARGET="${CTARGET}"
- GCC_SPECS="${gcc_specs_file}"
- MULTIOSDIRS="${mosdirs}"
- EOF
-}
-
-copy_minispecs_gcc_specs() {
- # on gcc 6 we don't need minispecs
- if tc_version_is_at_least 6.0 ; then
- return 0
- fi
-
- # setup the hardenedno* specs files and the vanilla specs file.
- if hardened_gcc_works ; then
- create_gcc_env_entry hardenednopiessp
- fi
- if hardened_gcc_works pie ; then
- create_gcc_env_entry hardenednopie
- fi
- if hardened_gcc_works ssp ; then
- create_gcc_env_entry hardenednossp
- fi
- create_gcc_env_entry vanilla
- insinto ${LIBPATH#${EPREFIX}}
- doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
- # Build system specs file which, if it exists, must be a complete set of
- # specs as it completely and unconditionally overrides the builtin specs.
- if ! tc_version_is_at_least 4.4 ; then
- $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
- cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
- doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
- fi
-}
-
-gcc_slot_java() {
- local x
-
- # Move Java headers to compiler-specific dir
- for x in "${D}${PREFIX}"/include/gc*.h "${D}${PREFIX}"/include/j*.h ; do
- [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/include/
- done
- for x in gcj gnu java javax org ; do
- if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
- dodir /${LIBPATH#${EPREFIX}}/include/${x}
- mv -f "${D}${PREFIX}"/include/${x}/* "${D}${LIBPATH}"/include/${x}/
- rm -rf "${D}${PREFIX}"/include/${x}
- fi
- done
-
- if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
- dodir /${LIBPATH#${EPREFIX}}/security
- mv -f "${D}${PREFIX}"/lib*/security/* "${D}${LIBPATH}"/security
- rm -rf "${D}${PREFIX}"/lib*/security
- fi
-
- # Move random gcj files to compiler-specific directories
- for x in libgcj.spec logging.properties ; do
- x="${D}${PREFIX}/lib/${x}"
- [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/
- done
-
- # Rename jar because it could clash with Kaffe's jar if this gcc is
- # primary compiler (aka don't have the -<version> extension)
- cd "${D}${BINPATH}"
- [[ -f jar ]] && mv -f jar gcj-jar
-}
-
-#---->> pkg_post* <<----
-
-toolchain_pkg_postinst() {
- do_gcc_config
- if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
- eselect compiler-shadow update all
- fi
-
- 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."
- echo
- ewarn "You might want to review the GCC upgrade guide when moving between"
- ewarn "major versions (like 4.2 to 4.3):"
- ewarn "https://wiki.gentoo.org/wiki/Upgrading_GCC"
- echo
-
- # Clean up old paths
- rm -f "${EROOT%/}"/*/rcscripts/awk/fixlafiles.awk "${EROOT%/}"/sbin/fix_libtool_files.sh
- rmdir "${EROOT%/}"/*/rcscripts{/awk,} 2>/dev/null
-
- 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
-
- # 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
- 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() {
- if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
- eselect compiler-shadow clean all
- fi
-
- # to make our lives easier (and saner), we do the fix_libtool stuff here.
- # rather than checking SLOT's and trying in upgrade paths, we just see if
- # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
- # unmerging. if it does, that means this was a simple re-emerge.
-
- # 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
- rm -f "${EROOT%/}"/etc/env.d/gcc/config-${CTARGET}
- rm -f "${EROOT%/}"/etc/env.d/??gcc-${CTARGET}
- rm -f "${EROOT%/}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
- fi
- return 0
- fi
-
- # ROOT isnt handled by the script
- [[ ${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
-}
-
-do_gcc_config() {
- if ! should_we_gcc_config ; then
- gcc-config --use-old --force
- return 0
- fi
-
- local current_gcc_config target
-
- current_gcc_config=$(gcc-config -c ${CTARGET} 2>/dev/null)
- if [[ -n ${current_gcc_config} ]] ; then
- local current_specs use_specs
- # figure out which specs-specific config is active
- current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
- [[ -n ${current_specs} ]] && use_specs=-${current_specs}
-
- if [[ -n ${use_specs} ]] && \
- [[ ! -e ${EROOT%/}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
- then
- ewarn "The currently selected specs-specific gcc config,"
- ewarn "${current_specs}, doesn't exist anymore. This is usually"
- ewarn "due to enabling/disabling hardened or switching to a version"
- ewarn "of gcc that doesnt create multiple specs files. The default"
- ewarn "config will be used, and the previous preference forgotten."
- use_specs=""
- fi
-
- target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
- else
- # The curent target is invalid. Attempt to switch to a valid one.
- # Blindly pick the latest version. #529608
- # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
- # doing a partial grep like this.
- target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
- fi
-
- gcc-config "${target}"
-}
-
-should_we_gcc_config() {
- # if the current config is invalid, we definitely want a new one
- # Note: due to bash quirkiness, the following must not be 1 line
- local curr_config
- curr_config=$(gcc-config -c ${CTARGET} 2>&1) || return 0
-
- # if the previously selected config has the same major.minor (branch) as
- # the version we are installing, then it will probably be uninstalled
- # for being in the same SLOT, make sure we run gcc-config.
- local curr_config_ver=$(gcc-config -S ${curr_config} | awk '{print $2}')
-
- local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver})
-
- if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
- return 0
- else
- # if we're installing a genuinely different compiler version,
- # we should probably tell the user -how- to switch to the new
- # gcc version, since we're not going to do it for him/her.
- # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
- # the middle of an emerge operation (like an 'emerge -e world'
- # which could install multiple gcc versions).
- # Only warn if we're installing a pkg as we might be called from
- # the pkg_{pre,post}rm steps. #446830
- if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
- einfo "The current gcc config appears valid, so it will not be"
- einfo "automatically switched for you. If you would like to"
- einfo "switch to the newly installed gcc version, do the"
- einfo "following:"
- echo
- einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
- einfo "source /etc/profile"
- echo
- fi
- return 1
- fi
-}
-
-#---->> support and misc functions <<----
-
-# This is to make sure we don't accidentally try to enable support for a
-# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
-#
-# Also add a hook so special ebuilds (kgcc64) can control which languages
-# exactly get enabled
-gcc-lang-supported() {
- grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
- [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
- has $1 ${TOOLCHAIN_ALLOWED_LANGS}
-}
-
-is_ada() {
- gcc-lang-supported ada || return 1
- use_if_iuse ada
-}
-
-is_cxx() {
- gcc-lang-supported 'c++' || return 1
- ! is_crosscompile && tc_version_is_at_least 4.8 && return 0
- use_if_iuse cxx
-}
-
-is_d() {
- gcc-lang-supported d || return 1
- use_if_iuse d
-}
-
-is_f77() {
- gcc-lang-supported f77 || return 1
- use_if_iuse fortran
-}
-
-is_f95() {
- gcc-lang-supported f95 || return 1
- use_if_iuse fortran
-}
-
-is_fortran() {
- gcc-lang-supported fortran || return 1
- use_if_iuse fortran
-}
-
-is_gcj() {
- gcc-lang-supported java || return 1
- use_if_iuse cxx && use_if_iuse gcj
-}
-
-is_go() {
- gcc-lang-supported go || return 1
- use_if_iuse cxx && use_if_iuse go
-}
-
-is_jit() {
- gcc-lang-supported jit || return 1
- # cross-compiler does not really support jit as it has
- # to generate code for a target. On target like avr
- # libgcclit.so can't link at all: bug #594572
- is_crosscompile && return 1
- use_if_iuse jit
-}
-
-is_multilib() {
- tc_version_is_at_least 3 || return 1
- use_if_iuse multilib
-}
-
-is_objc() {
- gcc-lang-supported objc || return 1
- use_if_iuse objc
-}
-
-is_objcxx() {
- gcc-lang-supported 'obj-c++' || return 1
- use_if_iuse cxx && use_if_iuse objc++
-}
-
-# Grab a variable from the build system (taken from linux-info.eclass)
-get_make_var() {
- local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
- echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
- r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
-}
-
-XGCC() { get_make_var GCC_FOR_TARGET ; }
-
-# The gentoo piessp patches allow for 3 configurations:
-# 1) PIE+SSP by default
-# 2) PIE by default
-# 3) SSP by default
-hardened_gcc_works() {
- if [[ $1 == "pie" ]] ; then
- # $gcc_cv_ld_pie is unreliable as it simply take the output of
- # `ld --help | grep -- -pie`, that reports the option in all cases, also if
- # the loader doesn't actually load the resulting executables.
- # To avoid breakage, blacklist FreeBSD here at least
- [[ ${CTARGET} == *-freebsd* ]] && return 1
-
- want_pie || return 1
- use_if_iuse nopie && return 1
- hardened_gcc_is_stable pie
- return $?
- elif [[ $1 == "ssp" ]] ; then
- [[ -n ${SPECS_VER} ]] || return 1
- use_if_iuse nossp && return 1
- hardened_gcc_is_stable ssp
- return $?
- else
- # laziness ;)
- hardened_gcc_works pie || return 1
- hardened_gcc_works ssp || return 1
- return 0
- fi
-}
-
-hardened_gcc_is_stable() {
- local tocheck
- if [[ $1 == "pie" ]] ; then
- if [[ ${CTARGET} == *-uclibc* ]] ; then
- tocheck=${PIE_UCLIBC_STABLE}
- elif [[ ${CTARGET} == *-musl* ]] ; then
- tocheck=${PIE_MUSL_STABLE}
- elif [[ ${CTARGET} == *-gnu* ]] ; then
- tocheck=${PIE_GLIBC_STABLE}
- fi
- elif [[ $1 == "ssp" ]] ; then
- if [[ ${CTARGET} == *-uclibc* ]] ; then
- tocheck=${SSP_UCLIBC_STABLE}
- elif [[ ${CTARGET} == *-musl* ]] ; then
- tocheck=${SSP_MUSL_STABLE}
- elif [[ ${CTARGET} == *-gnu* ]] ; then
- tocheck=${SSP_STABLE}
- fi
- else
- die "hardened_gcc_stable needs to be called with pie or ssp"
- fi
-
- has $(tc-arch) ${tocheck} && return 0
- return 1
-}
-
-want_minispecs() {
- # on gcc 6 we don't need minispecs
- if tc_version_is_at_least 6.0 ; then
- return 0
- fi
- if tc_version_is_at_least 4.3.2 && 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_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."
- else
- return 0
- fi
- ewarn "Hope you know what you are doing. Hardened will not work."
- return 0
- fi
- return 1
-}
-
-want_pie() {
- ! 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_if_iuse nopie || return 0
- return 1
-}
-
-has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
-toolchain_death_notice() {
- if [[ -e "${WORKDIR}"/build ]] ; then
- pushd "${WORKDIR}"/build >/dev/null
- (echo '' | $(tc-getCC ${CTARGET}) ${CFLAGS} -v -E - 2>&1) > gccinfo.log
- [[ -e "${T}"/build.log ]] && cp "${T}"/build.log .
- tar jcf "${WORKDIR}"/gcc-build-logs.tar.bz2 \
- gccinfo.log build.log $(find -name config.log)
- rm gccinfo.log build.log
- eerror
- eerror "Please include ${WORKDIR}/gcc-build-logs.tar.bz2 in your bug report."
- eerror
- popd >/dev/null
- fi
-}
-
-# Note [implicitly enabled flags]
-# -------------------------------
-# Usually configure-based packages handle explicit feature requests
-# like
-# ./configure --enable-foo
-# as explicit request to check for support of 'foo' and bail out at
-# configure time.
-#
-# GCC does not follow this pattern and instead overrides autodetection
-# of the feature and enables it unconditionally.
-# See bugs:
-# https://gcc.gnu.org/PR85663 (libsanitizer on mips)
-# https://bugs.gentoo.org/661252 (libvtv on powerpc64)
-#
-# Thus safer way to enable/disable the feature is to rely on implicit
-# enabled-by-default state:
-# econf $(usex foo '' --disable-foo)
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2019-05-20 21:04 Jory Pratt
0 siblings, 0 replies; 24+ messages in thread
From: Jory Pratt @ 2019-05-20 21:04 UTC (permalink / raw
To: gentoo-commits
commit: 29f0b3ce320c2740853d83cbef6ba1037ffedddf
Author: Jory Pratt <anarchy <AT> gentoo <DOT> org>
AuthorDate: Mon May 20 21:03:57 2019 +0000
Commit: Jory Pratt <anarchy <AT> gentoo <DOT> org>
CommitDate: Mon May 20 21:04:33 2019 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=29f0b3ce
eclass: sync 9.1 gcc changes from tree to overlay
eclass/toolchain.eclass | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 970d2c8..91297c0 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -174,6 +174,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
tc_version_is_at_least 8.0 &&
IUSE+=" systemtap" TC_FEATURES+=(systemtap)
tc_version_is_at_least 9.0 && IUSE+=" d"
+ tc_version_is_at_least 9.1 && IUSE+=" lto"
fi
SLOT="${GCC_CONFIG_VER}"
@@ -993,6 +994,11 @@ toolchain_src_configure() {
confgcc+=( --enable-libstdcxx-time )
fi
+ # Build compiler using LTO
+ if tc_version_is_at_least 9.1 && use_if_iuse lto ; then
+ confgcc+=( --with-build-config=bootstrap-lto )
+ fi
+
# Support to disable pch when building libstdcxx
if tc_version_is_at_least 6.0 && ! use_if_iuse pch ; then
confgcc+=( --disable-libstdcxx-pch )
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2019-05-05 16:49 Jory Pratt
0 siblings, 0 replies; 24+ messages in thread
From: Jory Pratt @ 2019-05-05 16:49 UTC (permalink / raw
To: gentoo-commits
commit: e2718633f1d0b9ab11267fe55051b081064f1ae2
Author: Jory Pratt <anarchy <AT> gentoo <DOT> org>
AuthorDate: Sun May 5 16:49:12 2019 +0000
Commit: Jory Pratt <anarchy <AT> gentoo <DOT> org>
CommitDate: Sun May 5 16:49:12 2019 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=e2718633
eclass: sync toolchain.eclass
Signed-off-by: Jory Pratt <anarchy <AT> gentoo.org>
eclass/toolchain.eclass | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index a3c901d..970d2c8 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -167,11 +167,13 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
IUSE+=" graphite +sanitize" 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 mpx"
+ tc_version_is_at_least 5.0 && IUSE+=" jit"
+ tc_version_is_between 5.0 9 && IUSE+=" mpx"
tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
# systemtap is a gentoo-specific switch: bug #654748
tc_version_is_at_least 8.0 &&
IUSE+=" systemtap" TC_FEATURES+=(systemtap)
+ tc_version_is_at_least 9.0 && IUSE+=" d"
fi
SLOT="${GCC_CONFIG_VER}"
@@ -2397,6 +2399,10 @@ is_go() {
is_jit() {
gcc-lang-supported jit || return 1
+ # cross-compiler does not really support jit as it has
+ # to generate code for a target. On target like avr
+ # libgcclit.so can't link at all: bug #594572
+ is_crosscompile && return 1
use_if_iuse jit
}
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2019-04-11 12:55 Anthony G. Basile
0 siblings, 0 replies; 24+ messages in thread
From: Anthony G. Basile @ 2019-04-11 12:55 UTC (permalink / raw
To: gentoo-commits
commit: 2734048bc5149bc247fb0482fae9f1f713601e90
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 11 12:54:43 2019 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Apr 11 12:55:06 2019 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=2734048b
eclass/toolchain.eclass: fix after commit 1fa41385
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
eclass/toolchain.eclass | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index be94db8..a3c901d 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1104,6 +1104,9 @@ toolchain_src_configure() {
*-elf|*-eabi)
confgcc+=( --with-newlib )
;;
+ *-musl*)
+ confgcc+=( --enable-__cxa_atexit )
+ ;;
*-gnu*)
confgcc+=(
--enable-__cxa_atexit
@@ -2455,12 +2458,16 @@ hardened_gcc_is_stable() {
if [[ $1 == "pie" ]] ; then
if [[ ${CTARGET} == *-uclibc* ]] ; then
tocheck=${PIE_UCLIBC_STABLE}
- else
+ elif [[ ${CTARGET} == *-musl* ]] ; then
+ tocheck=${PIE_MUSL_STABLE}
+ elif [[ ${CTARGET} == *-gnu* ]] ; then
tocheck=${PIE_GLIBC_STABLE}
fi
elif [[ $1 == "ssp" ]] ; then
if [[ ${CTARGET} == *-uclibc* ]] ; then
tocheck=${SSP_UCLIBC_STABLE}
+ elif [[ ${CTARGET} == *-musl* ]] ; then
+ tocheck=${SSP_MUSL_STABLE}
elif [[ ${CTARGET} == *-gnu* ]] ; then
tocheck=${SSP_STABLE}
fi
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2019-02-24 17:14 Anthony G. Basile
0 siblings, 0 replies; 24+ messages in thread
From: Anthony G. Basile @ 2019-02-24 17:14 UTC (permalink / raw
To: gentoo-commits
commit: 0ef588b1aae7bcdf9fd93630dfd5f9bddf527fe3
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 24 17:13:26 2019 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sun Feb 24 17:14:39 2019 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=0ef588b1
toolchain.eclass: bring into sync with upstream
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
eclass/toolchain.eclass | 226 ++++++++++++++++++++++++++++++++----------------
1 file changed, 150 insertions(+), 76 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 0163767..5411381 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -2,12 +2,13 @@
# Distributed under the terms of the GNU General Public License v2
# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
+# @SUPPORTED_EAPIS: 5
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 versionator prefix
+inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
if [[ ${PV} == *_pre9999* ]] ; then
EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"
@@ -25,8 +26,8 @@ FEATURES=${FEATURES/multilib-strict/}
case ${EAPI:-0} in
0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
- 5*) ;;
- *) die "I don't speak EAPI ${EAPI}." ;;
+ 5*) inherit eapi7-ver ;;
+ *) 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
@@ -49,7 +50,7 @@ is_crosscompile() {
# General purpose version check. Without a second arg matches up to minor version (x.x.x)
tc_version_is_at_least() {
- version_is_at_least "$1" "${2:-${GCC_RELEASE_VER}}"
+ ver_test "${2:-${GCC_RELEASE_VER}}" -ge "$1"
}
# General purpose version range check
@@ -61,17 +62,17 @@ tc_version_is_between() {
GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
GCC_PVR=${GCC_PV}
[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
-GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV})
-GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV})
-GCCMAJOR=$(get_version_component_range 1 ${GCC_PV})
-GCCMINOR=$(get_version_component_range 2 ${GCC_PV})
-GCCMICRO=$(get_version_component_range 3 ${GCC_PV})
+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=$(get_version_component_range 4 ${GCC_PV})
+ 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:-$(replace_version_separator 3 '-' ${GCC_PV})}
+GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(ver_rs 3 '-' ${GCC_PV})}
# Pre-release support
if [[ ${GCC_PV} == *_pre* ]] ; then
@@ -127,12 +128,18 @@ else
LICENSE="GPL-2+ LGPL-2.1+ FDL-1.1+"
fi
-IUSE="regression-test vanilla"
-IUSE_DEF=( nls nptl )
+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"
if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
- IUSE+=" altivec debug"
- IUSE_DEF+=( cxx fortran )
+ IUSE+=" altivec debug +cxx +fortran"
[[ -n ${PIE_VER} ]] && IUSE+=" nopie"
[[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
[[ -n ${D_VER} ]] && IUSE+=" d"
@@ -143,13 +150,13 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
tc_version_is_at_least 4.0 && IUSE+=" objc-gc"
tc_version_is_between 4.0 4.9 && IUSE+=" mudflap"
tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
- tc_version_is_at_least 4.2 && IUSE_DEF+=( openmp )
+ 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" IUSE_DEF+=( sanitize )
+ tc_version_is_at_least 4.8 && IUSE+=" graphite +sanitize"
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"
@@ -158,8 +165,6 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
tc_version_is_at_least 8.0 && IUSE+=" systemtap"
fi
-IUSE+=" ${IUSE_DEF[*]/#/+}"
-
SLOT="${GCC_CONFIG_VER}"
#---->> DEPEND <<----
@@ -202,7 +207,7 @@ DEPEND="${RDEPEND}
>=sys-devel/bison-1.875
>=sys-devel/flex-2.5.4
nls? ( sys-devel/gettext )
- regression-test? (
+ ${GCC_EBUILD_TEST_FLAG}? (
>=dev-util/dejagnu-1.4.4
>=sys-devel/autogen-5.5.4
)"
@@ -309,6 +314,14 @@ gentoo_urls() {
# ten Brugge's bounds-checking patches. If you want to use a patch
# for an older gcc version with a new gcc, make sure you set
# HTB_GCC_VER to that version of gcc.
+#
+# CYGWINPORTS_GITREV
+# If set, this variable signals that we should apply additional patches
+# maintained by upstream Cygwin developers at github/cygwinports/gcc,
+# using the specified git commit id there. The list of patches to
+# apply is extracted from gcc.cygport, maintained there as well.
+# This is done for compilers running on Cygwin, not for cross compilers
+# with a Cygwin target.
get_gcc_src_uri() {
export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
@@ -375,6 +388,11 @@ get_gcc_src_uri() {
fi
fi
+ # Cygwin patches from https://github.com/cygwinports/gcc
+ [[ -n ${CYGWINPORTS_GITREV} ]] && \
+ GCC_SRC_URI+=" elibc_Cygwin? ( https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.tar.gz
+ -> gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz )"
+
echo "${GCC_SRC_URI}"
}
@@ -481,6 +499,8 @@ gcc_quick_unpack() {
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
}
@@ -505,6 +525,7 @@ toolchain_src_prepare() {
fi
do_gcc_HTB_patches
do_gcc_PIE_patches
+ do_gcc_CYGWINPORTS_patches
epatch_user
if ( tc_version_is_at_least 4.8.2 || use_if_iuse hardened ) && ! use vanilla ; then
@@ -645,6 +666,18 @@ do_gcc_PIE_patches() {
BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
}
+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
+}
+
# configure to build with the hardened GCC specs as the default
make_gcc_hard() {
@@ -999,7 +1032,7 @@ toolchain_src_configure() {
then #291870
confgcc+=( --disable-shared )
fi
- needed_libc=uclibc
+ needed_libc=uclibc-ng
;;
*-cygwin) needed_libc=cygwin;;
x86_64-*-mingw*|\
@@ -1034,7 +1067,7 @@ toolchain_src_configure() {
confgcc+=( --enable-shared )
fi
case ${CHOST} in
- mingw*|*-mingw*|*-cygwin)
+ mingw*|*-mingw*)
confgcc+=( --enable-threads=win32 ) ;;
*)
confgcc+=( --enable-threads=posix ) ;;
@@ -1178,10 +1211,12 @@ toolchain_src_configure() {
### library options
- if ! is_gcj ; then
- confgcc+=( --disable-libgcj )
- elif use awt ; then
- confgcc+=( --enable-java-awt=gtk )
+ if tc_version_is_between 3.0 7.0 ; then
+ if ! is_gcj ; then
+ confgcc+=( --disable-libgcj )
+ elif use awt ; then
+ confgcc+=( --enable-java-awt=gtk )
+ fi
fi
if tc_version_is_at_least 4.2 ; then
@@ -1246,7 +1281,8 @@ toolchain_src_configure() {
if in_iuse vtv ; then
confgcc+=(
$(use_enable vtv vtable-verify)
- $(use_enable vtv libvtv)
+ # See Note [implicitly enabled flags]
+ $(usex vtv '' --disable-libvtv)
)
fi
@@ -1275,7 +1311,8 @@ toolchain_src_configure() {
fi
if tc_version_is_at_least 4.8 && in_iuse sanitize ; then
- confgcc+=( $(use_enable sanitize libsanitizer) )
+ # See Note [implicitly enabled flags]
+ confgcc+=( $(usex sanitize '' --disable-libsanitizer) )
fi
if tc_version_is_at_least 6.0 && in_iuse pie ; then
@@ -1322,7 +1359,7 @@ toolchain_src_configure() {
addwrite /dev/zero
echo "${S}"/configure "${confgcc[@]}"
# Older gcc versions did not detect bash and re-exec itself, so force the
- # use of bash. Newer ones will auto-detect, but this is not harmeful.
+ # use of bash. Newer ones will auto-detect, but this is not harmful.
CONFIG_SHELL="${EPREFIX}/bin/bash" \
bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
@@ -1479,6 +1516,12 @@ gcc_do_filter_flags() {
filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
filter-flags -f{no-,}stack-protector{,-all}
filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
+ # and warning options
+ filter-flags -Wextra -Wstack-protector
+ fi
+ if ! tc_version_is_at_least 4.1 ; then
+ filter-flags -fdiagnostics-show-option
+ filter-flags -Wstack-protector
fi
if tc_version_is_at_least 3.4 ; then
@@ -1594,6 +1637,11 @@ toolchain_src_compile() {
[[ ! -x /usr/bin/perl ]] \
&& find "${WORKDIR}"/build -name '*.[17]' -exec touch {} +
+ # Older gcc versions did not detect bash and re-exec itself, so force the
+ # use of bash. Newer ones will auto-detect, but this is not harmful.
+ # This needs to be set for compile as well, as it's used in libtool
+ # generation, which will break install otherwise (at least in 3.3.6): #664486
+ CONFIG_SHELL="${EPREFIX}/bin/bash" \
gcc_do_make ${GCC_MAKE_TARGET}
}
@@ -1684,7 +1732,7 @@ gcc_do_make() {
#---->> src_test <<----
toolchain_src_test() {
- if use regression-test ; then
+ if use ${GCC_EBUILD_TEST_FLAG} ; then
cd "${WORKDIR}"/build
emake -k check
fi
@@ -1723,9 +1771,9 @@ toolchain_src_install() {
S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
# Punt some tools which are really only useful while building gcc
- find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \;
+ find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
# This one comes with binutils
- find "${D}" -name libiberty.a -delete
+ find "${ED}" -name libiberty.a -delete
# Move the libraries to the proper location
gcc_movelibs
@@ -1734,7 +1782,7 @@ toolchain_src_install() {
if ! is_crosscompile ; then
local EXEEXT
eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
- [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}"
+ [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
fi
dodir /etc/env.d/gcc
@@ -1777,46 +1825,54 @@ toolchain_src_install() {
ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
fi
done
- # Rename the main go binaries as we don't want to clobber dev-lang/go
- # when gcc-config runs. #567806
- if tc_version_is_at_least 5 && is_go ; then
- for x in go gofmt; do
- mv ${x} ${x}-${GCCMAJOR} || die
- done
+
+ # When gcc builds a crosscompiler it does not install unprefixed tools.
+ # When cross-building gcc does install native tools.
+ if ! is_crosscompile; then
+ # Rename the main go binaries as we don't want to clobber dev-lang/go
+ # when gcc-config runs. #567806
+ if tc_version_is_at_least 5 && is_go ; then
+ for x in go gofmt; do
+ mv ${x} ${x}-${GCCMAJOR} || die
+ done
+ fi
fi
- # Now do the fun stripping stuff
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
- is_crosscompile && \
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${HOSTLIBPATH}"
- env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
- # gcc used to install helper binaries in lib/ but then moved to libexec/
- [[ -d ${D}${PREFIX}/libexec/gcc ]] && \
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
+ # 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:
+ # Using ${CHOST} tools:
+ # - "${D}${BINPATH}"
+ # - (for is_crosscompile) "${D}${HOSTLIBPATH}"
+ # - "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
+ # Using ${CTARGET} tools:
+ # - "${D}${LIBPATH}"
cd "${S}"
if is_crosscompile; then
- rm -rf "${ED}"usr/share/{man,info}
+ rm -rf "${ED}"/usr/share/{man,info}
rm -rf "${D}"${DATAPATH}/{man,info}
else
if tc_version_is_at_least 3.0 ; then
local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
if [[ -d ${cxx_mandir} ]] ; then
- cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
+ cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
fi
fi
- has noinfo ${FEATURES} \
- && rm -r "${D}${DATAPATH}"/info \
- || prepinfo "${DATAPATH#${EPREFIX}}"
- has noman ${FEATURES} \
- && rm -r "${D}${DATAPATH}"/man \
- || prepman "${DATAPATH#${EPREFIX}}"
fi
+
+ # portage regenerates 'dir' files on it's own: bug #672408
+ # Drop 'dir' files to avoid collisions.
+ if [[ -f "${D}${DATAPATH}"/info/dir ]]; then
+ einfo "Deleting '${D}${DATAPATH}/info/dir'"
+ rm "${D}${DATAPATH}"/info/dir || die
+ fi
+
# prune empty dirs left behind
- find "${D}" -depth -type d -delete 2>/dev/null
+ find "${ED}" -depth -type d -delete 2>/dev/null
# install testsuite results
- if use regression-test; then
+ 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 {} +
@@ -1853,7 +1909,7 @@ toolchain_src_install() {
# libvtv.la: gcc itself handles linkage correctly.
# lib*san.la: Sanitizer linkage is handled internally by gcc, and they
# do not support static linking. #487550 #546700
- find "${D}/${LIBPATH}" \
+ find "${D}${LIBPATH}" \
'(' \
-name libstdc++.la -o \
-name libstdc++fs.la -o \
@@ -1919,7 +1975,7 @@ gcc_movelibs() {
# code to run on the target.
if tc_version_is_at_least 5 && is_crosscompile ; then
dodir "${HOSTLIBPATH#${EPREFIX}}"
- mv "${ED}"usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
+ mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
fi
# For all the libs that are built for CTARGET, move them into the
@@ -1969,7 +2025,7 @@ gcc_movelibs() {
for FROMDIR in ${removedirs} ; do
rmdir "${D}"${FROMDIR} >& /dev/null
done
- find -depth "${D}" -type d -exec rmdir {} + >& /dev/null
+ find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
}
# make sure the libtool archives have libdir set to where they actually
@@ -2116,7 +2172,7 @@ gcc_slot_java() {
toolchain_pkg_postinst() {
do_gcc_config
- if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
+ if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
eselect compiler-shadow update all
fi
@@ -2131,20 +2187,20 @@ toolchain_pkg_postinst() {
echo
# Clean up old paths
- rm -f "${EROOT}"*/rcscripts/awk/fixlafiles.awk "${EROOT}"sbin/fix_libtool_files.sh
- rmdir "${EROOT}"*/rcscripts{/awk,} 2>/dev/null
+ rm -f "${EROOT%/}"/*/rcscripts/awk/fixlafiles.awk "${EROOT%/}"/sbin/fix_libtool_files.sh
+ rmdir "${EROOT%/}"/*/rcscripts{/awk,} 2>/dev/null
- mkdir -p "${EROOT}"usr/{share/gcc-data,sbin,bin}
+ 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
+ if use ${GCC_EBUILD_TEST_FLAG} ; then
elog "Testsuite results have been installed into /usr/share/doc/${PF}/testsuite"
echo
fi
@@ -2157,7 +2213,7 @@ toolchain_pkg_postinst() {
}
toolchain_pkg_postrm() {
- if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
+ if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
eselect compiler-shadow clean all
fi
@@ -2168,16 +2224,16 @@ 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
- 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}
+ if [[ -z $(ls "${EROOT%/}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
+ rm -f "${EROOT%/}"/etc/env.d/gcc/config-${CTARGET}
+ rm -f "${EROOT%/}"/etc/env.d/??gcc-${CTARGET}
+ rm -f "${EROOT%/}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
fi
return 0
fi
# ROOT isnt handled by the script
- [[ ${ROOT} != "/" ]] && return 0
+ [[ ${ROOT%/} ]] && return 0
if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
# make sure the profile is sane during same-slot upgrade #289403
@@ -2210,7 +2266,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 ${EROOT%/}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
then
ewarn "The currently selected specs-specific gcc config,"
ewarn "${current_specs}, doesn't exist anymore. This is usually"
@@ -2243,7 +2299,7 @@ should_we_gcc_config() {
# for being in the same SLOT, make sure we run gcc-config.
local curr_config_ver=$(gcc-config -S ${curr_config} | awk '{print $2}')
- local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
+ local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver})
if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
return 0
@@ -2455,3 +2511,21 @@ toolchain_death_notice() {
popd >/dev/null
fi
}
+
+# Note [implicitly enabled flags]
+# -------------------------------
+# Usually configure-based packages handle explicit feature requests
+# like
+# ./configure --enable-foo
+# as explicit request to check for support of 'foo' and bail out at
+# configure time.
+#
+# GCC does not follow this pattern and instead overrides autodetection
+# of the feature and enables it unconditionally.
+# See bugs:
+# https://gcc.gnu.org/PR85663 (libsanitizer on mips)
+# https://bugs.gentoo.org/661252 (libvtv on powerpc64)
+#
+# Thus safer way to enable/disable the feature is to rely on implicit
+# enabled-by-default state:
+# econf $(usex foo '' --disable-foo)
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2019-01-05 0:44 Anthony G. Basile
0 siblings, 0 replies; 24+ messages in thread
From: Anthony G. Basile @ 2019-01-05 0:44 UTC (permalink / raw
To: gentoo-commits
commit: 3bf7b7fcb0882ade14980e23f95150971de3c446
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 5 00:43:46 2019 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jan 5 00:43:46 2019 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=3bf7b7fc
eclass/qt5-build.eclass: remove
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
eclass/qt5-build.eclass | 808 ------------------------------------------------
1 file changed, 808 deletions(-)
diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass
deleted file mode 100644
index 82a2aaf..0000000
--- a/eclass/qt5-build.eclass
+++ /dev/null
@@ -1,808 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-# @ECLASS: qt5-build.eclass
-# @MAINTAINER:
-# qt@gentoo.org
-# @AUTHOR:
-# Davide Pesavento <pesa@gentoo.org>
-# @SUPPORTED_EAPIS: 6
-# @BLURB: Eclass for Qt5 split ebuilds.
-# @DESCRIPTION:
-# This eclass contains various functions that are used when building Qt5.
-# Requires EAPI 6.
-
-if [[ ${CATEGORY} != dev-qt ]]; then
- die "qt5-build.eclass is only to be used for building Qt 5."
-fi
-
-case ${EAPI} in
- 6) : ;;
- *) die "qt5-build.eclass: unsupported EAPI=${EAPI:-0}" ;;
-esac
-
-# @ECLASS-VARIABLE: QT5_MODULE
-# @PRE_INHERIT
-# @DESCRIPTION:
-# The upstream name of the module this package belongs to. Used for
-# SRC_URI and EGIT_REPO_URI. Must be set before inheriting the eclass.
-: ${QT5_MODULE:=${PN}}
-
-# @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# Array variable containing the source directories that should be built.
-# All paths must be relative to ${S}.
-
-# @ECLASS-VARIABLE: QT5_GENTOO_CONFIG
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# Array of <useflag:feature:macro> triplets that are evaluated in src_install
-# to generate the per-package list of enabled QT_CONFIG features and macro
-# definitions, which are then merged together with all other Qt5 packages
-# installed on the system to obtain the global qconfig.{h,pri} files.
-
-# @ECLASS-VARIABLE: VIRTUALX_REQUIRED
-# @DESCRIPTION:
-# For proper description see virtualx.eclass man page.
-# Here we redefine default value to be manual, if your package needs virtualx
-# for tests you should proceed with setting VIRTUALX_REQUIRED=test.
-: ${VIRTUALX_REQUIRED:=manual}
-
-inherit estack flag-o-matic ltprune toolchain-funcs versionator virtualx
-
-HOMEPAGE="https://www.qt.io/"
-LICENSE="|| ( GPL-2 GPL-3 LGPL-3 ) FDL-1.3"
-SLOT=5/$(get_version_component_range 1-2)
-
-QT5_MINOR_VERSION=$(get_version_component_range 2)
-QT5_PATCH_VERSION=$(get_version_component_range 3)
-readonly QT5_MINOR_VERSION QT5_PATCH_VERSION
-
-case ${PV} in
- 5.9999)
- # git dev branch
- QT5_BUILD_TYPE="live"
- EGIT_BRANCH="dev"
- ;;
- 5.?.9999|5.??.9999|5.???.9999)
- # git stable branch
- QT5_BUILD_TYPE="live"
- EGIT_BRANCH=${PV%.9999}
- ;;
- *_alpha*|*_beta*|*_rc*)
- # development release
- QT5_BUILD_TYPE="release"
- MY_P=${QT5_MODULE}-opensource-src-${PV/_/-}
- SRC_URI="https://download.qt.io/development_releases/qt/${PV%.*}/${PV/_/-}/submodules/${MY_P}.tar.xz"
- S=${WORKDIR}/${MY_P}
- ;;
- *)
- # official stable release
- QT5_BUILD_TYPE="release"
- MY_P=${QT5_MODULE}-opensource-src-${PV}
- SRC_URI="https://download.qt.io/official_releases/qt/${PV%.*}/${PV}/submodules/${MY_P}.tar.xz"
- S=${WORKDIR}/${MY_P}
- ;;
-esac
-readonly QT5_BUILD_TYPE
-
-EGIT_REPO_URI=(
- "https://code.qt.io/qt/${QT5_MODULE}.git"
- "https://github.com/qt/${QT5_MODULE}.git"
-)
-[[ ${QT5_BUILD_TYPE} == live ]] && inherit git-r3
-
-# @ECLASS-VARIABLE: QT5_BUILD_DIR
-# @OUTPUT_VARIABLE
-# @DESCRIPTION:
-# Build directory for out-of-source builds.
-case ${QT5_BUILD_TYPE} in
- live) : ${QT5_BUILD_DIR:=${S}_build} ;;
- release) : ${QT5_BUILD_DIR:=${S}} ;; # workaround for bug 497312
-esac
-
-IUSE="debug test"
-
-[[ ${PN} == qtwebkit ]] && RESTRICT+=" mirror" # bug 524584
-[[ ${QT5_BUILD_TYPE} == release ]] && RESTRICT+=" test" # bug 457182
-
-DEPEND="
- dev-lang/perl
- virtual/pkgconfig
-"
-if [[ (${PN} != qttest && ${PN} != qtwebkit) || (${PN} == qtwebkit && ${QT5_MINOR_VERSION} -lt 9) ]]; then
- DEPEND+=" test? ( ~dev-qt/qttest-${PV} )"
-fi
-RDEPEND="
- dev-qt/qtchooser
-"
-
-
-###### Phase functions ######
-
-EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
-
-# @FUNCTION: qt5-build_src_unpack
-# @DESCRIPTION:
-# Unpacks the sources.
-qt5-build_src_unpack() {
- if tc-is-gcc; then
- local min_gcc4_minor_version=7
- if [[ $(gcc-major-version) -lt 4 ]] || \
- [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt ${min_gcc4_minor_version} ]]; then
- eerror "GCC version 4.${min_gcc4_minor_version} or later is required to build this package"
- die "GCC 4.${min_gcc4_minor_version} or later required"
- fi
- fi
-
- # bug 307861
- if [[ ${PN} == qtwebengine || ${PN} == qtwebkit ]]; then
- eshopts_push -s extglob
- if is-flagq '-g?(gdb)?([1-9])'; then
- ewarn
- ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
- ewarn "You may experience really long compilation times and/or increased memory usage."
- ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
- ewarn
- fi
- eshopts_pop
- fi
-
- case ${QT5_BUILD_TYPE} in
- live) git-r3_src_unpack ;;
- release) default ;;
- esac
-}
-
-# @FUNCTION: qt5-build_src_prepare
-# @DESCRIPTION:
-# Prepares the environment and patches the sources if necessary.
-qt5-build_src_prepare() {
- qt5_prepare_env
-
- if [[ ${QT5_MODULE} == qtbase ]]; then
- qt5_symlink_tools_to_build_dir
-
- # Avoid unnecessary qmake recompilations
- if [[ ${QT5_MINOR_VERSION} -ge 8 ]]; then
- sed -i -e "/Creating qmake/i if [ '!' -e \"\$outpath/bin/qmake\" ]; then" \
- -e '/echo "Done."/a fi' \
- configure || die "sed failed (skip qmake bootstrap)"
- else
- sed -i -re "s|^if true;.*(\[ '\!').*(\"\\\$outpath/bin/qmake\".*)|if \1 -e \2 then|" \
- configure || die "sed failed (skip qmake bootstrap)"
- fi
-
- # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when bootstrapping qmake
- sed -i -e "/outpath\/qmake\".*\"\$MAKE\")/ s:): \
- ${MAKEOPTS} ${EXTRA_EMAKE} 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \
- 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&:" \
- -e 's/\(setBootstrapVariable\s\+\|EXTRA_C\(XX\)\?FLAGS=.*\)QMAKE_C\(XX\)\?FLAGS_\(DEBUG\|RELEASE\).*/:/' \
- configure || die "sed failed (respect env for qmake build)"
- sed -i -e '/^CPPFLAGS\s*=/ s/-g //' \
- qmake/Makefile.unix || die "sed failed (CPPFLAGS for qmake build)"
-
- # Respect CXX in bsymbolic_functions, fvisibility, precomp, and a few other tests
- sed -i -e "/^QMAKE_CONF_COMPILER=/ s:=.*:=\"$(tc-getCXX)\":" \
- configure || die "sed failed (QMAKE_CONF_COMPILER)"
-
- if [[ ${QT5_MINOR_VERSION} -le 7 ]]; then
- # Respect toolchain and flags in config.tests
- find config.tests/unix -name '*.test' -type f -execdir \
- sed -i -e 's/-nocache //' '{}' + || die
- fi
-
- # Don't inject -msse/-mavx/... into CXXFLAGS when detecting
- # compiler support for extended instruction sets (bug 552942)
- find config.tests/common -name '*.pro' -type f -execdir \
- sed -i -e '/QMAKE_CXXFLAGS\s*+=/ d' '{}' + || die
-
- # Don't add -O3 to CXXFLAGS (bug 549140)
- sed -i -e '/CONFIG\s*+=/ s/optimize_full//' \
- src/{corelib/corelib,gui/gui}.pro || die "sed failed (optimize_full)"
- fi
-
- default
-}
-
-# @FUNCTION: qt5-build_src_configure
-# @DESCRIPTION:
-# Runs qmake in the target directories. For packages
-# in qtbase, ./configure is also run before qmake.
-qt5-build_src_configure() {
- if [[ ${QT5_MODULE} == qtbase ]]; then
- qt5_base_configure
- fi
-
- qt5_foreach_target_subdir qt5_qmake
-}
-
-# @FUNCTION: qt5-build_src_compile
-# @DESCRIPTION:
-# Runs emake in the target directories.
-qt5-build_src_compile() {
- qt5_foreach_target_subdir emake
-}
-
-# @FUNCTION: qt5-build_src_test
-# @DESCRIPTION:
-# Runs tests in the target directories.
-qt5-build_src_test() {
- # disable broken cmake tests (bug 474004)
- local myqmakeargs=("${myqmakeargs[@]}" -after SUBDIRS-=cmake SUBDIRS-=installed_cmake)
-
- qt5_foreach_target_subdir qt5_qmake
- qt5_foreach_target_subdir emake
-
- # create a custom testrunner script that correctly sets
- # LD_LIBRARY_PATH before executing the given test
- local testrunner=${QT5_BUILD_DIR}/gentoo-testrunner
- cat > "${testrunner}" <<-_EOF_ || die
- #!/bin/sh
- export LD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
- "\$@"
- _EOF_
- chmod +x "${testrunner}"
-
- set -- qt5_foreach_target_subdir emake TESTRUNNER="'${testrunner}'" check
- if [[ ${VIRTUALX_REQUIRED} == test ]]; then
- virtx "$@"
- else
- "$@"
- fi
-}
-
-# @FUNCTION: qt5-build_src_install
-# @DESCRIPTION:
-# Runs emake install in the target directories.
-qt5-build_src_install() {
- qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install
-
- if [[ ${PN} == qtcore ]]; then
- pushd "${QT5_BUILD_DIR}" >/dev/null || die
-
- set -- emake INSTALL_ROOT="${D}" \
- sub-qmake-qmake-aux-pro-install_subtargets \
- install_{syncqt,mkspecs}
-
- einfo "Running $*"
- "$@"
-
- popd >/dev/null || die
-
- docompress -x "${QT5_DOCDIR#${EPREFIX}}"/global
-
- # install an empty Gentoo/gentoo-qconfig.h in ${D}
- # so that it's placed under package manager control
- > "${T}"/gentoo-qconfig.h
- (
- insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
- doins "${T}"/gentoo-qconfig.h
- )
-
- # include gentoo-qconfig.h at the beginning of QtCore/qconfig.h
- sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
- "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \
- || die "sed failed (qconfig.h)"
-
- # install qtchooser configuration file
- cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_ || die
- ${QT5_BINDIR}
- ${QT5_LIBDIR}
- _EOF_
-
- (
- insinto /etc/xdg/qtchooser
- doins "${T}/qt5-${CHOST}.conf"
- )
-
- # convenience symlinks
- dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf
- dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf
- fi
-
- qt5_install_module_qconfigs
- prune_libtool_files
-}
-
-# @FUNCTION: qt5-build_pkg_postinst
-# @DESCRIPTION:
-# Regenerate configuration after installation or upgrade/downgrade.
-qt5-build_pkg_postinst() {
- qt5_regenerate_global_qconfigs
-}
-
-# @FUNCTION: qt5-build_pkg_postrm
-# @DESCRIPTION:
-# Regenerate configuration when a module is completely removed.
-qt5-build_pkg_postrm() {
- if [[ -z ${REPLACED_BY_VERSION} && ${PN} != qtcore ]]; then
- qt5_regenerate_global_qconfigs
- fi
-}
-
-
-###### Public helpers ######
-
-# @FUNCTION: qt_use
-# @USAGE: <flag> [feature] [enableval]
-# @DESCRIPTION:
-# <flag> is the name of a flag in IUSE.
-#
-# Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
-# otherwise. If [feature] is not specified, <flag> is used in its place.
-# If [enableval] is not specified, the "-${enableval}" prefix is omitted.
-qt_use() {
- [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
-
- usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
-}
-
-# @FUNCTION: qt_use_compile_test
-# @USAGE: <flag> [config]
-# @DESCRIPTION:
-# <flag> is the name of a flag in IUSE.
-# [config] is the argument of qtCompileTest, defaults to <flag>.
-#
-# This function is useful to disable optional dependencies that are checked
-# at qmake-time using the qtCompileTest() function. If <flag> is disabled,
-# the compile test is skipped and the dependency is assumed to be unavailable,
-# i.e. the corresponding feature will be disabled. Note that all invocations
-# of this function must happen before calling qt5-build_src_configure.
-qt_use_compile_test() {
- [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
-
- if ! use "$1"; then
- mkdir -p "${QT5_BUILD_DIR}" || die
- echo "CONFIG += done_config_${2:-$1}" >> "${QT5_BUILD_DIR}"/.qmake.cache || die
- fi
-}
-
-# @FUNCTION: qt_use_disable_config
-# @USAGE: <flag> <config> <files...>
-# @DESCRIPTION:
-# <flag> is the name of a flag in IUSE.
-# <config> is the (lowercase) name of a Qt5 config entry.
-# <files...> is a list of one or more qmake project files.
-#
-# This function patches <files> to treat <config> as disabled
-# when <flag> is disabled, otherwise it does nothing.
-# This can be useful to avoid an automagic dependency when the config entry
-# is enabled on the system but the corresponding USE flag is disabled.
-qt_use_disable_config() {
- [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
-
- local flag=$1
- local config=$2
- shift 2
-
- if ! use "${flag}"; then
- echo "$@" | xargs sed -i -e "s/qtConfig(${config})/false/g" || die
- fi
-}
-
-# @FUNCTION: qt_use_disable_mod
-# @USAGE: <flag> <module> <files...>
-# @DESCRIPTION:
-# <flag> is the name of a flag in IUSE.
-# <module> is the (lowercase) name of a Qt5 module.
-# <files...> is a list of one or more qmake project files.
-#
-# This function patches <files> to treat <module> as not installed
-# when <flag> is disabled, otherwise it does nothing.
-# This can be useful to avoid an automagic dependency when the module
-# is present on the system but the corresponding USE flag is disabled.
-qt_use_disable_mod() {
- [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
-
- local flag=$1
- local module=$2
- shift 2
-
- if ! use "${flag}"; then
- echo "$@" | xargs sed -i -e "s/qtHaveModule(${module})/false/g" || die
- fi
-}
-
-
-###### Internal functions ######
-
-# @FUNCTION: qt5_prepare_env
-# @INTERNAL
-# @DESCRIPTION:
-# Prepares the environment for building Qt.
-qt5_prepare_env() {
- # setup installation directories
- # note: keep paths in sync with qmake-utils.eclass
- QT5_PREFIX=${EPREFIX}/usr
- QT5_HEADERDIR=${QT5_PREFIX}/include/qt5
- QT5_LIBDIR=${QT5_PREFIX}/$(get_libdir)
- QT5_ARCHDATADIR=${QT5_PREFIX}/$(get_libdir)/qt5
- QT5_BINDIR=${QT5_ARCHDATADIR}/bin
- QT5_PLUGINDIR=${QT5_ARCHDATADIR}/plugins
- QT5_LIBEXECDIR=${QT5_ARCHDATADIR}/libexec
- QT5_IMPORTDIR=${QT5_ARCHDATADIR}/imports
- QT5_QMLDIR=${QT5_ARCHDATADIR}/qml
- QT5_DATADIR=${QT5_PREFIX}/share/qt5
- QT5_DOCDIR=${QT5_PREFIX}/share/doc/qt-${PV}
- QT5_TRANSLATIONDIR=${QT5_DATADIR}/translations
- QT5_EXAMPLESDIR=${QT5_DATADIR}/examples
- QT5_TESTSDIR=${QT5_DATADIR}/tests
- QT5_SYSCONFDIR=${EPREFIX}/etc/xdg
- readonly QT5_PREFIX QT5_HEADERDIR QT5_LIBDIR QT5_ARCHDATADIR \
- QT5_BINDIR QT5_PLUGINDIR QT5_LIBEXECDIR QT5_IMPORTDIR \
- QT5_QMLDIR QT5_DATADIR QT5_DOCDIR QT5_TRANSLATIONDIR \
- QT5_EXAMPLESDIR QT5_TESTSDIR QT5_SYSCONFDIR
-
- if [[ ${QT5_MODULE} == qtbase ]]; then
- # see mkspecs/features/qt_config.prf
- export QMAKEMODULES="${QT5_BUILD_DIR}/mkspecs/modules:${S}/mkspecs/modules:${QT5_ARCHDATADIR}/mkspecs/modules"
- fi
-}
-
-# @FUNCTION: qt5_foreach_target_subdir
-# @INTERNAL
-# @DESCRIPTION:
-# Executes the command given as argument from inside each directory
-# listed in QT5_TARGET_SUBDIRS. Handles autotests subdirs automatically.
-qt5_foreach_target_subdir() {
- [[ -z ${QT5_TARGET_SUBDIRS[@]} ]] && QT5_TARGET_SUBDIRS=("")
-
- local subdir=
- for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
- if [[ ${EBUILD_PHASE} == test ]]; then
- subdir=tests/auto${subdir#src}
- [[ -d ${S}/${subdir} ]] || continue
- fi
-
- local msg="Running $* ${subdir:+in ${subdir}}"
- einfo "${msg}"
-
- mkdir -p "${QT5_BUILD_DIR}/${subdir}" || die -n || return $?
- pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die -n || return $?
-
- "$@" || die -n "${msg} failed" || return $?
-
- popd >/dev/null || die -n || return $?
- done
-}
-
-# @FUNCTION: qt5_symlink_tools_to_build_dir
-# @INTERNAL
-# @DESCRIPTION:
-# Symlinks qmake and a few other tools to QT5_BUILD_DIR,
-# so that they can be used when building other modules.
-qt5_symlink_tools_to_build_dir() {
- local tool= tools=()
- if [[ ${PN} != qtcore ]]; then
- tools+=(qmake moc rcc qlalr)
- [[ ${PN} != qtdbus ]] && tools+=(qdbuscpp2xml qdbusxml2cpp)
- [[ ${PN} != qtwidgets ]] && tools+=(uic)
- fi
-
- mkdir -p "${QT5_BUILD_DIR}"/bin || die
- pushd "${QT5_BUILD_DIR}"/bin >/dev/null || die
-
- for tool in "${tools[@]}"; do
- [[ -e ${QT5_BINDIR}/${tool} ]] || continue
- ln -s "${QT5_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
- done
-
- popd >/dev/null || die
-}
-
-# @FUNCTION: qt5_base_configure
-# @INTERNAL
-# @DESCRIPTION:
-# Runs ./configure for modules belonging to qtbase.
-qt5_base_configure() {
- # setup toolchain variables used by configure
- tc-export AR CC CXX OBJDUMP RANLIB STRIP
- export LD="$(tc-getCXX)"
-
- # bug 633838
- if [[ ${QT5_MINOR_VERSION} -ge 9 ]]; then
- unset QMAKESPEC XQMAKESPEC QMAKEPATH QMAKEFEATURES
- fi
-
- # configure arguments
- local conf=(
- # installation paths
- -prefix "${QT5_PREFIX}"
- -bindir "${QT5_BINDIR}"
- -headerdir "${QT5_HEADERDIR}"
- -libdir "${QT5_LIBDIR}"
- -archdatadir "${QT5_ARCHDATADIR}"
- -plugindir "${QT5_PLUGINDIR}"
- -libexecdir "${QT5_LIBEXECDIR}"
- -importdir "${QT5_IMPORTDIR}"
- -qmldir "${QT5_QMLDIR}"
- -datadir "${QT5_DATADIR}"
- -docdir "${QT5_DOCDIR}"
- -translationdir "${QT5_TRANSLATIONDIR}"
- -sysconfdir "${QT5_SYSCONFDIR}"
- -examplesdir "${QT5_EXAMPLESDIR}"
- -testsdir "${QT5_TESTSDIR}"
-
- # configure in release mode by default,
- # override via the CONFIG qmake variable
- -release
- -no-separate-debug-info
-
- # no need to forcefully build host tools in optimized mode,
- # just follow the overall debug/release build type
- -no-optimized-tools
-
- # licensing stuff
- -opensource -confirm-license
-
- # autodetect the highest supported version of the C++ standard
- #-c++std <c++11|c++14|c++1z>
-
- # build shared libraries
- -shared
-
- # always enable large file support
- $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -largefile)
-
- # disabling accessibility is not recommended by upstream, as
- # it will break QStyle and may break other internal parts of Qt
- -accessibility
-
- # disable all SQL drivers by default, override in qtsql
- -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc
- -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds
-
- # ensure the QML debugging support (qmltooling) is built in qtdeclarative
- -qml-debug
-
- # MIPS DSP instruction set extensions
- $(is-flagq -mno-dsp && echo -no-mips_dsp)
- $(is-flagq -mno-dspr2 && echo -no-mips_dspr2)
-
- # use pkg-config to detect include and library paths
- -pkg-config
-
- # prefer system libraries (only common hard deps here)
- -system-zlib
- -system-pcre
- -system-doubleconversion
-
- # disable everything to prevent automagic deps (part 1)
- -no-mtdev
- -no-journald -no-syslog
- -no-libpng -no-libjpeg
- -no-freetype -no-harfbuzz
- -no-openssl -no-libproxy
- -no-xkbcommon-x11 -no-xkbcommon-evdev
- -no-xinput2 -no-xcb-xlib
-
- # cannot use -no-gif because there is no way to override it later
- #-no-gif
-
- # always enable glib event loop support
- -glib
-
- # disable everything to prevent automagic deps (part 2)
- -no-gtk
- $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-pulseaudio -no-alsa)
-
- # exclude examples and tests from default build
- -nomake examples
- -nomake tests
- -no-compile-examples
-
- # disable rpath on non-prefix (bugs 380415 and 417169)
- $(usex prefix '' -no-rpath)
-
- # print verbose information about each configure test
- -verbose
-
- # always enable iconv support
- # since 5.8 this is handled in qtcore
- $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -iconv)
-
- # disable everything to prevent automagic deps (part 3)
- -no-cups -no-evdev -no-tslib -no-icu -no-fontconfig -no-dbus
-
- # let portage handle stripping
- -no-strip
-
- # precompiled headers can cause problems on hardened, so turn them off
- -no-pch
-
- # link-time code generation is not something we want to enable by default
- -no-ltcg
-
- # reduced relocations cause major breakage on at least arm and ppc, so
- # don't specify anything and let the configure figure out if they are
- # supported; see also https://bugreports.qt.io/browse/QTBUG-36129
- #-reduce-relocations
-
- # let configure automatically detect if GNU gold is available
- -no-use-gold-linker
-
- # disable all platform plugins by default, override in qtgui
- -no-xcb -no-eglfs -no-kms -no-gbm -no-directfb -no-linuxfb -no-mirclient
-
- # disable undocumented X11-related flags, override in qtgui
- # (not shown in ./configure -help output)
- -no-xkb
- $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-xrender)
-
- # disable obsolete/unused X11-related flags
- $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-mitshm -no-xcursor -no-xfixes -no-xrandr -no-xshape -no-xsync)
-
- # always enable session management support: it doesn't need extra deps
- # at configure time and turning it off is dangerous, see bug 518262
- -sm
-
- # typedef qreal to double (warning: changing this flag breaks the ABI)
- -qreal double
-
- # disable OpenGL and EGL support by default, override in qtgui,
- # qtopengl, qtprintsupport and qtwidgets
- -no-opengl -no-egl
-
- # disable libinput-based generic plugin by default, override in qtgui
- -no-libinput
-
- # disable gstreamer by default, override in qtmultimedia
- $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-gstreamer)
-
- # respect system proxies by default: it's the most natural
- # setting, and it'll become the new upstream default in 5.8
- -system-proxies
-
- # do not build with -Werror
- -no-warnings-are-errors
-
- # module-specific options
- "${myconf[@]}"
- )
-
- pushd "${QT5_BUILD_DIR}" >/dev/null || die
-
- einfo "Configuring with: ${conf[@]}"
- "${S}"/configure "${conf[@]}" || die "configure failed"
-
- if [[ ${QT5_MINOR_VERSION} -ge 8 ]]; then
- # a forwarding header is no longer created since 5.8, causing the system
- # config to always be used. bug 599636
- cp src/corelib/global/qconfig.h include/QtCore/ || die
- fi
-
- popd >/dev/null || die
-
-}
-
-# @FUNCTION: qt5_qmake
-# @INTERNAL
-# @DESCRIPTION:
-# Helper function that runs qmake in the current target subdir.
-# Intended to be called by qt5_foreach_target_subdir().
-qt5_qmake() {
- local projectdir=${PWD/#${QT5_BUILD_DIR}/${S}}
- local qmakepath=
- if [[ ${QT5_MODULE} == qtbase ]]; then
- qmakepath=${QT5_BUILD_DIR}/bin
- else
- qmakepath=${QT5_BINDIR}
- fi
-
- "${qmakepath}"/qmake \
- "${projectdir}" \
- CONFIG+=$(usex debug debug release) \
- CONFIG-=$(usex debug release debug) \
- QMAKE_AR="$(tc-getAR) cqs" \
- QMAKE_CC="$(tc-getCC)" \
- QMAKE_LINK_C="$(tc-getCC)" \
- QMAKE_LINK_C_SHLIB="$(tc-getCC)" \
- QMAKE_CXX="$(tc-getCXX)" \
- QMAKE_LINK="$(tc-getCXX)" \
- QMAKE_LINK_SHLIB="$(tc-getCXX)" \
- QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
- QMAKE_RANLIB= \
- QMAKE_STRIP="$(tc-getSTRIP)" \
- QMAKE_CFLAGS="${CFLAGS}" \
- QMAKE_CFLAGS_RELEASE= \
- QMAKE_CFLAGS_DEBUG= \
- QMAKE_CXXFLAGS="${CXXFLAGS}" \
- QMAKE_CXXFLAGS_RELEASE= \
- QMAKE_CXXFLAGS_DEBUG= \
- QMAKE_LFLAGS="${LDFLAGS}" \
- QMAKE_LFLAGS_RELEASE= \
- QMAKE_LFLAGS_DEBUG= \
- "${myqmakeargs[@]}" \
- || die "qmake failed (${projectdir#${S}/})"
-}
-
-# @FUNCTION: qt5_install_module_qconfigs
-# @INTERNAL
-# @DESCRIPTION:
-# Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
-qt5_install_module_qconfigs() {
- local x qconfig_add= qconfig_remove=
-
- > "${T}"/${PN}-qconfig.h
- > "${T}"/${PN}-qconfig.pri
-
- # generate qconfig_{add,remove} and ${PN}-qconfig.h
- for x in "${QT5_GENTOO_CONFIG[@]}"; do
- local flag=${x%%:*}
- x=${x#${flag}:}
- local feature=${x%%:*}
- x=${x#${feature}:}
- local macro=${x}
- macro=$(tr 'a-z-' 'A-Z_' <<< "${macro}")
-
- if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then
- [[ -n ${feature} ]] && qconfig_add+=" ${feature}"
- [[ -n ${macro} ]] && echo "#define QT_${macro}" >> "${T}"/${PN}-qconfig.h
- else
- [[ -n ${feature} ]] && qconfig_remove+=" ${feature}"
- [[ -n ${macro} ]] && echo "#define QT_NO_${macro}" >> "${T}"/${PN}-qconfig.h
- fi
- done
-
- # install ${PN}-qconfig.h
- [[ -s ${T}/${PN}-qconfig.h ]] && (
- insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
- doins "${T}"/${PN}-qconfig.h
- )
-
- # generate and install ${PN}-qconfig.pri
- [[ -n ${qconfig_add} ]] && echo "QCONFIG_ADD=${qconfig_add}" >> "${T}"/${PN}-qconfig.pri
- [[ -n ${qconfig_remove} ]] && echo "QCONFIG_REMOVE=${qconfig_remove}" >> "${T}"/${PN}-qconfig.pri
- [[ -s ${T}/${PN}-qconfig.pri ]] && (
- insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
- doins "${T}"/${PN}-qconfig.pri
- )
-}
-
-# @FUNCTION: qt5_regenerate_global_qconfigs
-# @INTERNAL
-# @DESCRIPTION:
-# Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
-# Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
-qt5_regenerate_global_qconfigs() {
- einfo "Regenerating gentoo-qconfig.h"
-
- find "${ROOT%/}${QT5_HEADERDIR}"/Gentoo \
- -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \
- -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h
-
- [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty"
- mv -f "${T}"/gentoo-qconfig.h "${ROOT%/}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \
- || eerror "Failed to install new gentoo-qconfig.h"
-
- einfo "Updating QT_CONFIG in qconfig.pri"
-
- local qconfig_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri
- if [[ -f ${qconfig_pri} ]]; then
- local x qconfig_add= qconfig_remove=
- local qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri}")
- local new_qt_config=
-
- # generate list of QT_CONFIG entries from the existing list,
- # appending QCONFIG_ADD and excluding QCONFIG_REMOVE
- eshopts_push -s nullglob
- for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
- qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")"
- qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")"
- done
- eshopts_pop
- for x in ${qt_config} ${qconfig_add}; do
- if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then
- new_qt_config+=" ${x}"
- fi
- done
-
- # now replace the existing QT_CONFIG with the generated list
- sed -i -e "s/^QT_CONFIG\s*+=.*/QT_CONFIG +=${new_qt_config}/" \
- "${qconfig_pri}" || eerror "Failed to sed QT_CONFIG in ${qconfig_pri}"
- else
- ewarn "${qconfig_pri} does not exist or is not a regular file"
- fi
-}
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2018-05-17 18:15 Aric Belsito
0 siblings, 0 replies; 24+ messages in thread
From: Aric Belsito @ 2018-05-17 18:15 UTC (permalink / raw
To: gentoo-commits
commit: 3b125569cb62d55c839898351dc7238d185923d9
Author: Aric Belsito <lluixhi <AT> gmail <DOT> com>
AuthorDate: Thu May 17 18:15:06 2018 +0000
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Thu May 17 18:15:06 2018 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=3b125569
toolchain.eclass: sync with upstream
eclass/toolchain.eclass | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 47e99ac..0163767 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -137,7 +137,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"
@@ -149,9 +150,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[*]/#/+}"
@@ -218,6 +222,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 <<----
@@ -1208,7 +1217,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
@@ -1220,6 +1239,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)
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2018-05-03 18:31 Aric Belsito
0 siblings, 0 replies; 24+ messages in thread
From: Aric Belsito @ 2018-05-03 18:31 UTC (permalink / raw
To: gentoo-commits
commit: ee289ee31cd6d54e23d13e025399a47959ff4304
Author: Aric Belsito <lluixhi <AT> gmail <DOT> com>
AuthorDate: Thu May 3 18:30:36 2018 +0000
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Thu May 3 18:30:36 2018 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=ee289ee3
toolchain.eclass: sync with upstream
eclass/toolchain.eclass | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index dee6a88..47e99ac 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -206,11 +206,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
"
@@ -972,7 +971,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 )
+ ;;
*-freebsd*) needed_libc=freebsd-lib;;
*-gnu*) needed_libc=glibc;;
*-klibc) needed_libc=klibc;;
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2018-04-14 17:41 Aric Belsito
0 siblings, 0 replies; 24+ messages in thread
From: Aric Belsito @ 2018-04-14 17:41 UTC (permalink / raw
To: gentoo-commits
commit: d7ce5eaedcb745006453047cc258d92accedde90
Author: Aric Belsito <lluixhi <AT> gmail <DOT> com>
AuthorDate: Sat Apr 14 17:41:15 2018 +0000
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Sat Apr 14 17:41:15 2018 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=d7ce5eae
toolchain.eclass: sync with upstream
eclass/toolchain.eclass | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index df637dc..dee6a88 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -24,8 +24,8 @@ fi
FEATURES=${FEATURES/multilib-strict/}
case ${EAPI:-0} in
- 0|1|2|3) die "Need to upgrade to at least EAPI=4" ;;
- 4*|5*) ;;
+ 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 pkg_pretend pkg_setup src_unpack src_prepare src_configure \
@@ -166,7 +166,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
@@ -174,7 +174,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
@@ -184,12 +184,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
@@ -1811,6 +1811,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.
@@ -1830,6 +1831,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 \
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2018-01-25 19:48 Aric Belsito
0 siblings, 0 replies; 24+ messages in thread
From: Aric Belsito @ 2018-01-25 19:48 UTC (permalink / raw
To: gentoo-commits
commit: 7116bde1b30f9d0cd1a660c4cb28351c3930add8
Author: Aric Belsito <lluixhi <AT> gmail <DOT> com>
AuthorDate: Thu Jan 25 19:48:03 2018 +0000
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Thu Jan 25 19:48:03 2018 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=7116bde1
toolchain.eclass: sync with upstream
eclass/toolchain.eclass | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index d3a06ea..df637dc 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -316,7 +316,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"
@@ -417,7 +421,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
@@ -993,7 +1001,7 @@ toolchain_src_configure() {
--disable-threads
--without-headers
)
- elif has_version "${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}
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2018-01-06 22:38 Aric Belsito
0 siblings, 0 replies; 24+ messages in thread
From: Aric Belsito @ 2018-01-06 22:38 UTC (permalink / raw
To: gentoo-commits
commit: 66f05bf7536ef5dadde32b0faf4ad199eef90dab
Author: Aric Belsito <lluixhi <AT> gmail <DOT> com>
AuthorDate: Sat Jan 6 22:37:31 2018 +0000
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Sat Jan 6 22:37:31 2018 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=66f05bf7
toolchain.eclass: sync with upstream
eclass/toolchain.eclass | 90 ++++++++++++++++++++++++-------------------------
1 file changed, 44 insertions(+), 46 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index e3011d6..d3a06ea 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
@@ -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) die "Need to upgrade to at least EAPI=4" ;;
+ 4*|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 <<----
@@ -390,10 +389,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
@@ -496,7 +491,7 @@ toolchain_src_prepare() {
do_gcc_PIE_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
@@ -538,7 +533,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
@@ -648,20 +643,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
@@ -909,7 +904,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})}" )
@@ -922,7 +917,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
@@ -934,7 +929,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
@@ -998,7 +993,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}[crosscompile_opts_headers-only(-)]" ; then
confgcc+=(
"${confgcc_no_libc[@]}"
--with-sysroot="${PREFIX}"/${CTARGET}
@@ -1061,12 +1056,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 ) ;;
@@ -1232,23 +1227,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)
)
@@ -1487,7 +1485,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}}
@@ -1578,7 +1576,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}
@@ -1622,7 +1620,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
@@ -1789,7 +1787,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}}"
@@ -2083,7 +2081,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."
@@ -2248,13 +2246,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() {
@@ -2264,27 +2262,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() {
@@ -2294,7 +2292,7 @@ is_jit() {
is_multilib() {
tc_version_is_at_least 3 || return 1
- use multilib
+ use_if_iuse multilib
}
is_objc() {
@@ -2304,7 +2302,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)
@@ -2376,12 +2374,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."
@@ -2395,11 +2393,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
}
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2017-12-12 20:58 Anthony G. Basile
0 siblings, 0 replies; 24+ messages in thread
From: Anthony G. Basile @ 2017-12-12 20:58 UTC (permalink / raw
To: gentoo-commits
commit: df8d9caa171abe98f105241aaf1e3351d118a319
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 12 20:56:47 2017 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Tue Dec 12 20:57:20 2017 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=df8d9caa
toolchain.eclass: bring into line with in tree versions
eclass/toolchain.eclass | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index a07863c..e3011d6 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -90,8 +90,6 @@ if [[ ${SNAPSHOT} == [56789].0-* ]] ; then
SNAPSHOT=${SNAPSHOT/.0}
fi
-export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
-
PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
if tc_version_is_at_least 3.4.0 ; then
@@ -141,6 +139,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
[[ -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.3 && IUSE+=" pgo"
tc_version_is_at_least 4.0 && IUSE+=" objc-gc"
tc_version_is_between 4.0 4.9 && IUSE+=" mudflap"
tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
@@ -240,7 +239,7 @@ S=$(
gentoo_urls() {
local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI
- HTTP~tamiko/distfiles/URI"
+ HTTP~tamiko/distfiles/URI HTTP~slyfox/distfiles/URI"
devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
echo mirror://gentoo/$1 ${devspace//URI/$1}
}
@@ -379,9 +378,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"'
@@ -581,14 +577,14 @@ toolchain_src_prepare() {
einfo "Fixing misc issues in configure files"
for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
ebegin " Updating ${f/${S}\/} [LANG]"
- patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
+ patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
|| eerror "Please file a bug about this"
eend $?
done
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 "${GCC_FILESDIR}"/gcc-configure-texinfo.patch
+ tc_version_is_at_least 4.1 && epatch "${FILESDIR}"/gcc-configure-texinfo.patch
if [[ -x contrib/gcc_update ]] ; then
einfo "Touching generated files"
@@ -642,7 +638,15 @@ do_gcc_PIE_patches() {
make_gcc_hard() {
local gcc_hard_flags=""
- # Gcc >= 6.X we can use configuration options to turn pie/ssp on as default
+
+ # If we use gcc-6 or newer with pie enable to compile older gcc we need to pass -no-pie
+ # to stage1; bug 618908
+ if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
+ einfo "Disabling PIE in stage1 (only) ..."
+ sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
+ fi
+
+ # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
if tc_version_is_at_least 6.0 ; then
if use pie ; then
einfo "Updating gcc to use automatic PIE building ..."
@@ -651,7 +655,7 @@ make_gcc_hard() {
einfo "Updating gcc to use automatic SSP building ..."
fi
if use hardened ; then
- # Will add some optimizations by default.
+ # 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}
@@ -1481,7 +1485,8 @@ gcc_do_filter_flags() {
FFLAGS=${CFLAGS}
FCFLAGS=${CFLAGS}
- local VAR="CFLAGS_"${CTARGET//-/_}
+ # "hppa2.0-unknown-linux-gnu" -> hppa2_0_unknown_linux_gnu
+ local VAR="CFLAGS_"${CTARGET//[-.]/_}
CXXFLAGS=${!VAR}
fi
@@ -1573,7 +1578,11 @@ gcc_do_make() {
# resulting binaries natively ^^;
GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
else
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
+ if tc_version_is_at_least 3.3 && use pgo; then
+ GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
+ else
+ GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
+ fi
fi
# Older versions of GCC could not do profiledbootstrap in parallel due to
@@ -1782,10 +1791,10 @@ toolchain_src_install() {
# between binary and source package borks things ....
if ! is_crosscompile ; then
insinto "${DATAPATH#${EPREFIX}}"
- newins "$(prefixify_ro "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la)" fixlafiles.awk || die
+ newins "$(prefixify_ro "${FILESDIR}"/awk/fixlafiles.awk-no_gcc_la)" fixlafiles.awk || die
exeinto "${DATAPATH#${EPREFIX}}"
- doexe "$(prefixify_ro "${GCC_FILESDIR}"/fix_libtool_files.sh)" || die
- doexe "${GCC_FILESDIR}"/c{89,99} || die
+ doexe "$(prefixify_ro "${FILESDIR}"/fix_libtool_files.sh)" || die
+ doexe "${FILESDIR}"/c{89,99} || die
fi
# libstdc++.la: Delete as it doesn't add anything useful: g++ itself
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2017-11-29 20:00 Aric Belsito
0 siblings, 0 replies; 24+ messages in thread
From: Aric Belsito @ 2017-11-29 20:00 UTC (permalink / raw
To: gentoo-commits
commit: 28220ab69ae4359ea742a89dea2c127d719b70d0
Author: Aric Belsito <lluixhi <AT> gmail <DOT> com>
AuthorDate: Wed Nov 29 19:59:23 2017 +0000
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Wed Nov 29 19:59:23 2017 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=28220ab6
eclass: disable gold linker in qt5
eclass/qt5-build.eclass | 808 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 808 insertions(+)
diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass
new file mode 100644
index 0000000..82a2aaf
--- /dev/null
+++ b/eclass/qt5-build.eclass
@@ -0,0 +1,808 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: qt5-build.eclass
+# @MAINTAINER:
+# qt@gentoo.org
+# @AUTHOR:
+# Davide Pesavento <pesa@gentoo.org>
+# @SUPPORTED_EAPIS: 6
+# @BLURB: Eclass for Qt5 split ebuilds.
+# @DESCRIPTION:
+# This eclass contains various functions that are used when building Qt5.
+# Requires EAPI 6.
+
+if [[ ${CATEGORY} != dev-qt ]]; then
+ die "qt5-build.eclass is only to be used for building Qt 5."
+fi
+
+case ${EAPI} in
+ 6) : ;;
+ *) die "qt5-build.eclass: unsupported EAPI=${EAPI:-0}" ;;
+esac
+
+# @ECLASS-VARIABLE: QT5_MODULE
+# @PRE_INHERIT
+# @DESCRIPTION:
+# The upstream name of the module this package belongs to. Used for
+# SRC_URI and EGIT_REPO_URI. Must be set before inheriting the eclass.
+: ${QT5_MODULE:=${PN}}
+
+# @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Array variable containing the source directories that should be built.
+# All paths must be relative to ${S}.
+
+# @ECLASS-VARIABLE: QT5_GENTOO_CONFIG
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Array of <useflag:feature:macro> triplets that are evaluated in src_install
+# to generate the per-package list of enabled QT_CONFIG features and macro
+# definitions, which are then merged together with all other Qt5 packages
+# installed on the system to obtain the global qconfig.{h,pri} files.
+
+# @ECLASS-VARIABLE: VIRTUALX_REQUIRED
+# @DESCRIPTION:
+# For proper description see virtualx.eclass man page.
+# Here we redefine default value to be manual, if your package needs virtualx
+# for tests you should proceed with setting VIRTUALX_REQUIRED=test.
+: ${VIRTUALX_REQUIRED:=manual}
+
+inherit estack flag-o-matic ltprune toolchain-funcs versionator virtualx
+
+HOMEPAGE="https://www.qt.io/"
+LICENSE="|| ( GPL-2 GPL-3 LGPL-3 ) FDL-1.3"
+SLOT=5/$(get_version_component_range 1-2)
+
+QT5_MINOR_VERSION=$(get_version_component_range 2)
+QT5_PATCH_VERSION=$(get_version_component_range 3)
+readonly QT5_MINOR_VERSION QT5_PATCH_VERSION
+
+case ${PV} in
+ 5.9999)
+ # git dev branch
+ QT5_BUILD_TYPE="live"
+ EGIT_BRANCH="dev"
+ ;;
+ 5.?.9999|5.??.9999|5.???.9999)
+ # git stable branch
+ QT5_BUILD_TYPE="live"
+ EGIT_BRANCH=${PV%.9999}
+ ;;
+ *_alpha*|*_beta*|*_rc*)
+ # development release
+ QT5_BUILD_TYPE="release"
+ MY_P=${QT5_MODULE}-opensource-src-${PV/_/-}
+ SRC_URI="https://download.qt.io/development_releases/qt/${PV%.*}/${PV/_/-}/submodules/${MY_P}.tar.xz"
+ S=${WORKDIR}/${MY_P}
+ ;;
+ *)
+ # official stable release
+ QT5_BUILD_TYPE="release"
+ MY_P=${QT5_MODULE}-opensource-src-${PV}
+ SRC_URI="https://download.qt.io/official_releases/qt/${PV%.*}/${PV}/submodules/${MY_P}.tar.xz"
+ S=${WORKDIR}/${MY_P}
+ ;;
+esac
+readonly QT5_BUILD_TYPE
+
+EGIT_REPO_URI=(
+ "https://code.qt.io/qt/${QT5_MODULE}.git"
+ "https://github.com/qt/${QT5_MODULE}.git"
+)
+[[ ${QT5_BUILD_TYPE} == live ]] && inherit git-r3
+
+# @ECLASS-VARIABLE: QT5_BUILD_DIR
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# Build directory for out-of-source builds.
+case ${QT5_BUILD_TYPE} in
+ live) : ${QT5_BUILD_DIR:=${S}_build} ;;
+ release) : ${QT5_BUILD_DIR:=${S}} ;; # workaround for bug 497312
+esac
+
+IUSE="debug test"
+
+[[ ${PN} == qtwebkit ]] && RESTRICT+=" mirror" # bug 524584
+[[ ${QT5_BUILD_TYPE} == release ]] && RESTRICT+=" test" # bug 457182
+
+DEPEND="
+ dev-lang/perl
+ virtual/pkgconfig
+"
+if [[ (${PN} != qttest && ${PN} != qtwebkit) || (${PN} == qtwebkit && ${QT5_MINOR_VERSION} -lt 9) ]]; then
+ DEPEND+=" test? ( ~dev-qt/qttest-${PV} )"
+fi
+RDEPEND="
+ dev-qt/qtchooser
+"
+
+
+###### Phase functions ######
+
+EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
+
+# @FUNCTION: qt5-build_src_unpack
+# @DESCRIPTION:
+# Unpacks the sources.
+qt5-build_src_unpack() {
+ if tc-is-gcc; then
+ local min_gcc4_minor_version=7
+ if [[ $(gcc-major-version) -lt 4 ]] || \
+ [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt ${min_gcc4_minor_version} ]]; then
+ eerror "GCC version 4.${min_gcc4_minor_version} or later is required to build this package"
+ die "GCC 4.${min_gcc4_minor_version} or later required"
+ fi
+ fi
+
+ # bug 307861
+ if [[ ${PN} == qtwebengine || ${PN} == qtwebkit ]]; then
+ eshopts_push -s extglob
+ if is-flagq '-g?(gdb)?([1-9])'; then
+ ewarn
+ ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
+ ewarn "You may experience really long compilation times and/or increased memory usage."
+ ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
+ ewarn
+ fi
+ eshopts_pop
+ fi
+
+ case ${QT5_BUILD_TYPE} in
+ live) git-r3_src_unpack ;;
+ release) default ;;
+ esac
+}
+
+# @FUNCTION: qt5-build_src_prepare
+# @DESCRIPTION:
+# Prepares the environment and patches the sources if necessary.
+qt5-build_src_prepare() {
+ qt5_prepare_env
+
+ if [[ ${QT5_MODULE} == qtbase ]]; then
+ qt5_symlink_tools_to_build_dir
+
+ # Avoid unnecessary qmake recompilations
+ if [[ ${QT5_MINOR_VERSION} -ge 8 ]]; then
+ sed -i -e "/Creating qmake/i if [ '!' -e \"\$outpath/bin/qmake\" ]; then" \
+ -e '/echo "Done."/a fi' \
+ configure || die "sed failed (skip qmake bootstrap)"
+ else
+ sed -i -re "s|^if true;.*(\[ '\!').*(\"\\\$outpath/bin/qmake\".*)|if \1 -e \2 then|" \
+ configure || die "sed failed (skip qmake bootstrap)"
+ fi
+
+ # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when bootstrapping qmake
+ sed -i -e "/outpath\/qmake\".*\"\$MAKE\")/ s:): \
+ ${MAKEOPTS} ${EXTRA_EMAKE} 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \
+ 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&:" \
+ -e 's/\(setBootstrapVariable\s\+\|EXTRA_C\(XX\)\?FLAGS=.*\)QMAKE_C\(XX\)\?FLAGS_\(DEBUG\|RELEASE\).*/:/' \
+ configure || die "sed failed (respect env for qmake build)"
+ sed -i -e '/^CPPFLAGS\s*=/ s/-g //' \
+ qmake/Makefile.unix || die "sed failed (CPPFLAGS for qmake build)"
+
+ # Respect CXX in bsymbolic_functions, fvisibility, precomp, and a few other tests
+ sed -i -e "/^QMAKE_CONF_COMPILER=/ s:=.*:=\"$(tc-getCXX)\":" \
+ configure || die "sed failed (QMAKE_CONF_COMPILER)"
+
+ if [[ ${QT5_MINOR_VERSION} -le 7 ]]; then
+ # Respect toolchain and flags in config.tests
+ find config.tests/unix -name '*.test' -type f -execdir \
+ sed -i -e 's/-nocache //' '{}' + || die
+ fi
+
+ # Don't inject -msse/-mavx/... into CXXFLAGS when detecting
+ # compiler support for extended instruction sets (bug 552942)
+ find config.tests/common -name '*.pro' -type f -execdir \
+ sed -i -e '/QMAKE_CXXFLAGS\s*+=/ d' '{}' + || die
+
+ # Don't add -O3 to CXXFLAGS (bug 549140)
+ sed -i -e '/CONFIG\s*+=/ s/optimize_full//' \
+ src/{corelib/corelib,gui/gui}.pro || die "sed failed (optimize_full)"
+ fi
+
+ default
+}
+
+# @FUNCTION: qt5-build_src_configure
+# @DESCRIPTION:
+# Runs qmake in the target directories. For packages
+# in qtbase, ./configure is also run before qmake.
+qt5-build_src_configure() {
+ if [[ ${QT5_MODULE} == qtbase ]]; then
+ qt5_base_configure
+ fi
+
+ qt5_foreach_target_subdir qt5_qmake
+}
+
+# @FUNCTION: qt5-build_src_compile
+# @DESCRIPTION:
+# Runs emake in the target directories.
+qt5-build_src_compile() {
+ qt5_foreach_target_subdir emake
+}
+
+# @FUNCTION: qt5-build_src_test
+# @DESCRIPTION:
+# Runs tests in the target directories.
+qt5-build_src_test() {
+ # disable broken cmake tests (bug 474004)
+ local myqmakeargs=("${myqmakeargs[@]}" -after SUBDIRS-=cmake SUBDIRS-=installed_cmake)
+
+ qt5_foreach_target_subdir qt5_qmake
+ qt5_foreach_target_subdir emake
+
+ # create a custom testrunner script that correctly sets
+ # LD_LIBRARY_PATH before executing the given test
+ local testrunner=${QT5_BUILD_DIR}/gentoo-testrunner
+ cat > "${testrunner}" <<-_EOF_ || die
+ #!/bin/sh
+ export LD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
+ "\$@"
+ _EOF_
+ chmod +x "${testrunner}"
+
+ set -- qt5_foreach_target_subdir emake TESTRUNNER="'${testrunner}'" check
+ if [[ ${VIRTUALX_REQUIRED} == test ]]; then
+ virtx "$@"
+ else
+ "$@"
+ fi
+}
+
+# @FUNCTION: qt5-build_src_install
+# @DESCRIPTION:
+# Runs emake install in the target directories.
+qt5-build_src_install() {
+ qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install
+
+ if [[ ${PN} == qtcore ]]; then
+ pushd "${QT5_BUILD_DIR}" >/dev/null || die
+
+ set -- emake INSTALL_ROOT="${D}" \
+ sub-qmake-qmake-aux-pro-install_subtargets \
+ install_{syncqt,mkspecs}
+
+ einfo "Running $*"
+ "$@"
+
+ popd >/dev/null || die
+
+ docompress -x "${QT5_DOCDIR#${EPREFIX}}"/global
+
+ # install an empty Gentoo/gentoo-qconfig.h in ${D}
+ # so that it's placed under package manager control
+ > "${T}"/gentoo-qconfig.h
+ (
+ insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
+ doins "${T}"/gentoo-qconfig.h
+ )
+
+ # include gentoo-qconfig.h at the beginning of QtCore/qconfig.h
+ sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
+ "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \
+ || die "sed failed (qconfig.h)"
+
+ # install qtchooser configuration file
+ cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_ || die
+ ${QT5_BINDIR}
+ ${QT5_LIBDIR}
+ _EOF_
+
+ (
+ insinto /etc/xdg/qtchooser
+ doins "${T}/qt5-${CHOST}.conf"
+ )
+
+ # convenience symlinks
+ dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf
+ dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf
+ fi
+
+ qt5_install_module_qconfigs
+ prune_libtool_files
+}
+
+# @FUNCTION: qt5-build_pkg_postinst
+# @DESCRIPTION:
+# Regenerate configuration after installation or upgrade/downgrade.
+qt5-build_pkg_postinst() {
+ qt5_regenerate_global_qconfigs
+}
+
+# @FUNCTION: qt5-build_pkg_postrm
+# @DESCRIPTION:
+# Regenerate configuration when a module is completely removed.
+qt5-build_pkg_postrm() {
+ if [[ -z ${REPLACED_BY_VERSION} && ${PN} != qtcore ]]; then
+ qt5_regenerate_global_qconfigs
+ fi
+}
+
+
+###### Public helpers ######
+
+# @FUNCTION: qt_use
+# @USAGE: <flag> [feature] [enableval]
+# @DESCRIPTION:
+# <flag> is the name of a flag in IUSE.
+#
+# Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
+# otherwise. If [feature] is not specified, <flag> is used in its place.
+# If [enableval] is not specified, the "-${enableval}" prefix is omitted.
+qt_use() {
+ [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
+
+ usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
+}
+
+# @FUNCTION: qt_use_compile_test
+# @USAGE: <flag> [config]
+# @DESCRIPTION:
+# <flag> is the name of a flag in IUSE.
+# [config] is the argument of qtCompileTest, defaults to <flag>.
+#
+# This function is useful to disable optional dependencies that are checked
+# at qmake-time using the qtCompileTest() function. If <flag> is disabled,
+# the compile test is skipped and the dependency is assumed to be unavailable,
+# i.e. the corresponding feature will be disabled. Note that all invocations
+# of this function must happen before calling qt5-build_src_configure.
+qt_use_compile_test() {
+ [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
+
+ if ! use "$1"; then
+ mkdir -p "${QT5_BUILD_DIR}" || die
+ echo "CONFIG += done_config_${2:-$1}" >> "${QT5_BUILD_DIR}"/.qmake.cache || die
+ fi
+}
+
+# @FUNCTION: qt_use_disable_config
+# @USAGE: <flag> <config> <files...>
+# @DESCRIPTION:
+# <flag> is the name of a flag in IUSE.
+# <config> is the (lowercase) name of a Qt5 config entry.
+# <files...> is a list of one or more qmake project files.
+#
+# This function patches <files> to treat <config> as disabled
+# when <flag> is disabled, otherwise it does nothing.
+# This can be useful to avoid an automagic dependency when the config entry
+# is enabled on the system but the corresponding USE flag is disabled.
+qt_use_disable_config() {
+ [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
+
+ local flag=$1
+ local config=$2
+ shift 2
+
+ if ! use "${flag}"; then
+ echo "$@" | xargs sed -i -e "s/qtConfig(${config})/false/g" || die
+ fi
+}
+
+# @FUNCTION: qt_use_disable_mod
+# @USAGE: <flag> <module> <files...>
+# @DESCRIPTION:
+# <flag> is the name of a flag in IUSE.
+# <module> is the (lowercase) name of a Qt5 module.
+# <files...> is a list of one or more qmake project files.
+#
+# This function patches <files> to treat <module> as not installed
+# when <flag> is disabled, otherwise it does nothing.
+# This can be useful to avoid an automagic dependency when the module
+# is present on the system but the corresponding USE flag is disabled.
+qt_use_disable_mod() {
+ [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
+
+ local flag=$1
+ local module=$2
+ shift 2
+
+ if ! use "${flag}"; then
+ echo "$@" | xargs sed -i -e "s/qtHaveModule(${module})/false/g" || die
+ fi
+}
+
+
+###### Internal functions ######
+
+# @FUNCTION: qt5_prepare_env
+# @INTERNAL
+# @DESCRIPTION:
+# Prepares the environment for building Qt.
+qt5_prepare_env() {
+ # setup installation directories
+ # note: keep paths in sync with qmake-utils.eclass
+ QT5_PREFIX=${EPREFIX}/usr
+ QT5_HEADERDIR=${QT5_PREFIX}/include/qt5
+ QT5_LIBDIR=${QT5_PREFIX}/$(get_libdir)
+ QT5_ARCHDATADIR=${QT5_PREFIX}/$(get_libdir)/qt5
+ QT5_BINDIR=${QT5_ARCHDATADIR}/bin
+ QT5_PLUGINDIR=${QT5_ARCHDATADIR}/plugins
+ QT5_LIBEXECDIR=${QT5_ARCHDATADIR}/libexec
+ QT5_IMPORTDIR=${QT5_ARCHDATADIR}/imports
+ QT5_QMLDIR=${QT5_ARCHDATADIR}/qml
+ QT5_DATADIR=${QT5_PREFIX}/share/qt5
+ QT5_DOCDIR=${QT5_PREFIX}/share/doc/qt-${PV}
+ QT5_TRANSLATIONDIR=${QT5_DATADIR}/translations
+ QT5_EXAMPLESDIR=${QT5_DATADIR}/examples
+ QT5_TESTSDIR=${QT5_DATADIR}/tests
+ QT5_SYSCONFDIR=${EPREFIX}/etc/xdg
+ readonly QT5_PREFIX QT5_HEADERDIR QT5_LIBDIR QT5_ARCHDATADIR \
+ QT5_BINDIR QT5_PLUGINDIR QT5_LIBEXECDIR QT5_IMPORTDIR \
+ QT5_QMLDIR QT5_DATADIR QT5_DOCDIR QT5_TRANSLATIONDIR \
+ QT5_EXAMPLESDIR QT5_TESTSDIR QT5_SYSCONFDIR
+
+ if [[ ${QT5_MODULE} == qtbase ]]; then
+ # see mkspecs/features/qt_config.prf
+ export QMAKEMODULES="${QT5_BUILD_DIR}/mkspecs/modules:${S}/mkspecs/modules:${QT5_ARCHDATADIR}/mkspecs/modules"
+ fi
+}
+
+# @FUNCTION: qt5_foreach_target_subdir
+# @INTERNAL
+# @DESCRIPTION:
+# Executes the command given as argument from inside each directory
+# listed in QT5_TARGET_SUBDIRS. Handles autotests subdirs automatically.
+qt5_foreach_target_subdir() {
+ [[ -z ${QT5_TARGET_SUBDIRS[@]} ]] && QT5_TARGET_SUBDIRS=("")
+
+ local subdir=
+ for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
+ if [[ ${EBUILD_PHASE} == test ]]; then
+ subdir=tests/auto${subdir#src}
+ [[ -d ${S}/${subdir} ]] || continue
+ fi
+
+ local msg="Running $* ${subdir:+in ${subdir}}"
+ einfo "${msg}"
+
+ mkdir -p "${QT5_BUILD_DIR}/${subdir}" || die -n || return $?
+ pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die -n || return $?
+
+ "$@" || die -n "${msg} failed" || return $?
+
+ popd >/dev/null || die -n || return $?
+ done
+}
+
+# @FUNCTION: qt5_symlink_tools_to_build_dir
+# @INTERNAL
+# @DESCRIPTION:
+# Symlinks qmake and a few other tools to QT5_BUILD_DIR,
+# so that they can be used when building other modules.
+qt5_symlink_tools_to_build_dir() {
+ local tool= tools=()
+ if [[ ${PN} != qtcore ]]; then
+ tools+=(qmake moc rcc qlalr)
+ [[ ${PN} != qtdbus ]] && tools+=(qdbuscpp2xml qdbusxml2cpp)
+ [[ ${PN} != qtwidgets ]] && tools+=(uic)
+ fi
+
+ mkdir -p "${QT5_BUILD_DIR}"/bin || die
+ pushd "${QT5_BUILD_DIR}"/bin >/dev/null || die
+
+ for tool in "${tools[@]}"; do
+ [[ -e ${QT5_BINDIR}/${tool} ]] || continue
+ ln -s "${QT5_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
+ done
+
+ popd >/dev/null || die
+}
+
+# @FUNCTION: qt5_base_configure
+# @INTERNAL
+# @DESCRIPTION:
+# Runs ./configure for modules belonging to qtbase.
+qt5_base_configure() {
+ # setup toolchain variables used by configure
+ tc-export AR CC CXX OBJDUMP RANLIB STRIP
+ export LD="$(tc-getCXX)"
+
+ # bug 633838
+ if [[ ${QT5_MINOR_VERSION} -ge 9 ]]; then
+ unset QMAKESPEC XQMAKESPEC QMAKEPATH QMAKEFEATURES
+ fi
+
+ # configure arguments
+ local conf=(
+ # installation paths
+ -prefix "${QT5_PREFIX}"
+ -bindir "${QT5_BINDIR}"
+ -headerdir "${QT5_HEADERDIR}"
+ -libdir "${QT5_LIBDIR}"
+ -archdatadir "${QT5_ARCHDATADIR}"
+ -plugindir "${QT5_PLUGINDIR}"
+ -libexecdir "${QT5_LIBEXECDIR}"
+ -importdir "${QT5_IMPORTDIR}"
+ -qmldir "${QT5_QMLDIR}"
+ -datadir "${QT5_DATADIR}"
+ -docdir "${QT5_DOCDIR}"
+ -translationdir "${QT5_TRANSLATIONDIR}"
+ -sysconfdir "${QT5_SYSCONFDIR}"
+ -examplesdir "${QT5_EXAMPLESDIR}"
+ -testsdir "${QT5_TESTSDIR}"
+
+ # configure in release mode by default,
+ # override via the CONFIG qmake variable
+ -release
+ -no-separate-debug-info
+
+ # no need to forcefully build host tools in optimized mode,
+ # just follow the overall debug/release build type
+ -no-optimized-tools
+
+ # licensing stuff
+ -opensource -confirm-license
+
+ # autodetect the highest supported version of the C++ standard
+ #-c++std <c++11|c++14|c++1z>
+
+ # build shared libraries
+ -shared
+
+ # always enable large file support
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -largefile)
+
+ # disabling accessibility is not recommended by upstream, as
+ # it will break QStyle and may break other internal parts of Qt
+ -accessibility
+
+ # disable all SQL drivers by default, override in qtsql
+ -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc
+ -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds
+
+ # ensure the QML debugging support (qmltooling) is built in qtdeclarative
+ -qml-debug
+
+ # MIPS DSP instruction set extensions
+ $(is-flagq -mno-dsp && echo -no-mips_dsp)
+ $(is-flagq -mno-dspr2 && echo -no-mips_dspr2)
+
+ # use pkg-config to detect include and library paths
+ -pkg-config
+
+ # prefer system libraries (only common hard deps here)
+ -system-zlib
+ -system-pcre
+ -system-doubleconversion
+
+ # disable everything to prevent automagic deps (part 1)
+ -no-mtdev
+ -no-journald -no-syslog
+ -no-libpng -no-libjpeg
+ -no-freetype -no-harfbuzz
+ -no-openssl -no-libproxy
+ -no-xkbcommon-x11 -no-xkbcommon-evdev
+ -no-xinput2 -no-xcb-xlib
+
+ # cannot use -no-gif because there is no way to override it later
+ #-no-gif
+
+ # always enable glib event loop support
+ -glib
+
+ # disable everything to prevent automagic deps (part 2)
+ -no-gtk
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-pulseaudio -no-alsa)
+
+ # exclude examples and tests from default build
+ -nomake examples
+ -nomake tests
+ -no-compile-examples
+
+ # disable rpath on non-prefix (bugs 380415 and 417169)
+ $(usex prefix '' -no-rpath)
+
+ # print verbose information about each configure test
+ -verbose
+
+ # always enable iconv support
+ # since 5.8 this is handled in qtcore
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -iconv)
+
+ # disable everything to prevent automagic deps (part 3)
+ -no-cups -no-evdev -no-tslib -no-icu -no-fontconfig -no-dbus
+
+ # let portage handle stripping
+ -no-strip
+
+ # precompiled headers can cause problems on hardened, so turn them off
+ -no-pch
+
+ # link-time code generation is not something we want to enable by default
+ -no-ltcg
+
+ # reduced relocations cause major breakage on at least arm and ppc, so
+ # don't specify anything and let the configure figure out if they are
+ # supported; see also https://bugreports.qt.io/browse/QTBUG-36129
+ #-reduce-relocations
+
+ # let configure automatically detect if GNU gold is available
+ -no-use-gold-linker
+
+ # disable all platform plugins by default, override in qtgui
+ -no-xcb -no-eglfs -no-kms -no-gbm -no-directfb -no-linuxfb -no-mirclient
+
+ # disable undocumented X11-related flags, override in qtgui
+ # (not shown in ./configure -help output)
+ -no-xkb
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-xrender)
+
+ # disable obsolete/unused X11-related flags
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-mitshm -no-xcursor -no-xfixes -no-xrandr -no-xshape -no-xsync)
+
+ # always enable session management support: it doesn't need extra deps
+ # at configure time and turning it off is dangerous, see bug 518262
+ -sm
+
+ # typedef qreal to double (warning: changing this flag breaks the ABI)
+ -qreal double
+
+ # disable OpenGL and EGL support by default, override in qtgui,
+ # qtopengl, qtprintsupport and qtwidgets
+ -no-opengl -no-egl
+
+ # disable libinput-based generic plugin by default, override in qtgui
+ -no-libinput
+
+ # disable gstreamer by default, override in qtmultimedia
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-gstreamer)
+
+ # respect system proxies by default: it's the most natural
+ # setting, and it'll become the new upstream default in 5.8
+ -system-proxies
+
+ # do not build with -Werror
+ -no-warnings-are-errors
+
+ # module-specific options
+ "${myconf[@]}"
+ )
+
+ pushd "${QT5_BUILD_DIR}" >/dev/null || die
+
+ einfo "Configuring with: ${conf[@]}"
+ "${S}"/configure "${conf[@]}" || die "configure failed"
+
+ if [[ ${QT5_MINOR_VERSION} -ge 8 ]]; then
+ # a forwarding header is no longer created since 5.8, causing the system
+ # config to always be used. bug 599636
+ cp src/corelib/global/qconfig.h include/QtCore/ || die
+ fi
+
+ popd >/dev/null || die
+
+}
+
+# @FUNCTION: qt5_qmake
+# @INTERNAL
+# @DESCRIPTION:
+# Helper function that runs qmake in the current target subdir.
+# Intended to be called by qt5_foreach_target_subdir().
+qt5_qmake() {
+ local projectdir=${PWD/#${QT5_BUILD_DIR}/${S}}
+ local qmakepath=
+ if [[ ${QT5_MODULE} == qtbase ]]; then
+ qmakepath=${QT5_BUILD_DIR}/bin
+ else
+ qmakepath=${QT5_BINDIR}
+ fi
+
+ "${qmakepath}"/qmake \
+ "${projectdir}" \
+ CONFIG+=$(usex debug debug release) \
+ CONFIG-=$(usex debug release debug) \
+ QMAKE_AR="$(tc-getAR) cqs" \
+ QMAKE_CC="$(tc-getCC)" \
+ QMAKE_LINK_C="$(tc-getCC)" \
+ QMAKE_LINK_C_SHLIB="$(tc-getCC)" \
+ QMAKE_CXX="$(tc-getCXX)" \
+ QMAKE_LINK="$(tc-getCXX)" \
+ QMAKE_LINK_SHLIB="$(tc-getCXX)" \
+ QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
+ QMAKE_RANLIB= \
+ QMAKE_STRIP="$(tc-getSTRIP)" \
+ QMAKE_CFLAGS="${CFLAGS}" \
+ QMAKE_CFLAGS_RELEASE= \
+ QMAKE_CFLAGS_DEBUG= \
+ QMAKE_CXXFLAGS="${CXXFLAGS}" \
+ QMAKE_CXXFLAGS_RELEASE= \
+ QMAKE_CXXFLAGS_DEBUG= \
+ QMAKE_LFLAGS="${LDFLAGS}" \
+ QMAKE_LFLAGS_RELEASE= \
+ QMAKE_LFLAGS_DEBUG= \
+ "${myqmakeargs[@]}" \
+ || die "qmake failed (${projectdir#${S}/})"
+}
+
+# @FUNCTION: qt5_install_module_qconfigs
+# @INTERNAL
+# @DESCRIPTION:
+# Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
+qt5_install_module_qconfigs() {
+ local x qconfig_add= qconfig_remove=
+
+ > "${T}"/${PN}-qconfig.h
+ > "${T}"/${PN}-qconfig.pri
+
+ # generate qconfig_{add,remove} and ${PN}-qconfig.h
+ for x in "${QT5_GENTOO_CONFIG[@]}"; do
+ local flag=${x%%:*}
+ x=${x#${flag}:}
+ local feature=${x%%:*}
+ x=${x#${feature}:}
+ local macro=${x}
+ macro=$(tr 'a-z-' 'A-Z_' <<< "${macro}")
+
+ if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then
+ [[ -n ${feature} ]] && qconfig_add+=" ${feature}"
+ [[ -n ${macro} ]] && echo "#define QT_${macro}" >> "${T}"/${PN}-qconfig.h
+ else
+ [[ -n ${feature} ]] && qconfig_remove+=" ${feature}"
+ [[ -n ${macro} ]] && echo "#define QT_NO_${macro}" >> "${T}"/${PN}-qconfig.h
+ fi
+ done
+
+ # install ${PN}-qconfig.h
+ [[ -s ${T}/${PN}-qconfig.h ]] && (
+ insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
+ doins "${T}"/${PN}-qconfig.h
+ )
+
+ # generate and install ${PN}-qconfig.pri
+ [[ -n ${qconfig_add} ]] && echo "QCONFIG_ADD=${qconfig_add}" >> "${T}"/${PN}-qconfig.pri
+ [[ -n ${qconfig_remove} ]] && echo "QCONFIG_REMOVE=${qconfig_remove}" >> "${T}"/${PN}-qconfig.pri
+ [[ -s ${T}/${PN}-qconfig.pri ]] && (
+ insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
+ doins "${T}"/${PN}-qconfig.pri
+ )
+}
+
+# @FUNCTION: qt5_regenerate_global_qconfigs
+# @INTERNAL
+# @DESCRIPTION:
+# Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
+# Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
+qt5_regenerate_global_qconfigs() {
+ einfo "Regenerating gentoo-qconfig.h"
+
+ find "${ROOT%/}${QT5_HEADERDIR}"/Gentoo \
+ -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \
+ -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h
+
+ [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty"
+ mv -f "${T}"/gentoo-qconfig.h "${ROOT%/}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \
+ || eerror "Failed to install new gentoo-qconfig.h"
+
+ einfo "Updating QT_CONFIG in qconfig.pri"
+
+ local qconfig_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri
+ if [[ -f ${qconfig_pri} ]]; then
+ local x qconfig_add= qconfig_remove=
+ local qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri}")
+ local new_qt_config=
+
+ # generate list of QT_CONFIG entries from the existing list,
+ # appending QCONFIG_ADD and excluding QCONFIG_REMOVE
+ eshopts_push -s nullglob
+ for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
+ qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")"
+ qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")"
+ done
+ eshopts_pop
+ for x in ${qt_config} ${qconfig_add}; do
+ if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then
+ new_qt_config+=" ${x}"
+ fi
+ done
+
+ # now replace the existing QT_CONFIG with the generated list
+ sed -i -e "s/^QT_CONFIG\s*+=.*/QT_CONFIG +=${new_qt_config}/" \
+ "${qconfig_pri}" || eerror "Failed to sed QT_CONFIG in ${qconfig_pri}"
+ else
+ ewarn "${qconfig_pri} does not exist or is not a regular file"
+ fi
+}
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2017-09-05 19:13 Aric Belsito
0 siblings, 0 replies; 24+ messages in thread
From: Aric Belsito @ 2017-09-05 19:13 UTC (permalink / raw
To: gentoo-commits
commit: 57dbfdd6d2ed16648783e4bc61637c8d1f7e04d4
Author: Aric Belsito <lluixhi <AT> gmail <DOT> com>
AuthorDate: Tue Sep 5 19:12:38 2017 +0000
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Tue Sep 5 19:12:38 2017 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=57dbfdd6
toolchain.eclass: sync with upstream
eclass/toolchain.eclass | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index b996315..a07863c 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -2070,6 +2070,9 @@ gcc_slot_java() {
toolchain_pkg_postinst() {
do_gcc_config
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
+ eselect compiler-shadow update all
+ fi
if ! is_crosscompile ; then
echo
@@ -2108,6 +2111,10 @@ toolchain_pkg_postinst() {
}
toolchain_pkg_postrm() {
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
+ eselect compiler-shadow clean all
+ fi
+
# to make our lives easier (and saner), we do the fix_libtool stuff here.
# rather than checking SLOT's and trying in upgrade paths, we just see if
# the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2017-05-06 21:30 Aric Belsito
0 siblings, 0 replies; 24+ messages in thread
From: Aric Belsito @ 2017-05-06 21:30 UTC (permalink / raw
To: gentoo-commits
commit: 0144c5895bbf7a204f0077904a388b8e78931054
Author: Matthias Maier <tamiko <AT> 43-1 <DOT> org>
AuthorDate: Sat May 6 18:41:28 2017 +0000
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com>
CommitDate: Sat May 6 18:41:28 2017 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=0144c589
toolchain.eclass: enable pie and ssp for gcc >= 6 for #615370
Take over upstream commit
commit 4000cdde4281ffef9b61da83f16a30547131259a
Author: William Hubbs <williamh <AT> gentoo.org>
Date: Sat May 6 10:31:31 2017 -0500
toolchain.eclass: enable pie and ssp for gcc >= 6 for #615370
eclass/toolchain.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 191cfad..f42e58e 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -153,7 +153,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
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_at_least 5.0 && IUSE+=" jit mpx"
- tc_version_is_at_least 6.0 && IUSE+=" pie ssp +pch"
+ tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
fi
IUSE+=" ${IUSE_DEF[*]/#/+}"
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2016-05-03 8:51 Anthony G. Basile
0 siblings, 0 replies; 24+ messages in thread
From: Anthony G. Basile @ 2016-05-03 8:51 UTC (permalink / raw
To: gentoo-commits
commit: 1b84859faa3792c2f3431945c48b07d25bc055cb
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Tue May 3 08:52:00 2016 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Tue May 3 08:52:00 2016 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=1b84859f
toolchain.eclass: add gcc 6 support
eclass/toolchain.eclass | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index a272810..1192f62 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -153,7 +153,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
# 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"
- tc_version_is_at_least 5.0 && IUSE+=" jit"
+ tc_version_is_at_least 5.0 && IUSE+=" jit pch"
tc_version_is_at_least 6.0 && IUSE+=" pie +ssp"
fi
@@ -626,6 +626,23 @@ do_gcc_PIE_patches() {
# configure to build with the hardened GCC specs as the default
make_gcc_hard() {
+
+ # Gcc >= 6.X we don't need to sed in Makefile
+ # It have configurations options to turn pie/ssp on as default
+ if tc_version_is_at_least 6.0 ; then
+ if use hardened ; then
+ # rebrand to make bug reports easier
+ BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
+ fi
+ if use pie ; then
+ einfo "Updating gcc to use automatic PIE building ..."
+ fi
+ if use ssp ; then
+ einfo "Updating gcc to use automatic SSP building ..."
+ fi
+ return 1
+ fi
+
# we want to be able to control the pie patch logic via something other
# than ALL_CFLAGS...
sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
@@ -899,6 +916,11 @@ toolchain_src_configure() {
confgcc+=( --enable-libstdcxx-time )
fi
+ # Support to disable pch when building libstdcxx
+ if tc_version_is_at_least 5.0 && ! use pch ; then
+ confgcc+=( --disable-libstdcxx-pch )
+ fi
+
# The jit language requires this.
is_jit && confgcc+=( --enable-host-shared )
@@ -1915,6 +1937,11 @@ create_gcc_env_entry() {
}
copy_minispecs_gcc_specs() {
+ # on gcc 6 we don't need minispecs
+ if tc_version_is_at_least 6.0 ; then
+ return 0
+ fi
+
# setup the hardenedno* specs files and the vanilla specs file.
if hardened_gcc_works ; then
create_gcc_env_entry hardenednopiessp
@@ -2263,6 +2290,10 @@ hardened_gcc_is_stable() {
}
want_minispecs() {
+ # on gcc 6 we don't need minispecs
+ if tc_version_is_at_least 6.0 ; then
+ return 0
+ fi
if tc_version_is_at_least 4.3.2 && use hardened ; then
if ! want_pie ; then
ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2016-05-03 8:32 Anthony G. Basile
0 siblings, 0 replies; 24+ messages in thread
From: Anthony G. Basile @ 2016-05-03 8:32 UTC (permalink / raw
To: gentoo-commits
commit: b954e8da3988230fd889d69536103e1fc0149813
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Tue May 3 08:32:48 2016 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Tue May 3 08:32:48 2016 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=b954e8da
toolchain.eclass: sync with tree
eclass/toolchain.eclass | 92 +++++++++++++++++++++++++++++++++++--------------
1 file changed, 66 insertions(+), 26 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 066fc42..a272810 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -104,6 +104,7 @@ INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
if is_crosscompile ; then
BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
+ HOSTLIBPATH=${PREFIX}/${CHOST}/${CTARGET}/lib/${GCC_CONFIG_VER}
else
BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
fi
@@ -152,17 +153,13 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
# 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"
+ tc_version_is_at_least 5.0 && IUSE+=" jit"
tc_version_is_at_least 6.0 && IUSE+=" pie +ssp"
fi
IUSE+=" ${IUSE_DEF[*]/#/+}"
-# Support upgrade paths here or people get pissed
-if ! tc_version_is_at_least 4.7 || is_crosscompile || use multislot || [[ ${GCC_PV} == *_alpha* ]] ; then
- SLOT="${GCC_CONFIG_VER}"
-else
- SLOT="${GCC_BRANCH_VER}"
-fi
+SLOT="${GCC_CONFIG_VER}"
#---->> DEPEND <<----
@@ -656,7 +653,7 @@ make_gcc_hard() {
ewarn "PIE has not been enabled by default"
gcc_hard_flags+=" -DEFAULT_SSP"
else
- # do nothing if hardened is't supported, but don't die either
+ # do nothing if hardened isn't supported, but don't die either
ewarn "hardened is not supported for this arch in this gcc version"
return 0
fi
@@ -838,6 +835,7 @@ toolchain_src_configure() {
is_d && GCC_LANG+=",d"
is_gcj && GCC_LANG+=",java"
is_go && GCC_LANG+=",go"
+ is_jit && GCC_LANG+=",jit"
if is_objc || is_objcxx ; then
GCC_LANG+=",objc"
if tc_version_is_at_least 4 ; then
@@ -901,6 +899,9 @@ toolchain_src_configure() {
confgcc+=( --enable-libstdcxx-time )
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
# # This helps with locating debug files.
# case ${CTARGET} in
@@ -1502,7 +1503,7 @@ toolchain_src_compile() {
# Do not make manpages if we do not have perl ...
[[ ! -x /usr/bin/perl ]] \
- && find "${WORKDIR}"/build -name '*.[17]' | xargs touch
+ && find "${WORKDIR}"/build -name '*.[17]' -exec touch {} +
gcc_do_make ${GCC_MAKE_TARGET}
}
@@ -1660,7 +1661,12 @@ toolchain_src_install() {
for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do
# For some reason, g77 gets made instead of ${CTARGET}-g77...
# this should take care of that
- [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
+ if [[ -f ${x} ]] ; then
+ # In case they're hardlinks, clear out the target first
+ # otherwise the mv below will complain.
+ rm -f ${CTARGET}-${x}
+ mv ${x} ${CTARGET}-${x}
+ fi
if [[ -f ${CTARGET}-${x} ]] ; then
if ! is_crosscompile ; then
@@ -1678,9 +1684,18 @@ toolchain_src_install() {
ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
fi
done
+ # Rename the main go binaries as we don't want to clobber dev-lang/go
+ # when gcc-config runs. #567806
+ if tc_version_is_at_least 5 && is_go ; then
+ for x in go gofmt; do
+ mv ${x} ${x}-${GCCMAJOR} || die
+ done
+ fi
# Now do the fun stripping stuff
env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
+ is_crosscompile && \
+ env RESTRICT="" CHOST=${CHOST} prepstrip "${D}/${HOSTLIBPATH}"
env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
# gcc used to install helper binaries in lib/ but then moved to libexec/
[[ -d ${D}${PREFIX}/libexec/gcc ]] && \
@@ -1710,9 +1725,8 @@ toolchain_src_install() {
# install testsuite results
if use regression-test; then
docinto testsuite
- find "${WORKDIR}"/build -type f -name "*.sum" -print0 | xargs -0 dodoc
- find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -print0 \
- | xargs -0 dodoc
+ 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
@@ -1762,6 +1776,17 @@ gcc_movelibs() {
# older versions of gcc did not support --print-multi-os-directory
tc_version_is_at_least 3.2 || return 0
+ # For non-target libs which are for CHOST and not CTARGET, we want to
+ # move them to the compiler-specific CHOST internal dir. This is stuff
+ # that you want to link against when building tools rather than building
+ # code to run on the target.
+ if tc_version_is_at_least 5 && is_crosscompile ; then
+ dodir "${HOSTLIBPATH}"
+ mv "${D}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
+ fi
+
+ # For all the libs that are built for CTARGET, move them into the
+ # compiler-specific CTARGET internal dir.
local x multiarg removedirs=""
for multiarg in $($(XGCC) -print-multi-lib) ; do
multiarg=${multiarg#*;}
@@ -1807,7 +1832,7 @@ gcc_movelibs() {
for FROMDIR in ${removedirs} ; do
rmdir "${D}"${FROMDIR} >& /dev/null
done
- find "${D}" -type d | xargs rmdir >& /dev/null
+ find -depth "${D}" -type d -exec rmdir {} + >& /dev/null
}
# make sure the libtool archives have libdir set to where they actually
@@ -1957,7 +1982,7 @@ toolchain_pkg_postinst() {
echo
ewarn "You might want to review the GCC upgrade guide when moving between"
ewarn "major versions (like 4.2 to 4.3):"
- ewarn "https://www.gentoo.org/doc/en/gcc-upgrading.xml"
+ ewarn "https://wiki.gentoo.org/wiki/Upgrading_GCC"
echo
# Clean up old paths
@@ -2025,26 +2050,36 @@ do_gcc_config() {
return 0
fi
- local current_gcc_config="" current_specs="" use_specs=""
+ local current_gcc_config target
current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
if [[ -n ${current_gcc_config} ]] ; then
+ local current_specs use_specs
# figure out which specs-specific config is active
current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
[[ -n ${current_specs} ]] && use_specs=-${current_specs}
- fi
- if [[ -n ${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"
- ewarn "due to enabling/disabling hardened or switching to a version"
- ewarn "of gcc that doesnt create multiple specs files. The default"
- ewarn "config will be used, and the previous preference forgotten."
- use_specs=""
+
+ if [[ -n ${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"
+ ewarn "due to enabling/disabling hardened or switching to a version"
+ ewarn "of gcc that doesnt create multiple specs files. The default"
+ ewarn "config will be used, and the previous preference forgotten."
+ use_specs=""
+ fi
+
+ target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
+ else
+ # The curent target is invalid. Attempt to switch to a valid one.
+ # Blindly pick the latest version. #529608
+ # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
+ # doing a partial grep like this.
+ target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
fi
- gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs}
+ gcc-config "${target}"
}
should_we_gcc_config() {
@@ -2143,6 +2178,11 @@ is_go() {
use cxx && use_if_iuse go
}
+is_jit() {
+ gcc-lang-supported jit || return 1
+ use_if_iuse jit
+}
+
is_multilib() {
tc_version_is_at_least 3 || return 1
use multilib
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2015-10-02 21:30 Anthony G. Basile
0 siblings, 0 replies; 24+ messages in thread
From: Anthony G. Basile @ 2015-10-02 21:30 UTC (permalink / raw
To: gentoo-commits
commit: df5ea96a502a015fdc64ee8d9491f6c492bba209
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 2 21:35:31 2015 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Fri Oct 2 21:35:31 2015 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=df5ea96a
toolchain.eclass: update http -> https
eclass/toolchain.eclass | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 44e08af..066fc42 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -5,7 +5,7 @@
# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
DESCRIPTION="The GNU Compiler Collection"
-HOMEPAGE="http://gcc.gnu.org/"
+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 versionator
@@ -238,7 +238,7 @@ S=$(
gentoo_urls() {
local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI"
- devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/}
+ devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
echo mirror://gentoo/$1 ${devspace//URI/$1}
}
@@ -1617,7 +1617,7 @@ toolchain_src_install() {
# 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:
- # http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
+ # 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
@@ -1957,7 +1957,7 @@ toolchain_pkg_postinst() {
echo
ewarn "You might want to review the GCC upgrade guide when moving between"
ewarn "major versions (like 4.2 to 4.3):"
- ewarn "http://www.gentoo.org/doc/en/gcc-upgrading.xml"
+ ewarn "https://www.gentoo.org/doc/en/gcc-upgrading.xml"
echo
# Clean up old paths
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2015-08-30 15:32 Anthony G. Basile
0 siblings, 0 replies; 24+ messages in thread
From: Anthony G. Basile @ 2015-08-30 15:32 UTC (permalink / raw
To: gentoo-commits
commit: 96907bfdfec76098d7b12ec6eabbdecb65dd29f0
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 30 15:36:24 2015 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sun Aug 30 15:36:24 2015 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=96907bfd
toolchain.eclass: sync to the tree version.
eclass/toolchain.eclass | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index f4e651c..44e08af 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.675 2015/06/01 16:05:43 vapier Exp $
+# $Id$
# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
@@ -152,7 +152,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
# 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"
- tc_version_is_at_least 6.0 && IUSE+=" pie"
+ tc_version_is_at_least 6.0 && IUSE+=" pie +ssp"
fi
IUSE+=" ${IUSE_DEF[*]/#/+}"
@@ -172,7 +172,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 >=dev-libs/mpfr-2.4.2"
+ 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
@@ -180,7 +180,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"
+tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0"
if in_iuse graphite ; then
if tc_version_is_at_least 5.0 ; then
@@ -213,10 +213,6 @@ if in_iuse gcj ; then
x11-proto/xextproto
=x11-libs/gtk+-2*
virtual/pkgconfig
- amd64? ( multilib? (
- app-emulation/emul-linux-x86-gtklibs
- app-emulation/emul-linux-x86-xlibs
- ) )
"
tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
@@ -882,7 +878,9 @@ 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
- confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes release)}" )
+ # 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})}" )
fi
# Branding
@@ -1195,7 +1193,11 @@ toolchain_src_configure() {
fi
if tc_version_is_at_least 6.0 ; then
- confgcc+=( $(use_enable pie default-pie) )
+ confgcc+=(
+ $(use_enable pie default-pie)
+ # This defaults to -fstack-protector-strong.
+ $(use_enable ssp default-ssp)
+ )
fi
# Disable gcc info regeneration -- it ships with generated info pages
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [gentoo-commits] proj/musl:master commit in: eclass/
@ 2015-06-12 20:09 Anthony G. Basile
0 siblings, 0 replies; 24+ messages in thread
From: Anthony G. Basile @ 2015-06-12 20:09 UTC (permalink / raw
To: gentoo-commits
commit: aee379fa9eb0bcee1126dff5568b16e8d119835d
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 12 20:11:21 2015 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Fri Jun 12 20:11:21 2015 +0000
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=aee379fa
eclass/toolchain.eclass: follow tree version.
eclass/toolchain.eclass | 153 ++++++++++++++++++++++++------------------------
1 file changed, 78 insertions(+), 75 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index f6e451a..f4e651c 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,6 +1,6 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.635 2014/08/05 01:41:01 floppym Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.675 2015/06/01 16:05:43 vapier Exp $
# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
@@ -26,7 +26,7 @@ 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) ;;
+ 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}."
@@ -37,8 +37,8 @@ EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
export CTARGET=${CTARGET:-${CHOST}}
if [[ ${CTARGET} = ${CHOST} ]] ; then
- if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
- export CTARGET=${CATEGORY/cross-}
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
fi
fi
: ${TARGET_ABI:=${ABI}}
@@ -86,9 +86,9 @@ elif [[ ${GCC_PV} == *_rc* ]] ; then
SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
fi
-if [[ ${SNAPSHOT} == 5.0-* ]] ; then
- # The gcc-5 release has dropped the .0 for some reason.
- SNAPSHOT=${SNAPSHOT/5.0/5}
+if [[ ${SNAPSHOT} == [56789].0-* ]] ; then
+ # The gcc-5+ releases have dropped the .0 for some reason.
+ SNAPSHOT=${SNAPSHOT/.0}
fi
export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
@@ -134,7 +134,7 @@ IUSE="multislot regression-test vanilla"
IUSE_DEF=( nls nptl )
if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
- IUSE+=" altivec"
+ IUSE+=" altivec debug"
IUSE_DEF+=( cxx fortran )
[[ -n ${PIE_VER} ]] && IUSE+=" nopie"
[[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
@@ -146,16 +146,19 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
tc_version_is_at_least 4.2 && IUSE_DEF+=( openmp )
tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
- tc_version_is_at_least 4.6 && IUSE+=" graphite"
tc_version_is_at_least 4.7 && IUSE+=" go"
- tc_version_is_at_least 4.8 && IUSE_DEF+=( sanitize )
+ # 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" IUSE_DEF+=( sanitize )
+ tc_version_is_at_least 4.9 && IUSE+=" cilk"
+ tc_version_is_at_least 6.0 && IUSE+=" pie"
fi
-[[ ${EAPI:-0} != 0 ]] && IUSE_DEF=( "${IUSE_DEF[@]/#/+}" )
-IUSE+=" ${IUSE_DEF[*]}"
+IUSE+=" ${IUSE_DEF[*]/#/+}"
# Support upgrade paths here or people get pissed
-if ! tc_version_is_at_least 4.7 || use multislot ; then
+if ! tc_version_is_at_least 4.7 || is_crosscompile || use multislot || [[ ${GCC_PV} == *_alpha* ]] ; then
SLOT="${GCC_CONFIG_VER}"
else
SLOT="${GCC_BRANCH_VER}"
@@ -180,18 +183,14 @@ fi
tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1"
if in_iuse graphite ; then
- if tc_version_is_at_least 4.8 ; then
+ if tc_version_is_at_least 5.0 ; then
+ RDEPEND+=" graphite? ( >=dev-libs/isl-0.14 )"
+ elif tc_version_is_at_least 4.8 ; then
RDEPEND+="
graphite? (
>=dev-libs/cloog-0.18.0
>=dev-libs/isl-0.11.1
)"
- else
- RDEPEND+="
- graphite? (
- >=dev-libs/cloog-ppl-0.15.10
- >=dev-libs/ppl-0.11
- )"
fi
fi
@@ -242,7 +241,7 @@ S=$(
gentoo_urls() {
local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
- HTTP~halcy0n/patches/URI HTTP~zorry/patches/gcc/URI"
+ HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI"
devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/}
echo mirror://gentoo/$1 ${devspace//URI/$1}
}
@@ -392,8 +391,8 @@ toolchain_pkg_pretend() {
#---->> pkg_setup <<----
toolchain_pkg_setup() {
- case "${EAPI:-0}" in
- 0|1|2|3) toolchain_pkg_pretend ;;
+ case ${EAPI} in
+ 2|3) toolchain_pkg_pretend ;;
esac
# we dont want to use the installed compiler's specs to build gcc
@@ -409,10 +408,6 @@ toolchain_src_unpack() {
else
gcc_quick_unpack
fi
-
- case ${EAPI:-0} in
- 0|1) toolchain_src_prepare ;;
- esac
}
gcc_quick_unpack() {
@@ -886,10 +881,8 @@ 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 4 || [[ -n ${GCC_CHECKS_LIST} ]] ; then
- confgcc+=( --enable-checking=${GCC_CHECKS_LIST:-release} )
- else
- confgcc+=( --disable-checking )
+ if tc_version_is_at_least 3.4 ; then
+ confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes release)}" )
fi
# Branding
@@ -1040,9 +1033,9 @@ toolchain_src_configure() {
*)
# If they've explicitly opt-ed in, do hardfloat,
# otherwise let the gcc default kick in.
- [[ ${CTARGET//_/-} == *-hardfloat-* ]] \
- && confgcc+=( --with-float=hard )
- ;;
+ case ${CTARGET//_/-} in
+ *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
+ esac
esac
local with_abi_map=()
@@ -1088,7 +1081,7 @@ toolchain_src_configure() {
amd64)
# drop the older/ABI checks once this get's merged into some
# version of gcc upstream
- if tc_version_is_at_least 4.7 && has x32 $(get_all_abis TARGET) ; then
+ if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
fi
;;
@@ -1167,7 +1160,10 @@ toolchain_src_configure() {
fi
confgcc+=( --disable-libssp )
fi
+ fi
+ if in_iuse cilk ; then
+ confgcc+=( $(use_enable cilk libcilkrts) )
fi
# newer gcc's come with libquadmath, but only fortran uses
@@ -1182,27 +1178,26 @@ toolchain_src_configure() {
confgcc+=( --disable-lto )
fi
- # graphite was added in 4.4 but we only support it in 4.6+ due to external
- # library issues. 4.6/4.7 uses cloog-ppl which is a fork of CLooG with a
- # PPL backend. 4.8+ uses upstream CLooG with the ISL backend. We install
- # cloog-ppl into a non-standard location to prevent collisions.
- if tc_version_is_at_least 4.8 ; then
- confgcc+=( $(use_with graphite cloog) )
+ # 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
+ confgcc+=( $(use_with graphite isl) )
use graphite && confgcc+=( --disable-isl-version-check )
- elif tc_version_is_at_least 4.6 ; then
+ elif tc_version_is_at_least 4.8 ; then
confgcc+=( $(use_with graphite cloog) )
- confgcc+=( $(use_with graphite ppl) )
- use graphite && confgcc+=( --with-cloog-include=/usr/include/cloog-ppl )
- use graphite && confgcc+=( --disable-ppl-version-check )
+ use graphite && confgcc+=( --disable-isl-version-check )
elif tc_version_is_at_least 4.4 ; then
- confgcc+=( --without-cloog )
- confgcc+=( --without-ppl )
+ confgcc+=( --without-{cloog,ppl} )
fi
if tc_version_is_at_least 4.8 ; then
confgcc+=( $(use_enable sanitize libsanitizer) )
fi
+ if tc_version_is_at_least 6.0 ; then
+ confgcc+=( $(use_enable pie default-pie) )
+ fi
+
# Disable gcc info regeneration -- it ships with generated info pages
# already. Our custom version/urls/etc... trigger it. #464008
export gcc_cv_prog_makeinfo_modern=no
@@ -1235,7 +1230,10 @@ toolchain_src_configure() {
# and now to do the actual configuration
addwrite /dev/zero
echo "${S}"/configure "${confgcc[@]}"
- "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
+ # Older gcc versions did not detect bash and re-exec itself, so force the
+ # use of bash. Newer ones will auto-detect, but this is not harmeful.
+ CONFIG_SHELL="/bin/bash" \
+ bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
# return to whatever directory we were in before
popd > /dev/null
@@ -1474,7 +1472,7 @@ gcc-multilib-configure() {
if [[ -n ${list} ]] ; then
case ${CTARGET} in
x86_64*)
- tc_version_is_at_least 4.7 && confgcc+=( --with-multilib-list=${list:1} )
+ tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} )
;;
esac
fi
@@ -1498,10 +1496,6 @@ gcc-abi-map() {
#----> src_compile <----
toolchain_src_compile() {
- case ${EAPI:-0} in
- 0|1) toolchain_src_configure ;;
- esac
-
touch "${S}"/gcc/c-gperf.h
# Do not make manpages if we do not have perl ...
@@ -1576,6 +1570,13 @@ gcc_do_make() {
cd "${CTARGET}"/libstdc++-v3
emake doxygen-man || ewarn "failed to make docs"
fi
+ # Clean bogus manpages. #113902
+ find -name '*_build_*' -delete
+ # Blow away generated directory references. Newer versions of gcc
+ # have gotten better at this, but not perfect. This is easier than
+ # backporting all of the various doxygen patches. #486754
+ find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
+ xargs rm -f
else
ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
fi
@@ -1611,8 +1612,12 @@ toolchain_src_install() {
fi
done
- # Remove generated headers, as they can cause things to break
- # (ncurses, openssl, etc).
+ # 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:
+ # http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
+ # This is because bsd userland needs fixedincludes to build gcc, while
+ # linux does not. Both can dispose of them afterwards.
while read x ; do
grep -q 'It has been auto-edited by fixincludes from' "${x}" \
&& rm -f "${x}"
@@ -1687,8 +1692,6 @@ toolchain_src_install() {
if tc_version_is_at_least 3.0 ; then
local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
if [[ -d ${cxx_mandir} ]] ; then
- # clean bogus manpages #113902
- find "${cxx_mandir}" -name '*_build_*' -exec rm {} \;
cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
fi
fi
@@ -1714,13 +1717,9 @@ toolchain_src_install() {
# between binary and source package borks things ....
if ! is_crosscompile ; then
insinto "${DATAPATH}"
- if tc_version_is_at_least 4.0 ; then
- newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die
- find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \;
- find "${D}/${LIBPATH}" -name "lib?san.la" -type f -exec rm "{}" \; # 487550
- else
- doins "${GCC_FILESDIR}"/awk/fixlafiles.awk || die
- fi
+ newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die
+ find "${D}/${LIBPATH}" -name libstdc++.la -type f -delete
+ find "${D}/${LIBPATH}" -name 'lib*san.la' -type f -delete #487550 #546700
exeinto "${DATAPATH}"
doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die
doexe "${GCC_FILESDIR}"/c{89,99} || die
@@ -1784,7 +1783,7 @@ gcc_movelibs() {
if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
if [[ -n ${files} ]] ; then
- mv ${files} "${TODIR}"
+ mv ${files} "${TODIR}" || die
fi
fi
done
@@ -1794,7 +1793,7 @@ gcc_movelibs() {
FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
[[ -f ${x} ]] || continue
- sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}"
+ sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}" || die
mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
done
done
@@ -1813,21 +1812,25 @@ gcc_movelibs() {
# -are-, and not where they -used- to be. also, any dependencies we have
# on our own .la files need to be updated.
fix_libtool_libdir_paths() {
+ local libpath="$1"
+
pushd "${D}" >/dev/null
- pushd "./${1}" >/dev/null
+ pushd "./${libpath}" >/dev/null
local dir="${PWD#${D%/}}"
local allarchives=$(echo *.la)
allarchives="\(${allarchives// /\\|}\)"
popd >/dev/null
- sed -i \
- -e "/^libdir=/s:=.*:='${dir}':" \
- ./${dir}/*.la
- sed -i \
- -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${LIBPATH}/\1:g" \
- $(find ./${PREFIX}/lib* -maxdepth 3 -name '*.la') \
- ./${dir}/*.la
+ # The libdir might not have any .la files. #548782
+ find "./${dir}" -maxdepth 1 -name '*.la' \
+ -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
+ # Would be nice to combine these, but -maxdepth can not be specified
+ # on sub-expressions.
+ find "./${PREFIX}"/lib* -maxdepth 3 -name '*.la' \
+ -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
+ find "./${dir}/" -maxdepth 1 -name '*.la' \
+ -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
popd >/dev/null
}
^ permalink raw reply related [flat|nested] 24+ messages in thread
end of thread, other threads:[~2021-11-20 23:24 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-26 0:04 [gentoo-commits] proj/musl:master commit in: eclass/ Aric Belsito
-- strict thread matches above, loose matches on Subject: below --
2021-11-20 23:24 Sam James
2021-11-17 11:48 Sam James
2021-11-17 11:47 Sam James
2019-08-28 21:29 Jory Pratt
2019-05-20 21:04 Jory Pratt
2019-05-05 16:49 Jory Pratt
2019-04-11 12:55 Anthony G. Basile
2019-02-24 17:14 Anthony G. Basile
2019-01-05 0:44 Anthony G. Basile
2018-05-17 18:15 Aric Belsito
2018-05-03 18:31 Aric Belsito
2018-04-14 17:41 Aric Belsito
2018-01-25 19:48 Aric Belsito
2018-01-06 22:38 Aric Belsito
2017-12-12 20:58 Anthony G. Basile
2017-11-29 20:00 Aric Belsito
2017-09-05 19:13 Aric Belsito
2017-05-06 21:30 Aric Belsito
2016-05-03 8:51 Anthony G. Basile
2016-05-03 8:32 Anthony G. Basile
2015-10-02 21:30 Anthony G. Basile
2015-08-30 15:32 Anthony G. Basile
2015-06-12 20:09 Anthony G. Basile
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox