eclass/toolchain: Sync with Gentoo

It's from Gentoo commit c7cd3be059f221c6333980f155c1bafca9769ed0.
This commit is contained in:
Flatcar Buildbot 2023-06-19 07:15:02 +00:00
parent bb47e62c08
commit 3ed40b2c26

View File

@ -22,7 +22,6 @@ _TOOLCHAIN_ECLASS=1
DESCRIPTION="The GNU Compiler Collection" DESCRIPTION="The GNU Compiler Collection"
HOMEPAGE="https://gcc.gnu.org/" HOMEPAGE="https://gcc.gnu.org/"
[[ ${EAPI} == 7 ]] && inherit eutils
inherit edo flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix inherit edo flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
tc_is_live() { tc_is_live() {
@ -61,7 +60,6 @@ is_crosscompile() {
[[ ${CHOST} != ${CTARGET} ]] [[ ${CHOST} != ${CTARGET} ]]
} }
# @FUNCTION: tc_version_is_at_least # @FUNCTION: tc_version_is_at_least
# @USAGE: ver1 [ver2] # @USAGE: ver1 [ver2]
# @DESCRIPTION: # @DESCRIPTION:
@ -200,7 +198,7 @@ fi
# Require minimum gcc version to simplify assumptions. # Require minimum gcc version to simplify assumptions.
# Normally we would require gcc-6+ (based on sys-devel/gcc) # Normally we would require gcc-6+ (based on sys-devel/gcc)
# but we still have sys-devel/gcc-apple-4.2.1_p5666. # but we still have sys-devel/gcc-apple-4.2.1_p5666.
tc_version_is_at_least 4.2.1 || die "${ECLASS}: ${GCC_RELEASE_VER} is too old." tc_version_is_at_least 8 || die "${ECLASS}: ${GCC_RELEASE_VER} is too old."
PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr} PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
@ -234,11 +232,8 @@ tc_has_feature() {
if [[ ${PN} != kgcc64 && ${PN} != gcc-* ]] ; then if [[ ${PN} != kgcc64 && ${PN} != gcc-* ]] ; then
IUSE+=" debug +cxx +nptl" TC_FEATURES+=( nptl ) IUSE+=" debug +cxx +nptl" TC_FEATURES+=( nptl )
[[ -n ${PIE_VER} ]] && IUSE+=" nopie"
[[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
IUSE+=" +fortran" TC_FEATURES+=( fortran ) IUSE+=" +fortran" TC_FEATURES+=( fortran )
IUSE+=" doc hardened multilib objc" IUSE+=" doc hardened multilib objc"
tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=( gcj )
IUSE+=" pgo" IUSE+=" pgo"
IUSE+=" objc-gc" TC_FEATURES+=( objc-gc ) IUSE+=" objc-gc" TC_FEATURES+=( objc-gc )
IUSE+=" libssp objc++" IUSE+=" libssp objc++"
@ -251,31 +246,16 @@ if [[ ${PN} != kgcc64 && ${PN} != gcc-* ]] ; then
IUSE+=" +openmp" IUSE+=" +openmp"
fi fi
tc_version_is_at_least 4.3 && IUSE+=" fixed-point" IUSE+=" fixed-point"
tc_version_is_at_least 4.7 && IUSE+=" go" IUSE+=" go"
IUSE+=" +sanitize" TC_FEATURES+=( sanitize )
# 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 ) IUSE+=" graphite" TC_FEATURES+=( graphite )
IUSE+=" ada"
tc_version_is_between 4.9 8 && IUSE+=" cilk" IUSE+=" vtv"
tc_version_is_at_least 4.9 && IUSE+=" ada" IUSE+=" jit"
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_between 5.0 9 && IUSE+=" mpx"
tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch" IUSE+=" +pie +ssp +pch"
# systemtap is a gentoo-specific switch: bug #654748
tc_version_is_at_least 8.0 &&
IUSE+=" systemtap" TC_FEATURES+=( systemtap ) IUSE+=" systemtap" TC_FEATURES+=( systemtap )
tc_version_is_at_least 9.0 && IUSE+=" d" TC_FEATURES+=( d ) tc_version_is_at_least 9.0 && IUSE+=" d" TC_FEATURES+=( d )
@ -311,18 +291,11 @@ RDEPEND="
" "
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}"
RDEPEND+=" ${GMP_MPFR_DEPS}" RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
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_has_feature objc-gc ; then
if tc_version_is_at_least 7 ; then
RDEPEND+=" objc-gc? ( >=dev-libs/boehm-gc-7.4.2 )" RDEPEND+=" objc-gc? ( >=dev-libs/boehm-gc-7.4.2 )"
fi
fi fi
if tc_has_feature graphite ; then if tc_has_feature graphite ; then
@ -347,25 +320,6 @@ if [[ ${PN} == gcc && ${PV} == *_p* ]] ; then
BDEPEND+=" sys-apps/texinfo" BDEPEND+=" sys-apps/texinfo"
fi fi
if tc_has_feature gcj ; then
DEPEND+="
gcj? (
app-arch/zip
app-arch/unzip
>=media-libs/libart_lgpl-2.1
awt? (
x11-base/xorg-proto
x11-libs/libXt
x11-libs/libX11
x11-libs/libXtst
=x11-libs/gtk+-2*
x11-libs/pango
virtual/pkgconfig
)
)
"
fi
if tc_has_feature sanitize ; then if tc_has_feature sanitize ; then
# libsanitizer relies on 'crypt.h' to be present # libsanitizer relies on 'crypt.h' to be present
# on target. glibc user to provide it unconditionally. # on target. glibc user to provide it unconditionally.
@ -475,7 +429,8 @@ gentoo_urls() {
HTTP~tamiko/distfiles/URI HTTP~tamiko/distfiles/URI
HTTP~zorry/patches/gcc/URI HTTP~zorry/patches/gcc/URI
HTTP~vapier/dist/URI HTTP~vapier/dist/URI
HTTP~blueness/dist/URI" HTTP~blueness/dist/URI
"
devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/} devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
echo ${devspace//URI/$1} mirror://gentoo/$1 echo ${devspace//URI/$1} mirror://gentoo/$1
} }
@ -504,36 +459,9 @@ gentoo_urls() {
# The resulting filename of this tarball will be: # The resulting filename of this tarball will be:
# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.xz # gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.xz
# #
# PIE_VER
# PIE_GCC_VER
# These variables control patching in various updates for the logic
# controlling Position Independent Executables. PIE_VER is expected
# to be the version of this patch, and PIE_GCC_VER the gcc version of
# the patch:
# An example:
# PIE_VER="8.7.6.5"
# PIE_GCC_VER="3.4.0"
# The resulting filename of this tarball will be:
# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.xz
#
# SPECS_VER
# SPECS_GCC_VER
# This is for the minispecs files included in the hardened gcc-4.x
# The specs files for hardenedno*, vanilla and for building the "specs" file.
# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
# the gcc version of the patch.
# An example:
# SPECS_VER="8.7.6.5"
# SPECS_GCC_VER="3.4.0"
# The resulting filename of this tarball will be:
# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.xz
#
get_gcc_src_uri() { get_gcc_src_uri() {
export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
export MUSL_GCC_VER=${MUSL_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 # Set where to download gcc itself depending on whether we're using a
# live git tree, snapshot, or release tarball. # live git tree, snapshot, or release tarball.
@ -545,17 +473,10 @@ get_gcc_src_uri() {
elif [[ -n ${SNAPSHOT} ]] ; then elif [[ -n ${SNAPSHOT} ]] ; then
GCC_SRC_URI="mirror://gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz" GCC_SRC_URI="mirror://gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz"
else 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=" GCC_SRC_URI="
mirror://gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz mirror://gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz
mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz
" "
else
GCC_SRC_URI="
mirror://gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2
mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2
"
fi
fi fi
[[ -n ${PATCH_VER} ]] && \ [[ -n ${PATCH_VER} ]] && \
@ -563,22 +484,6 @@ get_gcc_src_uri() {
[[ -n ${MUSL_VER} ]] && \ [[ -n ${MUSL_VER} ]] && \
GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})" GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
[[ -n ${PIE_VER} ]] && \
PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX}} && \
GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
# gcc minispec for the hardened gcc 4 compiler
[[ -n ${SPECS_VER} ]] && \
GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
if tc_has_feature gcj ; then
if tc_version_is_at_least 4.5 ; then
GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
elif tc_version_is_at_least 4.3 ; then
GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
fi
fi
echo "${GCC_SRC_URI}" echo "${GCC_SRC_URI}"
} }
@ -592,11 +497,7 @@ toolchain_pkg_pretend() {
ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"' ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
_tc_use_if_iuse objc++ && \ _tc_use_if_iuse objc++ && \
ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"' 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 fi
want_minispecs
} }
#---->> pkg_setup <<---- #---->> pkg_setup <<----
@ -664,7 +565,6 @@ toolchain_src_prepare() {
cd "${S}" || die cd "${S}" || die
do_gcc_gentoo_patches do_gcc_gentoo_patches
do_gcc_PIE_patches
if tc_is_live ; then if tc_is_live ; then
BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, commit ${EGIT_VERSION}" BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, commit ${EGIT_VERSION}"
@ -672,8 +572,7 @@ toolchain_src_prepare() {
eapply_user eapply_user
if ( tc_version_is_at_least 4.8.2 || _tc_use_if_iuse hardened ) \ if ! use vanilla ; then
&& ! use vanilla ; then
make_gcc_hard make_gcc_hard
fi fi
@ -684,7 +583,6 @@ toolchain_src_prepare() {
-exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} + || die -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} + || die
setup_multilib_osdirnames setup_multilib_osdirnames
gcc_version_patch
local actual_version=$(< "${S}"/gcc/BASE-VER) local actual_version=$(< "${S}"/gcc/BASE-VER)
if [[ "${GCC_RELEASE_VER}" != "${actual_version}" ]] ; then if [[ "${GCC_RELEASE_VER}" != "${actual_version}" ]] ; then
@ -692,23 +590,6 @@ toolchain_src_prepare() {
die "Please set 'TOOLCHAIN_GCC_PV' to '${actual_version}'" die "Please set 'TOOLCHAIN_GCC_PV' to '${actual_version}'"
fi 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 # Fixup libtool to correctly generate .la files with portage
elibtoolize --portage --shallow --no-uclibc elibtoolize --portage --shallow --no-uclibc
@ -724,11 +605,6 @@ toolchain_src_prepare() {
eend $? eend $?
done done
# bug #215828
if ! tc_version_is_at_least 4.6.0 ; then
sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die
fi
if ! use prefix-guest && [[ -n ${EPREFIX} ]] ; then if ! use prefix-guest && [[ -n ${EPREFIX} ]] ; then
einfo "Prefixifying dynamic linkers..." einfo "Prefixifying dynamic linkers..."
for f in gcc/config/*/*linux*.h ; do for f in gcc/config/*/*linux*.h ; do
@ -780,46 +656,30 @@ do_gcc_gentoo_patches() {
fi fi
} }
do_gcc_PIE_patches() {
want_pie || return 0
use vanilla && return 0
einfo "Applying PIE patches ..."
eapply "${WORKDIR}"/piepatch/*.patch
BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
}
# configure to build with the hardened GCC specs as the default # configure to build with the hardened GCC specs as the default
make_gcc_hard() { make_gcc_hard() {
local gcc_hard_flags="" local gcc_hard_flags=""
# If we use gcc-6 or newer with PIE enabled to compile older gcc,
# we need to pass -no-pie to stage1; bug #618908
if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
einfo "Disabling PIE in stage1 (only) ..."
sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
fi
# For gcc >= 6.x, we can use configuration options to turn PIE/SSP
# on as default
if tc_version_is_at_least 6.0 ; then
if _tc_use_if_iuse pie ; then if _tc_use_if_iuse pie ; then
einfo "Updating gcc to use automatic PIE building ..." einfo "Updating gcc to use automatic PIE building ..."
fi fi
if _tc_use_if_iuse ssp ; then if _tc_use_if_iuse ssp ; then
einfo "Updating gcc to use automatic SSP building ..." einfo "Updating gcc to use automatic SSP building ..."
fi fi
if _tc_use_if_iuse default-stack-clash-protection ; then if _tc_use_if_iuse default-stack-clash-protection ; then
# The define DEF_GENTOO_SCP is checked in 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch # The define DEF_GENTOO_SCP is checked in 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
einfo "Updating gcc to use automatic stack clash protection ..." einfo "Updating gcc to use automatic stack clash protection ..."
gcc_hard_flags+=" -DDEF_GENTOO_SCP" gcc_hard_flags+=" -DDEF_GENTOO_SCP"
fi fi
if _tc_use_if_iuse default-znow ; then if _tc_use_if_iuse default-znow ; then
# The define DEF_GENTOO_ZNOW is checked in 23_all_DEF_GENTOO_ZNOW-z-now.patch # The define DEF_GENTOO_ZNOW is checked in 23_all_DEF_GENTOO_ZNOW-z-now.patch
einfo "Updating gcc to request symbol resolution at start (-z now) ..." einfo "Updating gcc to request symbol resolution at start (-z now) ..."
gcc_hard_flags+=" -DDEF_GENTOO_ZNOW" gcc_hard_flags+=" -DDEF_GENTOO_ZNOW"
fi fi
if _tc_use_if_iuse hardened ; then if _tc_use_if_iuse hardened ; then
# Will add some hardened options as default, e.g. for gcc-12 # Will add some hardened options as default, e.g. for gcc-12
# * -fstack-clash-protection # * -fstack-clash-protection
@ -838,45 +698,16 @@ make_gcc_hard() {
# Rebrand to make bug reports easier # Rebrand to make bug reports easier
BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened} BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
fi 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 # We want to be able to control the PIE patch logic via something other
# than ALL_CFLAGS... # than ALL_CFLAGS...
sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \ sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
-e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \ -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
-i "${S}"/gcc/Makefile.in || die -i "${S}"/gcc/Makefile.in || die
# Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
if tc_version_is_at_least 4.7 ; then
sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \ sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \ -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
-i "${S}"/gcc/Makefile.in || die -i "${S}"/gcc/Makefile.in || die
fi
sed -i \ sed -i \
-e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \ -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
@ -932,24 +763,6 @@ setup_multilib_osdirnames() {
sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die 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 <<---- #---->> src_configure <<----
toolchain_src_configure() { toolchain_src_configure() {
@ -970,12 +783,6 @@ toolchain_src_configure() {
# issues with 3rd party jar implementations. bug #384291 # issues with 3rd party jar implementations. bug #384291
export JAR=no export JAR=no
# For hardened gcc 4.3: add the pie patchset to build the hardened specs
# file (build.specs) to use when building gcc.
if ! tc_version_is_at_least 4.4 && want_minispecs ; then
setup_minispecs_gcc_build_specs
fi
local confgcc=( --host=${CHOST} ) local confgcc=( --host=${CHOST} )
local build_config_targets=() local build_config_targets=()
@ -1008,16 +815,13 @@ toolchain_src_configure() {
# then --with-python-dir=/lib/python2.5/site-packages should be passed. # then --with-python-dir=/lib/python2.5/site-packages should be passed.
# #
# This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python" # 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 ) confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
fi
### language options ### language options
local GCC_LANG="c" local GCC_LANG="c"
is_cxx && GCC_LANG+=",c++" is_cxx && GCC_LANG+=",c++"
is_d && GCC_LANG+=",d" is_d && GCC_LANG+=",d"
is_gcj && GCC_LANG+=",java"
is_go && GCC_LANG+=",go" is_go && GCC_LANG+=",go"
if is_objc || is_objcxx ; then if is_objc || is_objcxx ; then
GCC_LANG+=",objc" GCC_LANG+=",objc"
@ -1075,7 +879,7 @@ toolchain_src_configure() {
fi fi
# Branding # Branding
tc_version_is_at_least 4.3 && confgcc+=( confgcc+=(
--with-bugurl=https://bugs.gentoo.org/ --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion="${BRANDING_GCC_PKGVERSION}" --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
) )
@ -1084,25 +888,16 @@ toolchain_src_configure() {
confgcc+=( --with-gcc-major-version-only ) confgcc+=( --with-gcc-major-version-only )
fi fi
# If we want hardened support with the newer PIE patchset for >=gcc 4.4
if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then
confgcc+=( $(use_enable hardened esp) )
fi
# Allow gcc to search for clock funcs in the main C lib. # Allow gcc to search for clock funcs in the main C lib.
# if it can't find them, then tough cookies -- we aren't # if it can't find them, then tough cookies -- we aren't
# going to link in -lrt to all C++ apps. bug #411681 # going to link in -lrt to all C++ apps. bug #411681
if tc_version_is_at_least 4.4 && is_cxx ; then if is_cxx ; then
confgcc+=( --enable-libstdcxx-time ) confgcc+=( --enable-libstdcxx-time )
fi fi
# This only controls whether the compiler *supports* LTO, not whether # This only controls whether the compiler *supports* LTO, not whether
# it's *built using* LTO. Hence we do it without a USE flag. # it's *built using* LTO. Hence we do it without a USE flag.
if tc_version_is_at_least 4.6 ; then
confgcc+=( --enable-lto ) confgcc+=( --enable-lto )
elif tc_version_is_at_least 4.5 ; then
confgcc+=( --disable-lto )
fi
# Build compiler itself using LTO # Build compiler itself using LTO
if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then
@ -1114,7 +909,7 @@ toolchain_src_configure() {
fi fi
# Support to disable PCH when building libstdcxx # Support to disable PCH when building libstdcxx
if tc_version_is_at_least 6.0 && ! _tc_use_if_iuse pch ; then if ! _tc_use_if_iuse pch ; then
confgcc+=( --disable-libstdcxx-pch ) confgcc+=( --disable-libstdcxx-pch )
fi fi
@ -1130,12 +925,6 @@ toolchain_src_configure() {
# ;; # ;;
# esac # 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 ### Cross-compiler options
if is_crosscompile ; then if is_crosscompile ; then
# Enable build warnings by default with cross-compilers when system # Enable build warnings by default with cross-compilers when system
@ -1184,9 +973,9 @@ toolchain_src_configure() {
if [[ -n ${needed_libc} ]] ; then if [[ -n ${needed_libc} ]] ; then
local confgcc_no_libc=( --disable-shared ) local confgcc_no_libc=( --disable-shared )
# requires libc: bug #734820 # requires libc: bug #734820
tc_version_is_at_least 4.6 && confgcc_no_libc+=( --disable-libquadmath ) confgcc_no_libc+=( --disable-libquadmath )
# requires libc # requires libc
tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic ) confgcc_no_libc+=( --disable-libatomic )
if ! has_version ${CATEGORY}/${needed_libc} ; then if ! has_version ${CATEGORY}/${needed_libc} ; then
confgcc+=( confgcc+=(
@ -1272,7 +1061,7 @@ toolchain_src_configure() {
# gcc has fixed-point arithmetic support in 4.3 for mips targets that can # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
# significantly increase compile time by several hours. This will allow # significantly increase compile time by several hours. This will allow
# users to control this feature in the event they need the support. # users to control this feature in the event they need the support.
tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) ) in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
case $(tc-is-softfloat) in case $(tc-is-softfloat) in
yes) yes)
@ -1317,10 +1106,7 @@ toolchain_src_configure() {
[[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb ) [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
# Enable hardvfp # Enable hardvfp
if [[ $(tc-is-softfloat) == "no" ]] && \ if [[ $(tc-is-softfloat) == "no" ]] && [[ ${CTARGET} == armv[67]* ]] ; then
[[ ${CTARGET} == armv[67]* ]] && \
tc_version_is_at_least 4.5
then
# Follow the new arm hardfp distro standard by default # Follow the new arm hardfp distro standard by default
confgcc+=( --with-float=hard ) confgcc+=( --with-float=hard )
case ${CTARGET} in case ${CTARGET} in
@ -1334,9 +1120,7 @@ toolchain_src_configure() {
# when no specific arch/mode/float is specified, e.g. # when no specific arch/mode/float is specified, e.g.
# for target arm-none-eabi, since doing this is # for target arm-none-eabi, since doing this is
# incompatible with --with-arch/cpu/float/fpu. # incompatible with --with-arch/cpu/float/fpu.
if is_multilib && [[ ${arm_arch} == arm ]] && \ if is_multilib && [[ ${arm_arch} == arm ]] ; then
tc_version_is_at_least 7.1
then
confgcc+=( --with-multilib-list=aprofile,rmprofile ) confgcc+=( --with-multilib-list=aprofile,rmprofile )
fi fi
;; ;;
@ -1348,7 +1132,7 @@ toolchain_src_configure() {
amd64) amd64)
# drop the older/ABI checks once this gets merged into some # drop the older/ABI checks once this gets merged into some
# version of gcc upstream # version of gcc upstream
if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then if has x32 $(get_all_abis TARGET) ; then
confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) ) confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
fi fi
;; ;;
@ -1357,10 +1141,6 @@ toolchain_src_configure() {
# since glibc will do so based on CTARGET anyways # since glibc will do so based on CTARGET anyways
confgcc+=( --with-arch=${CTARGET%%-*} ) confgcc+=( --with-arch=${CTARGET%%-*} )
;; ;;
hppa)
# Enable sjlj exceptions for backward compatibility on hppa
[[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
;;
ppc) ppc)
# Set up defaults based on current CFLAGS # Set up defaults based on current CFLAGS
is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double ) is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
@ -1393,19 +1173,15 @@ toolchain_src_configure() {
# be small, and should simplify building of 64bit kernels in a 32bit # be small, and should simplify building of 64bit kernels in a 32bit
# userland by not needing sys-devel/kgcc64. bug #349405 # userland by not needing sys-devel/kgcc64. bug #349405
case $(tc-arch) in case $(tc-arch) in
ppc|ppc64) amd64|ppc|ppc64|sparc|x86)
confgcc+=( --enable-targets=all ) 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 esac
# On Darwin we need libdir to be set in order to get correct install names # On Darwin we need libdir to be set in order to get correct install names
# for things like libobjc-gnu, libgcj and libfortran. If we enable it on # for things like libobjc-gnu and libfortran. If we enable it on
# non-Darwin we screw up the behaviour this eclass relies on. We in # non-Darwin we screw up the behaviour this eclass relies on. We in
# particular need this over --libdir for bug #255315. # particular need this over --libdir for bug #255315.
[[ ${CTARGET} == *-darwin* ]] && \ [[ ${CTARGET} == *-darwin* ]] && \
@ -1413,15 +1189,6 @@ toolchain_src_configure() {
### library options ### 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 if in_iuse openmp ; then
# Make sure target has pthreads support: bug #326757, bug #335883 # Make sure target has pthreads support: bug #326757, bug #335883
# There shouldn't be a chicken & egg problem here as openmp won't # There shouldn't be a chicken & egg problem here as openmp won't
@ -1443,10 +1210,6 @@ toolchain_src_configure() {
if _tc_use_if_iuse libssp ; then if _tc_use_if_iuse libssp ; then
confgcc+=( --enable-libssp ) confgcc+=( --enable-libssp )
else else
if hardened_gcc_is_stable ssp; then
export gcc_cv_libc_provides_ssp=yes
fi
if _tc_use_if_iuse ssp; then if _tc_use_if_iuse ssp; then
# On some targets USE="ssp -libssp" is an invalid # On some targets USE="ssp -libssp" is an invalid
# configuration as the target libc does not provide # configuration as the target libc does not provide
@ -1502,31 +1265,29 @@ toolchain_src_configure() {
# graphite was added in 4.4 but we only support it in 6.5+ due to external # graphite was added in 4.4 but we only support it in 6.5+ due to external
# library issues. bug #448024, bug #701270 # library issues. bug #448024, bug #701270
if tc_version_is_at_least 6.5 && in_iuse graphite ; then if in_iuse graphite ; then
confgcc+=( $(use_with graphite isl) ) confgcc+=( $(use_with graphite isl) )
use graphite && confgcc+=( --disable-isl-version-check ) use graphite && confgcc+=( --disable-isl-version-check )
elif tc_version_is_at_least 5.0 ; then else
confgcc+=( --without-isl ) 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 fi
if tc_version_is_at_least 4.8; then
if in_iuse sanitize ; then if in_iuse sanitize ; then
# See Note [implicitly enabled flags] # See Note [implicitly enabled flags]
confgcc+=( $(usex sanitize '' --disable-libsanitizer) ) confgcc+=( $(usex sanitize '' --disable-libsanitizer) )
else else
confgcc+=( --disable-libsanitizer ) confgcc+=( --disable-libsanitizer )
fi fi
fi
if tc_version_is_at_least 6.0 && in_iuse pie ; then if in_iuse pie ; then
confgcc+=( $(use_enable pie default-pie) ) confgcc+=( $(use_enable pie default-pie) )
if tc_version_is_at_least 14.0.0_pre20230612 ${PV} ; then
confgcc+=( --enable-host-pie )
fi
fi fi
if tc_version_is_at_least 6.0 && in_iuse ssp ; then if in_iuse ssp ; then
confgcc+=( confgcc+=(
# This defaults to -fstack-protector-strong. # This defaults to -fstack-protector-strong.
$(use_enable ssp default-ssp) $(use_enable ssp default-ssp)
@ -1743,39 +1504,14 @@ gcc_do_filter_flags() {
filter-flags '-fsanitize=*' filter-flags '-fsanitize=*'
if tc_version_is_between 6 8 ; then
# -mstackrealign triggers crashes in exception throwing
# at least on ada: bug #688580
# The reason is unknown. Drop the flag for now.
filter-flags -mstackrealign
fi
case $(tc-arch) in case $(tc-arch) in
amd64|x86) amd64|x86)
filter-flags '-mcpu=*' filter-flags '-mcpu=*'
# bug #357287
tc_version_is_between 4.4 4.5 && append-flags -mno-avx
if tc_version_is_between 4.6 4.7 ; then
# bug #411333, bug #466454
replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
fi
;; ;;
alpha) alpha)
# bug #454426 # bug #454426
append-ldflags -Wl,--no-relax append-ldflags -Wl,--no-relax
;; ;;
sparc)
# Temporary workaround for random ICEs reproduced by multiple users
# bug #457062
tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
;;
*-macos)
# https://gcc.gnu.org/PR25127
tc_version_is_between 4.0 4.2 && \
filter-flags '-mcpu=*' '-march=*' '-mtune=*'
;;
esac esac
strip-unsupported-flags strip-unsupported-flags
@ -1791,27 +1527,6 @@ gcc_do_filter_flags() {
local VAR="CFLAGS_"${CTARGET//[-.]/_} local VAR="CFLAGS_"${CTARGET//[-.]/_}
CXXFLAGS=${!VAR-${CFLAGS}} CXXFLAGS=${!VAR-${CFLAGS}}
fi 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() { gcc-multilib-configure() {
@ -1835,7 +1550,7 @@ gcc-multilib-configure() {
if [[ -n ${list} ]] ; then if [[ -n ${list} ]] ; then
case ${CTARGET} in case ${CTARGET} in
x86_64*) x86_64*)
tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} ) confgcc+=( --with-multilib-list=${list:1} )
;; ;;
esac esac
fi fi
@ -1919,17 +1634,8 @@ gcc_do_make() {
fi fi
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 if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"} 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 fi
if is_crosscompile; then if is_crosscompile; then
@ -1981,13 +1687,9 @@ gcc_do_make() {
if ! is_crosscompile && _tc_use_if_iuse cxx && _tc_use_if_iuse doc ; then if ! is_crosscompile && _tc_use_if_iuse cxx && _tc_use_if_iuse doc ; then
if type -p doxygen > /dev/null ; then if type -p doxygen > /dev/null ; then
if tc_version_is_at_least 4.3 ; then cd "${CTARGET}"/libstdc++-v3/doc || die
cd "${CTARGET}"/libstdc++-v3/doc
emake doc-man-doxygen emake doc-man-doxygen
else
cd "${CTARGET}"/libstdc++-v3
emake doxygen-man
fi
# Clean bogus manpages. bug #113902 # Clean bogus manpages. bug #113902
find -name '*_build_*' -delete find -name '*_build_*' -delete
@ -2130,18 +1832,11 @@ toolchain_src_install() {
create_gcc_env_entry create_gcc_env_entry
create_revdep_rebuild_entry create_revdep_rebuild_entry
# Setup the gcc_env_entry for hardened gcc 4 with minispecs
want_minispecs && copy_minispecs_gcc_specs
# Make sure we don't have stuff lying around that
# can nuke multiple versions of gcc
gcc_slot_java
dodir /usr/bin dodir /usr/bin
cd "${D}"${BINPATH} || die cd "${D}"${BINPATH} || die
# Ugh: we really need to auto-detect this list. # Ugh: we really need to auto-detect this list.
# It's constantly out of date. # It's constantly out of date.
for x in cpp gcc gccrs g++ c++ gcov g77 gcj gcjh gfortran gccgo gnat* ; do for x in cpp gcc gccrs g++ c++ gcov g77 gfortran gccgo gnat* ; do
# For some reason, g77 gets made instead of ${CTARGET}-g77... # For some reason, g77 gets made instead of ${CTARGET}-g77...
# this should take care of that # this should take care of that
if [[ -f ${x} ]] ; then if [[ -f ${x} ]] ; then
@ -2278,16 +1973,8 @@ toolchain_src_install() {
export QA_WX_LOAD="usr/lib*/go/*/*.gox" export QA_WX_LOAD="usr/lib*/go/*/*.gox"
# Disable RANDMMAP so PCH works, bug #301299 # Disable RANDMMAP so PCH works, bug #301299
if tc_version_is_at_least 4.3 ; then
pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1" pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus" pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
fi
# Disable MPROTECT so java works, bug #574808
if is_gcj ; then
pax-mark -m "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
pax-mark -m "${ED}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
fi
if use test ; then if use test ; then
# TODO: In future, install orphaned to allow comparison across # TODO: In future, install orphaned to allow comparison across
@ -2311,7 +1998,7 @@ gcc_movelibs() {
# move them to the compiler-specific CHOST internal dir. This is stuff # move them to the compiler-specific CHOST internal dir. This is stuff
# that you want to link against when building tools rather than building # that you want to link against when building tools rather than building
# code to run on the target. # code to run on the target.
if tc_version_is_at_least 5 && is_crosscompile ; then if is_crosscompile ; then
dodir "${HOSTLIBPATH#${EPREFIX}}" dodir "${HOSTLIBPATH#${EPREFIX}}"
mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
fi fi
@ -2353,14 +2040,6 @@ gcc_movelibs() {
fi fi
done done
fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}" 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 done
# We remove directories separately to avoid this case: # We remove directories separately to avoid this case:
@ -2460,67 +2139,6 @@ create_revdep_rebuild_entry() {
EOF EOF
} }
copy_minispecs_gcc_specs() {
# On gcc 6, we don't need minispecs
if tc_version_is_at_least 6.0 ; then
return 0
fi
# Setup the hardenedno* specs files and the vanilla specs file.
if hardened_gcc_works ; then
create_gcc_env_entry hardenednopiessp
fi
if hardened_gcc_works pie ; then
create_gcc_env_entry hardenednopie
fi
if hardened_gcc_works ssp ; then
create_gcc_env_entry hardenednossp
fi
create_gcc_env_entry vanilla
insinto ${LIBPATH#${EPREFIX}}
doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
# Build system specs file which, if it exists, must be a complete set of
# specs as it completely and unconditionally overrides the builtin specs.
if ! tc_version_is_at_least 4.4 ; then
$(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
fi
}
gcc_slot_java() {
local x
# Move Java headers to compiler-specific dir
for x in "${D}${PREFIX}"/include/gc*.h "${D}${PREFIX}"/include/j*.h ; do
[[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/include/
done
for x in gcj gnu java javax org ; do
if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
dodir /${LIBPATH#${EPREFIX}}/include/${x}
mv -f "${D}${PREFIX}"/include/${x}/* "${D}${LIBPATH}"/include/${x}/
rm -rf "${D}${PREFIX}"/include/${x}
fi
done
if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
dodir /${LIBPATH#${EPREFIX}}/security
mv -f "${D}${PREFIX}"/lib*/security/* "${D}${LIBPATH}"/security
rm -rf "${D}${PREFIX}"/lib*/security
fi
# Move random gcj files to compiler-specific directories
for x in libgcj.spec logging.properties ; do
x="${D}${PREFIX}/lib/${x}"
[[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/
done
# Rename jar because it could clash with Kaffe's jar if this gcc is
# primary compiler (aka doesn't have the -<version> extension)
cd "${D}${BINPATH}"
[[ -f jar ]] && mv -f jar gcj-jar
}
#---->> pkg_post* <<---- #---->> pkg_post* <<----
toolchain_pkg_postinst() { toolchain_pkg_postinst() {
@ -2687,11 +2305,6 @@ is_fortran() {
_tc_use_if_iuse fortran _tc_use_if_iuse fortran
} }
is_gcj() {
gcc-lang-supported java || return 1
_tc_use_if_iuse cxx && _tc_use_if_iuse gcj
}
is_go() { is_go() {
gcc-lang-supported go || return 1 gcc-lang-supported go || return 1
_tc_use_if_iuse cxx && _tc_use_if_iuse go _tc_use_if_iuse cxx && _tc_use_if_iuse go
@ -2741,80 +2354,6 @@ get_make_var() {
XGCC() { get_make_var GCC_FOR_TARGET ; } XGCC() { get_make_var GCC_FOR_TARGET ; }
# The gentoo pie-ssp patches allow for 3 configurations:
# 1) PIE+SSP by default
# 2) PIE by default
# 3) SSP by default
hardened_gcc_works() {
if [[ $1 == "pie" ]] ; then
# $gcc_cv_ld_pie is unreliable as it simply take the output of
# `ld --help | grep -- -pie`, that reports the option in all cases, also if
# the loader doesn't actually load the resulting executables.
want_pie || return 1
_tc_use_if_iuse nopie && return 1
hardened_gcc_is_stable pie
return $?
elif [[ $1 == "ssp" ]] ; then
[[ -n ${SPECS_VER} ]] || return 1
_tc_use_if_iuse nossp && return 1
hardened_gcc_is_stable ssp
return $?
else
# laziness ;)
hardened_gcc_works pie || return 1
hardened_gcc_works ssp || return 1
return 0
fi
}
hardened_gcc_is_stable() {
local tocheck
if [[ $1 == "pie" ]] ; then
tocheck=${PIE_GLIBC_STABLE}
elif [[ $1 == "ssp" ]] ; then
tocheck=${SSP_STABLE}
else
die "hardened_gcc_stable needs to be called with pie or ssp"
fi
has $(tc-arch) ${tocheck} && return 0
return 1
}
want_minispecs() {
# On gcc 6, we don't need minispecs
if tc_version_is_at_least 6.0 ; then
return 0
fi
if tc_version_is_at_least 4.3.2 && _tc_use_if_iuse hardened ; then
if ! want_pie ; then
ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
elif use vanilla ; then
ewarn "You will not get hardened features if you have the vanilla USE-flag."
elif _tc_use_if_iuse nopie && _tc_use_if_iuse nossp ; then
ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
elif ! hardened_gcc_works ; then
ewarn "Your $(tc-arch) arch is not supported."
else
return 0
fi
ewarn "Hope you know what you are doing. Hardened will not work."
return 0
fi
return 1
}
want_pie() {
! _tc_use_if_iuse hardened && [[ -n ${PIE_VER} ]] \
&& _tc_use_if_iuse nopie && return 1
[[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
tc_version_is_at_least 4.3.2 && return 1
[[ -z ${PIE_VER} ]] && return 1
_tc_use_if_iuse nopie || return 0
return 1
}
has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice" has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
toolchain_death_notice() { toolchain_death_notice() {
if [[ -e "${WORKDIR}"/build ]] ; then if [[ -e "${WORKDIR}"/build ]] ; then