eclass/toolchain: Sync with Gentoo

It's from Gentoo commit 44d2dbd6db9e05f156a81a3a360ff48e2ac9d773.
This commit is contained in:
Flatcar Buildbot 2025-01-13 07:08:48 +00:00 committed by Krzesimir Nowak
parent ea58932471
commit 73253d793f

View File

@ -1,4 +1,4 @@
# Copyright 1999-2024 Gentoo Authors
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: toolchain.eclass
@ -33,7 +33,12 @@ tc_is_live() {
}
if tc_is_live ; then
EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git https://github.com/gcc-mirror/gcc"
EGIT_REPO_URI="
https://gcc.gnu.org/git/gcc.git
https://git.sr.ht/~sourceware/gcc
https://gitlab.com/x86-gcc/gcc.git
https://github.com/gcc-mirror/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.
@ -199,7 +204,7 @@ GCCMICRO=$(ver_cut 3 ${GCC_PV})
# @INTERNAL
# @DESCRIPTION:
# Controls whether fixincludes should be used.
GCC_RUN_FIXINCLUDES=0
: "${GCC_RUN_FIXINCLUDES:=0}"
tc_use_major_version_only() {
local use_major_version_only=0
@ -333,7 +338,7 @@ if [[ ${PN} != kgcc64 && ${PN} != gcc-* ]] ; then
# it was disabled in 13.
tc_version_is_at_least 14.0.0_pre20230423 ${PV} && IUSE+=" rust" TC_FEATURES+=( rust )
tc_version_is_at_least 14.2.1_p20241026 ${PV} && IUSE+=" time64"
tc_version_is_at_least 15.0.0_pre20241124 ${PV} && IUSE+=" libdiagnostics"
tc_version_is_at_least 15.0.0_pre20241124 ${PV} && IUSE+=" libgdiagnostics"
fi
if tc_version_is_at_least 10; then
@ -406,16 +411,29 @@ if tc_has_feature valgrind ; then
fi
if [[ ${PN} != gnat-gpl ]] && tc_has_feature ada ; then
BDEPEND+="
ada? (
|| (
sys-devel/gcc:${SLOT}[ada]
<sys-devel/gcc-${SLOT}[ada]
<dev-lang/ada-bootstrap-${SLOT}
dev-lang/gnat-gpl[ada]
if tc_use_major_version_only ; then
BDEPEND+="
ada? (
|| (
sys-devel/gcc:${SLOT}[ada]
<sys-devel/gcc-${SLOT}[ada]
<dev-lang/ada-bootstrap-$((${SLOT} + 1))
dev-lang/gnat-gpl[ada]
)
)
)
"
"
else
BDEPEND+="
ada? (
|| (
sys-devel/gcc:${SLOT}[ada]
<sys-devel/gcc-${SLOT}[ada]
<dev-lang/ada-bootstrap-${SLOT}
dev-lang/gnat-gpl[ada]
)
)
"
fi
fi
# TODO: Add a pkg_setup & pkg_pretend check for whether the active compiler
@ -670,6 +688,11 @@ toolchain_src_prepare() {
eapply_user
# Workaround -march=native not working for stage1 with non-GCC (bug #933772).
if ! tc-is-gcc && [[ "${CFLAGS}${CXXFLAGS}" == *-march=native* ]] ; then
CLANG_DISABLE_CET_HACK=1
fi
if ! use vanilla ; then
tc_enable_hardened_gcc
fi
@ -698,7 +721,7 @@ toolchain_src_prepare() {
gnuconfig_update
if ! use prefix-guest && [[ -n ${EPREFIX} ]] ; then
if ! is_crosscompile && ! use prefix-guest && [[ -n ${EPREFIX} ]] ; then
einfo "Prefixifying dynamic linkers..."
for f in gcc/config/*/*linux*.h ; do
ebegin " Updating ${f}"
@ -770,7 +793,7 @@ tc_enable_hardened_gcc() {
hardened_gcc_flags+=" -DDEF_GENTOO_ZNOW"
fi
if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux-gnu* ]] ; then
if _tc_use_if_iuse cet && [[ -z ${CLANG_DISABLE_CET_HACK} && ${CTARGET} == *x86_64*-linux-gnu* ]] ; then
einfo "Updating gcc to use x86-64 control flow protection by default ..."
hardened_gcc_flags+=" -DEXTRA_OPTIONS_CF"
fi
@ -847,33 +870,79 @@ setup_multilib_osdirnames() {
sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
}
# @FUNCTION: toolchain_setup_ada
# @FUNCTION: _get_bootstrap_gcc_info
# @USAGE: [gcc_pkg|gcc_bin_base]...
# @DESCRIPTION:
# Get some information about the gcc that would be used to build this package.
# All the variables that are passed as arguments will be set to their apropriate
# values:
#
# - bootstrap_gcc_pkg = the ${CATEGORY}/${PN} that provides the build gcc
#
# - bootstrap_gcc_bin_base = the directory up to /gcc-bin but excluding the slot, of
# the aformentioned package.
_get_bootstrap_gcc_info() {
crossp() {
tc-is-cross-compiler && echo "${2}" || echo "${1}"
}
local arg
for arg ; do
case "${arg}" in
bootstrap_gcc_pkg)
bootstrap_gcc_pkg=$(crossp sys-devel/gcc cross-${CHOST}/gcc)
;;
bootstrap_gcc_bin_base)
bootstrap_gcc_bin_base=${BROOT}/usr/$(crossp ${CHOST} ${CBUILD}/${CHOST})/gcc-bin
;;
*)
die "Unknown argument '${arg}' passed to ${FUNCNAME}"
esac
done
}
# @FUNCTION: _find_bootstrap_gcc_with
# @USAGE: <use_expression> <pretty_use_name> <minimum_slot>
# @RETURN: Shell true if a matching gcc installation was found, false otherwise
# @INTERNAL
# @DESCRIPTION:
# Determine the most suitable GNAT (Ada compiler) for bootstrapping
# and setup the environment, including wrappers, for building.
toolchain_setup_ada() {
local latest_gcc=$(best_version -b "sys-devel/gcc")
latest_gcc="${latest_gcc#sys-devel/gcc-}"
latest_gcc=$(ver_cut 1 ${latest_gcc})
# Check installed versions of gcc that can be used as a compiler for the current
# build for one matching a certain USE expression. The order of preference is
# checking for the same SLOT we are building, then iterate downwards until (and
# including) minimum_slot, then iterate upward starting with SLOT+1. When
# cross-compiling only SLOT is checked.
#
# If a proper installation is discovered this function will set
# ${bootstrap_gcc_bin_dir} to the full path of the directory in which
# ${CHOST}-gcc and friends are found and ${bootstrap_gcc_slot} to the slot that
# was found. If nothing was found those variables will be empty.
#
# This function is provided to aid languages like ada and d that require
# bootstraping.
_find_bootstrap_gcc_with() {
local use="${1}"
local pretty_use="${2}"
local bootstrap_gcc_pkg bootstrap_gcc_bin_base
_get_bootstrap_gcc_info bootstrap_gcc_pkg bootstrap_gcc_bin_base
local ada_bootstrap
local ada_candidate
local ada_bootstrap_type
# GNAT can usually be built using the last major version and
# the current version, at least.
#
# Order of preference (descending):
# 1) Match the version being built;
# 2) Iterate downwards from the version being built;
# 3) Iterate upwards from the version being built to the greatest version installed.
for ada_candidate in ${SLOT} $(seq $((${SLOT} - 1)) -1 10) $(seq $((${SLOT} + 1)) ${latest_gcc}) ; do
has_version -b "sys-devel/gcc:${ada_candidate}" || continue
local min_slot max_slot
if tc-is-cross-compiler ; then
min_slot="${SLOT}"
max_slot="${SLOT}"
else
min_slot="${3}"
max_slot=$(best_version -b "${bootstrap_gcc_pkg}")
max_slot="${max_slot#${bootstrap_gcc_pkg}-}"
max_slot=$(ver_cut 1 ${max_slot})
fi
ebegin "Testing sys-devel/gcc:${ada_candidate} for Ada"
if has_version -b "sys-devel/gcc:${ada_candidate}[ada(-)]" ; then
ada_bootstrap=${ada_candidate}
ada_bootstrap_type=gcc
local candidate result
for candidate in ${SLOT} $(seq $((${SLOT} - 1)) -1 ${min_slot}) $(seq $((${SLOT} + 1)) ${max_slot}) ; do
has_version -b "${bootstrap_gcc_pkg}:${candidate}" || continue
ebegin "Testing ${bootstrap_gcc_pkg}:${candidate} for ${pretty_use}"
if has_version -b "${bootstrap_gcc_pkg}:${candidate}${use}" ; then
result=${candidate}
eend 0
break
@ -881,17 +950,62 @@ toolchain_setup_ada() {
eend 1
done
if [[ ${result} ]] ; then
bootstrap_gcc_bin_dir="${bootstrap_gcc_bin_base}/${result}"
bootstrap_gcc_slot=${result}
return 0
else
bootstrap_gcc_bin_dir=
bootstrap_gcc_slot=
return 1
fi
}
# @FUNCTION: toolchain_setup_ada
# @INTERNAL
# @DESCRIPTION:
# Determine the most suitable GNAT (Ada compiler) for bootstrapping
# and setup the environment, including wrappers, for building.
toolchain_setup_ada() {
local ada_bootstrap
local ada_candidate
local ada_bootstrap_type
local ada_bootstrap_bin_dir
# GNAT can usually be built using the last major version and
# the current version, at least.
#
# Order of preference (descending):
# 1) Match the version being built;
# 2) Iterate downwards from the version being built;
# 3) Iterate upwards from the version being built to the greatest version installed.
local bootstrap_gcc_slot bootstrap_gcc_bin_dir
if _find_bootstrap_gcc_with "[ada(-)]" "Ada" 10 ; then
ada_bootstrap=${bootstrap_gcc_slot}
ada_bootstrap_type=gcc
ada_bootstrap_bin_dir="${bootstrap_gcc_bin_dir}"
fi
# As a penultimate resort, try dev-lang/ada-bootstrap.
if ver_test ${ada_bootstrap} -gt ${PV} || [[ -z ${ada_bootstrap} ]] ; then
ebegin "Testing fallback dev-lang/ada-bootstrap for Ada"
if has_version -b "<dev-lang/ada-bootstrap-${SLOT}" ; then
# TODO: Figure out ada-bootstrap versioning/slots
# XXX: This can be cleaned up like BDEPEND for tc_use_major_version_only
# once we only support such versions.
if has_version -b "=dev-lang/ada-bootstrap-${SLOT}*" || has_version -b "<dev-lang/ada-bootstrap-${SLOT}" ; then
# Workaround the old scheme
if has_version -b "=dev-lang/ada-bootstrap-0_p2021*" ; then
ada_bootstrap=10
else
local latest_ada_bootstrap=$(best_version -b "<dev-lang/ada-bootstrap-${SLOT}")
latest_ada_bootstrap="${latest_ada_bootstrap#dev-lang/ada-bootstrap-}"
latest_ada_bootstrap=$(ver_cut 1 ${latest_ada_bootstrap})
ada_bootstrap="${latest_ada_bootstrap}"
export ADA_INCLUDE_PATH="${BROOT}/usr/lib/ada-bootstrap/usr/lib/gcc/${CHOST}/${ada_bootstrap}/adainclude::${ADA_INCLUDE_PATH}"
export ADA_OBJECTS_PATH="${BROOT}/usr/lib/ada-bootstrap/usr/lib/gcc/${CHOST}/${ada_bootstrap}/adalib:${ADA_OBJECTS_PATH}"
fi
#local latest_ada_bootstrap=$(best_version -b "<dev-lang/ada-bootstrap-${SLOT}")
#latest_ada_bootstrap="${latest_ada_bootstrap#dev-lang/ada-bootstrap-}"
#latest_ada_bootstrap=$(ver_cut 1 ${latest_ada_bootstrap})
ada_bootstrap="10"
ada_bootstrap_type=ada-bootstrap
ada_bootstrap_bin_dir="${BROOT}/usr/lib/ada-bootstrap/bin"
eend 0
else
@ -905,6 +1019,7 @@ toolchain_setup_ada() {
if has_version -b "dev-lang/gnat-gpl" ; then
ada_bootstrap=10
ada_bootstrap_type=gcc
ada_bootstrap_bin_dir="${BROOT}/usr/${CHOST}/gcc-bin/${ada_bootstrap}"
eend 0
else
eend 1
@ -969,10 +1084,10 @@ toolchain_setup_ada() {
case ${ada_bootstrap_type} in
ada-bootstrap)
export PATH="${BROOT}/usr/lib/ada-bootstrap/bin:${PATH}"
gnat1_path=${BROOT}/usr/lib/ada-bootstrap/libexec/gcc/${CBUILD}/${ada_bootstrap}/gnat1
gnat1_path=${BROOT}/usr/lib/ada-bootstrap/libexec/gcc/${CHOST}/${ada_bootstrap}/gnat1
;;
*)
gnat1_path=${BROOT}/usr/libexec/gcc/${CBUILD}/${ada_bootstrap}/gnat1
gnat1_path=${BROOT}/usr/libexec/gcc/${CHOST}/${ada_bootstrap}/gnat1
;;
esac
@ -989,7 +1104,7 @@ toolchain_setup_ada() {
# work for us as the stage1 compiler doesn't necessarily have Ada
# support. Substitute the Ada compiler we found earlier.
local adalib
adalib=$(${CBUILD}-gcc-${ada_bootstrap} -print-libgcc-file-name || die "Finding adalib dir failed")
adalib=$("${ada_bootstrap_bin_dir}"/${CHOST}-gcc -print-libgcc-file-name || die "Finding adalib dir failed")
adalib="${adalib%/*}/adalib"
sed -i \
-e "s:adalib=.*:adalib=${adalib}:" \
@ -997,19 +1112,26 @@ toolchain_setup_ada() {
# Create bin wrappers because not all of the build system respects
# GNATBIND or GNATMAKE.
mkdir "${T}"/ada-wrappers || die
local tool
for tool in gnat{,bind,chop,clean,kr,link,ls,make,name,prep} ; do
cat <<-EOF > "${T}"/ada-wrappers/${tool} || die
#!/bin/sh
exec $(type -P ${CBUILD}-${tool}-${ada_bootstrap}) "\$@"
EOF
_toolchain_make_gnat_wrappers() {
mkdir "${T}"/ada-wrappers || die
local tool
for tool in gnat{,bind,chop,clean,kr,link,ls,make,name,prep} ; do
cat <<-EOF > "${T}"/ada-wrappers/${tool} || die
#!/bin/sh
exec "${ada_bootstrap_bin_dir}"/${CHOST}-${tool} "\$@"
EOF
export "${tool^^}"="${T}"/ada-wrappers/${tool}
done
chmod +x "${T}"/ada-wrappers/gnat{,bind,chop,clean,kr,link,ls,make,name,prep} || die
export "${tool^^}"="${T}"/ada-wrappers/${tool}
done
chmod +x "${T}"/ada-wrappers/gnat{,bind,chop,clean,kr,link,ls,make,name,prep} || die
export PATH="${T}/ada-wrappers:${old_path}"
}
# Only make the wrappers for native builds. For cross, we can't
# do it as CBUILD vs CHOST will get mixed up then.
! tc-is-cross-compiler && _toolchain_make_gnat_wrappers
export PATH="${T}/ada-wrappers:${old_path}"
export CC="$(tc-getCC) -specs=${T}/ada.spec"
}
@ -1019,47 +1141,20 @@ toolchain_setup_ada() {
# Determine the most suitable GDC (D compiler) for bootstrapping
# and setup the environment for building.
toolchain_setup_d() {
local gcc_pkg gcc_bin_base
if tc-is-cross-compiler ; then
gcc_pkg=cross-${CHOST}/gcc
gcc_bin_base=${BROOT}/usr/${CBUILD}/${CHOST}/gcc-bin
else
gcc_pkg=sys-devel/gcc
gcc_bin_base=${BROOT}/usr/${CHOST}/gcc-bin
fi
local bootstrap_gcc_slot bootstrap_gcc_bin_dir
_find_bootstrap_gcc_with "[d(-)]" "D" 11
local latest_gcc=$(best_version -b "${gcc_pkg}")
latest_gcc="${latest_gcc#${gcc_pkg}-}"
latest_gcc=$(ver_cut 1 ${latest_gcc})
local d_bootstrap
local d_candidate
# Order of preference (descending):
# 1) Match the version being built;
# 2) Iterate downwards from the version being built;
# 3) Iterate upwards from the version being built to the greatest version installed.
for d_candidate in ${SLOT} $(seq $((${SLOT} - 1)) -1 10) $(seq $((${SLOT} + 1)) ${latest_gcc}) ; do
has_version -b "${gcc_pkg}:${d_candidate}" || continue
ebegin "Testing ${gcc_pkg}:${d_candidate} for D"
if has_version -b "${gcc_pkg}:${d_candidate}[d(-)]" ; then
d_bootstrap=${d_candidate}
eend 0
break
fi
eend 1
done
if [[ -z ${d_bootstrap} ]] ; then
if [[ -z ${bootstrap_gcc_bin_dir} ]] ; then
if tc-is-cross-compiler ; then
# We can't add cross-${CHOST}/gcc[d] to BDEPEND but we can
# print a useful message to the user.
eerror "No ${gcc_pkg}[d] was found installed."
local bootstrap_gcc_pkg
_get_bootstrap_gcc_info bootstrap_gcc_pkg
eerror "No ${bootstrap_gcc_pkg}[d] was found installed."
eerror "When cross-compiling GDC a bootstrap GDC is required."
eerror "Either disable the d USE flag or add:"
eerror ""
eerror " ${gcc_pkg} d"
eerror " ${bootstrap_gcc_pkg} d"
eerror ""
eerror "In your package.use and re-emerge it."
eerror ""
@ -1068,7 +1163,7 @@ toolchain_setup_d() {
die "Did not find any appropriate GDC compiler installed"
fi
export GDC=${gcc_bin_base}/${d_bootstrap}/${CHOST}-gdc
export GDC=${bootstrap_gcc_bin_dir}/${CHOST}-gdc
}
#---->> src_configure <<----
@ -1243,11 +1338,16 @@ toolchain_src_configure() {
confgcc+=( --enable-lto )
# Build compiler itself using LTO
if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then
BUILD_CONFIG_TARGETS+=( bootstrap-lto )
if _tc_use_if_iuse lto ; then
# GCC 11 at least has a -Wlto-type-mismatch issue with Ada
if ! tc_version_is_at_least 12.1 && is_ada ; then
:;
elif tc_version_is_at_least 9.1 ; then
BUILD_CONFIG_TARGETS+=( bootstrap-lto )
fi
fi
if tc_version_is_at_least 12 && _tc_use_if_iuse cet && [[ ${CTARGET} == x86_64-*-gnu* ]] ; then
if tc_version_is_at_least 12 && _tc_use_if_iuse cet && [[ -z ${CLANG_DISABLE_CET_HACK} && ${CTARGET} == x86_64-*-gnu* ]] ; then
BUILD_CONFIG_TARGETS+=( bootstrap-cet )
fi
@ -1311,8 +1411,31 @@ toolchain_src_configure() {
confgcc+=( --enable-shared --disable-threads )
;;
nvptx*)
# "LTO is not supported for this target"
confgcc+=( --disable-lto )
needed_libc=newlib
confgcc+=(
# "LTO is not supported for this target"
--disable-lto
)
# --enable-as-accelerator-for= seems to disable
# installing nvtpx-none-cc etc, so we have to
# avoid passing that for the stage1-build that
# crossdev does. If we pass it unconditionally,
# we can't build newlib after building stage1 gcc.
if has_version ${CATEGORY}/${PN} ; then
confgcc+=(
# It's unlikely that anyone will want
# to build nvptx-none as a pure standalone
# toolchain (which will be single-threaded, etc).
#
# If someone really wants it, we can see about
# adding a USE=offload or similar based on CTARGET
# for cross targets. But for now, we always assume
# we're being built as an offloading compiler (accelerator).
--enable-as-accelerator-for=${CHOST}
--disable-sjlj-exceptions
)
fi
;;
esac
@ -1389,7 +1512,7 @@ toolchain_src_configure() {
# __cxa_atexit is "essential for fully standards-compliant handling of
# destructors", but apparently requires glibc.
case ${CTARGET} in
*-elf|*-eabi)
nvptx*|*-elf|*-eabi)
confgcc+=( --with-newlib )
;;
*-musl*)
@ -1546,6 +1669,13 @@ toolchain_src_configure() {
[[ ${CTARGET} == *-darwin* ]] && \
confgcc+=( --enable-version-specific-runtime-libs )
# Linux specifically here for bug #946397.
# TODO: amdgcn-amdhsa?
[[ ${CTARGET} == x86_64*-*-linux-* ]] && confgcc+=(
--enable-offload-defaulted
--enable-offload-targets=nvptx-none
)
### library options
if in_iuse openmp ; then
@ -1604,7 +1734,7 @@ toolchain_src_configure() {
enable_cet_for 'x86_64' 'gnu' 'cet'
enable_cet_for 'aarch64' 'gnu' 'standard-branch-protection'
[[ ${CTARGET} == i[34567]86-* ]] && confgcc+=( --disable-cet )
[[ -n ${CLANG_DISABLE_CET_HACK} || ${CTARGET} == i[34567]86-* ]] && confgcc+=( --disable-cet )
fi
if in_iuse systemtap ; then
@ -1674,7 +1804,7 @@ toolchain_src_configure() {
fi
case ${CBUILD}-${CHOST}-${CTARGET} in
*i686-w64-mingw32*|*x86_64-w64-mingw32*)
*-w*-mingw*)
# config/i386/t-cygming requires fixincludes (bug #925204)
GCC_RUN_FIXINCLUDES=1
;;
@ -1746,8 +1876,8 @@ toolchain_src_configure() {
gcc_shell="${BROOT}"/bin/sh
fi
if is_jit || _tc_use_if_iuse libdiagnostics ; then
einfo "Configuring shared gcc for JIT/libdiagnostics"
if is_jit || _tc_use_if_iuse libgdiagnostics ; then
einfo "Configuring shared gcc for JIT/libgdiagnostics"
local confgcc_jit=(
"${confgcc[@]}"
@ -1784,7 +1914,7 @@ toolchain_src_configure() {
)
if tc_version_is_at_least 15.0.0_pre20241124 ${PV} ; then
confgcc_jit+=( $(use_enable libdiagnostics) )
confgcc_jit+=( $(use_enable libgdiagnostics) )
fi
if tc_version_is_at_least 13.1 ; then
@ -1966,6 +2096,9 @@ gcc_do_filter_flags() {
fi
fi
# https://gcc.gnu.org/PR100431
filter-flags -Werror=format-security
if ver_test -lt 13.6 ; then
# These aren't supported by the just-built compiler either.
filter-flags -fharden-compares -fharden-conditional-branches \
@ -2396,11 +2529,7 @@ toolchain_src_install() {
if [[ ${GCC_RUN_FIXINCLUDES} == 0 ]] ; then
# 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.
# (ncurses, openssl, etc).
while read x ; do
grep -q 'It has been auto-edited by fixincludes from' "${x}" \
&& rm -f "${x}"
@ -2420,8 +2549,6 @@ toolchain_src_install() {
pushd "${WORKDIR}"/build-jit > /dev/null || die
S="${WORKDIR}"/build-jit emake DESTDIR="${D}" -j1 install
# Punt some tools which are really only useful while building gcc
find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \; || die
# This one comes with binutils
find "${ED}" -name libiberty.a -delete || die
@ -2444,8 +2571,6 @@ toolchain_src_install() {
# - https://gcc.gnu.org/PR109898
S="${WORKDIR}"/build emake DESTDIR="${D}" -j1 install
# Punt some tools which are really only useful while building gcc
find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \; || die
# This one comes with binutils
find "${ED}" -name libiberty.a -delete || die
@ -2516,7 +2641,7 @@ toolchain_src_install() {
# - "${D}${LIBPATH}"
# As dostrip does not specify host to override ${CHOST} tools just skip
# non-native binary stripping.
is_crosscompile && dostrip -x "${LIBPATH}"
is_crosscompile && dostrip -x "${LIBPATH#"${EPREFIX}"}"
cd "${S}" || die
if is_crosscompile; then
@ -2666,6 +2791,26 @@ gcc_movelibs() {
fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
done
# Without this, we end up either unable to find the libgomp spec/archive, or
# we underlink and can't find gomp_nvptx_main (presumably because we can't find the plugin)
# https://src.fedoraproject.org/rpms/gcc/blob/02c34dfa3627ef05d676d30e152a66e77b58529b/f/gcc.spec#_1445
if [[ ${CTARGET} == nvptx* ]] && has_version ${CATEGORY}/${PN} ; then
rm -rf "${ED}"/usr/libexec/gcc/nvptx-none/${GCCMAJOR}/install-tools
rm -rf "${ED}"/usr/libexec/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/{install-tools,plugin,cc1,cc1plus,f951}
rm -rf "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/{install-tools,plugin}
rm -rf "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/{install-tools,plugin,include-fixed}
mv "${ED}"/usr/nvptx-none/lib/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/
mv "${ED}"/usr/nvptx-none/lib/mgomp/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mgomp/
mv "${ED}"/usr/nvptx-none/lib/mptx-3.1/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mptx-3.1/
mv "${ED}"/usr/nvptx-none/lib/mgomp/mptx-3.1/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mgomp/mptx-3.1/
mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/ || die
mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/mgomp/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mgomp/ || die
# Nonfatal because the multilib variants change: see r15-5975-g86b3a7532d56f7 and r15-6029-gd4e1f7cfdb8375
# TODO: Should we enable all of them unconditionally? Expose it somehow (USE_EXPAND?)?
mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/mptx-3.1/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mptx-3.1/
mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/mgomp/mptx-3.1/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mgomp/mptx-3.1/
fi
# We remove directories separately to avoid this case:
# mv SRC/lib/../lib/*.o DEST
# rmdir SRC/lib/../lib/
@ -2816,6 +2961,12 @@ toolchain_pkg_postrm() {
rm -f "${EROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
fi
return 0
else
# Removed the last GCC installed (bug #906040)
if ! has_version "sys-devel/gcc" && has_version "sys-devel/clang" ; then
einfo "Last GCC version removed. Cleaning up ${EROOT}/etc/clang/gentoo-gcc-install.cfg."
echo > "${EROOT}"/etc/clang/gentoo-gcc-install.cfg
fi
fi
# gcc stopped installing .la files fixer in June 2020.