Skip to content

Commit cdc0d0a

Browse files
committed
eclass/toolchain: sync with gx86
Closes: https://bugs.gentoo.org/940173 Signed-off-by: Fabian Groffen <[email protected]>
1 parent eadd02f commit cdc0d0a

File tree

1 file changed

+59
-62
lines changed

1 file changed

+59
-62
lines changed

eclass/toolchain.eclass

+59-62
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ _TOOLCHAIN_ECLASS=1
2222
DESCRIPTION="The GNU Compiler Collection"
2323
HOMEPAGE="https://gcc.gnu.org/"
2424

25-
inherit edo flag-o-matic gnuconfig libtool multilib pax-utils python-any-r1 toolchain-funcs prefix
25+
inherit edo flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
26+
27+
[[ -n ${TOOLCHAIN_HAS_TESTS} ]] && inherit python-any-r1
2628

2729
tc_is_live() {
2830
[[ ${PV} == *9999* ]]
@@ -60,9 +62,6 @@ is_crosscompile() {
6062
[[ ${CHOST} != ${CTARGET} ]]
6163
}
6264

63-
# The target prefix defaults to the host prefix, except for cross compilers, which targets the empty prefix by default.
64-
: ${TPREFIX:=$(is_crosscompile || echo "${EPREFIX}")}
65-
6665
# @FUNCTION: tc_version_is_at_least
6766
# @USAGE: ver1 [ver2]
6867
# @DESCRIPTION:
@@ -146,6 +145,12 @@ tc_version_is_between() {
146145
# @DESCRIPTION:
147146
# Indicate the developer who hosts the patchset for an ebuild.
148147

148+
# @ECLASS_VARIABLE: TOOLCHAIN_HAS_TESTS
149+
# @DEFAULT_UNSET
150+
# @DESCRIPTION:
151+
# Controls whether python-any-r1 is inherited and validate_failures.py
152+
# is used.
153+
149154
# @ECLASS_VARIABLE: GCC_PV
150155
# @INTERNAL
151156
# @DESCRIPTION:
@@ -276,14 +281,15 @@ STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VE
276281
LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
277282
IUSE="test vanilla +nls"
278283
RESTRICT="!test? ( test )"
284+
[[ -z ${TOOLCHAIN_HAS_TESTS} ]] && RESTRICT+=" test"
279285

280286
TC_FEATURES=()
281287

282288
tc_has_feature() {
283289
has "$1" "${TC_FEATURES[@]}"
284290
}
285291

286-
# Prefix: allow gcc-apple post 4.2.1
292+
# PREFIX_LOCAL: allow gcc-apple post 4.2.1
287293
if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ||
288294
[[ ${PN} == "gcc-apple" && $(tc_version_is_at_least 12.1) == 0 ]] ; then
289295
IUSE+=" debug +cxx +nptl" TC_FEATURES+=( nptl )
@@ -358,6 +364,7 @@ fi
358364

359365
BDEPEND="
360366
app-alternatives/yacc
367+
!elibc_Darwin? ( sys-devel/binutils:* )
361368
>=sys-devel/flex-2.5.4
362369
nls? ( sys-devel/gettext )
363370
test? (
@@ -418,7 +425,7 @@ if tc_has_feature rust && tc_version_is_at_least 14.0.0_pre20230421 ; then
418425
fi
419426

420427
# PREFIX LOCAL: we don't have 2.11 (yet)
421-
PDEPEND=">=sys-devel/gcc-config-2.3"
428+
PDEPEND=">=sys-devel/gcc-config-2.7"
422429

423430
#---->> S + SRC_URI essentials <<----
424431

@@ -542,7 +549,8 @@ get_gcc_src_uri() {
542549
[[ -n ${MUSL_VER} ]] && \
543550
GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
544551

545-
GCC_SRC_URI+=" test? ( https://gitweb.gentoo.org/proj/gcc-patches.git/plain/scripts/testsuite-management/validate_failures.py?id=${GCC_VALIDATE_FAILURES_VERSION} -> gcc-validate-failures-${GCC_VALIDATE_FAILURES_VERSION}.py )"
552+
[[ -n ${TOOLCHAIN_HAS_TESTS} ]] && \
553+
GCC_SRC_URI+=" test? ( https://gitweb.gentoo.org/proj/gcc-patches.git/plain/scripts/testsuite-management/validate_failures.py?id=${GCC_VALIDATE_FAILURES_VERSION} -> gcc-validate-failures-${GCC_VALIDATE_FAILURES_VERSION}.py )"
546554

547555
echo "${GCC_SRC_URI}"
548556
}
@@ -574,7 +582,7 @@ toolchain_pkg_setup() {
574582
# more legible.
575583
MAKEOPTS="--output-sync=line ${MAKEOPTS}"
576584

577-
use test && python-any-r1_pkg_setup
585+
[[ -n ${TOOLCHAIN_HAS_TESTS} ]] && use test && python-any-r1_pkg_setup
578586
}
579587

580588
#---->> src_unpack <<----
@@ -599,16 +607,6 @@ toolchain_fetch_git_patches() {
599607
mkdir "${WORKDIR}"/musl || die
600608
mv "${WORKDIR}"/patch.tmp/${PATCH_GCC_VER}/musl/* "${WORKDIR}"/musl || die
601609
fi
602-
603-
# PREFIX_LOCAL
604-
# yuck, but how else to do it portable?
605-
local realEPREFIX=$(python -c 'import os; print(os.path.realpath("'"${EPREFIX}"'"))')
606-
if [[ -z ${I_KNOW_MY_GCC_WORKS_FINE_WITH_SYMLINKS} && ${EPREFIX} != ${realEPREFIX} ]] ; then
607-
ewarn "Your \${EPREFIX} contains one or more symlinks. GCC has a"
608-
ewarn "bug which prevents it from working properly when there are"
609-
ewarn "symlinks in your \${EPREFIX}."
610-
ewarn "See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29831"
611-
fi
612610
}
613611

614612
toolchain_src_unpack() {
@@ -661,7 +659,7 @@ toolchain_src_prepare() {
661659
sed -i -e "/\"\/System\/Library\/Frameworks\"\,/i\ \ \"${EPREFIX}/MacOSX.sdk/System/Library/Frameworks\"\, \"${EPREFIX}/Frameworks\"\, " \
662660
"${S}"/gcc/config/${darwindriver} || die "sed gcc/config/${darwindriver} failed"
663661

664-
if use test ; then
662+
if [[ -n ${TOOLCHAIN_HAS_TESTS} ]] && use test ; then
665663
cp "${DISTDIR}"/gcc-validate-failures-${GCC_VALIDATE_FAILURES_VERSION}.py "${T}"/validate_failures.py || die
666664
chmod +x "${T}"/validate_failures.py || die
667665
fi
@@ -1133,7 +1131,7 @@ toolchain_src_configure() {
11331131
# should be /usr, because it's the path to search includes
11341132
# for, which is unrelated to TOOLCHAIN_PREFIX, a.k.a.
11351133
# PREFIX
1136-
confgcc+=( --with-local-prefix="${TPREFIX}/usr" )
1134+
confgcc+=( --with-local-prefix="${EPREFIX}/usr" )
11371135

11381136
# enable the configured SDK, Apple no longer installs stuff
11391137
# into /usr
@@ -1349,7 +1347,9 @@ toolchain_src_configure() {
13491347
fi
13501348

13511349
if in_iuse cet ; then
1352-
[[ ${CTARGET} == x86_64-*-gnu* ]] && confgcc+=( $(use_enable cet) )
1350+
if [[ ${CTARGET} == i[[34567]]86-*-linux* || ${CTARGET} == x86_64-*-gnu* ]] ; then
1351+
confgcc+=( $(use_enable cet) )
1352+
fi
13531353
[[ ${CTARGET} == aarch64-*-gnu* ]] && confgcc+=( $(use_enable cet standard-branch-protection) )
13541354
fi
13551355

@@ -1920,7 +1920,6 @@ gcc_do_make() {
19201920

19211921
einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
19221922
pushd "${WORKDIR}"/build >/dev/null || die
1923-
19241923
emake "${emakeargs[@]}" ${GCC_MAKE_TARGET}
19251924

19261925
if is_ada; then
@@ -1981,34 +1980,27 @@ toolchain_src_test() {
19811980
local -x LD_PRELOAD=
19821981

19831982
# Controls running expensive tests in e.g. the torture testsuite.
1983+
# Note that 'TEST', not 'TESTS', is correct here as it's a GCC
1984+
# testsuite variable, not ours.
19841985
local -x GCC_TEST_RUN_EXPENSIVE=1
19851986

19861987
# Use a subshell to allow meddling with flags just for the testsuite
19871988
(
1988-
# Unexpected warnings confuse the tests.
1989-
filter-flags -W*
1990-
# May break parsing.
1991-
filter-flags '-fdiagnostics-color=*' '-fdiagnostics-urls=*'
1992-
# Gentoo QA flags which don't belong in tests
1993-
filter-flags -frecord-gcc-switches
1994-
filter-flags '-Wl,--defsym=__gentoo_check_ldflags__=0'
1995-
# Go doesn't support this and causes noisy warnings
1996-
filter-flags -Wbuiltin-declaration-mismatch
1997-
# The ASAN tests at least need LD_PRELOAD and the contract
1998-
# tests.
1999-
filter-flags -fno-semantic-interposition
2000-
20011989
# Workaround our -Wformat-security default which breaks
20021990
# various tests as it adds unexpected warning output.
2003-
append-flags -Wno-format-security -Wno-format
1991+
GCC_TESTS_CFLAGS+=" -Wno-format-security -Wno-format"
1992+
GCC_TESTS_CXXFLAGS+=" -Wno-format-security -Wno-format"
1993+
20041994
# Workaround our -Wtrampolines default which breaks
20051995
# tests too.
2006-
append-flags -Wno-trampolines
1996+
GCC_TESTS_CFLAGS+=" -Wno-trampolines"
1997+
GCC_TESTS_CXXFLAGS+=" -Wno-trampolines"
20071998
# A handful of Ada (and objc++?) tests need an executable stack
2008-
append-ldflags -Wl,--no-warn-execstack
1999+
GCC_TESTS_LDFLAGS+=" -Wl,--no-warn-execstack"
20092000
# Avoid confusing tests like Fortran/C interop ones where
20102001
# CFLAGS are used.
2011-
append-flags -Wno-complain-wrong-lang
2002+
GCC_TESTS_CFLAGS+=" -Wno-complain-wrong-lang"
2003+
GCC_TESTS_CXXFLAGS+=" -Wno-complain-wrong-lang"
20122004

20132005
# Issues with Ada tests:
20142006
# gnat.dg/align_max.adb
@@ -2019,45 +2011,50 @@ toolchain_src_test() {
20192011
#
20202012
# TODO: This isn't ideal given it obv. affects codegen
20212013
# and we want to be sure it works.
2022-
append-flags -fno-stack-clash-protection
2014+
GCC_TESTS_CFLAGS+=" -fno-stack-clash-protection"
2015+
GCC_TESTS_CXXFLAGS+=" -fno-stack-clash-protection"
20232016

20242017
# configure defaults to '-O2 -g' and some tests expect it
20252018
# accordingly.
2026-
append-flags -g
2019+
GCC_TESTS_CFLAGS+=" -g"
20272020

20282021
# TODO: Does this handle s390 (-m31) correctly?
20292022
# TODO: What if there are multiple ABIs like x32 too?
2030-
is_multilib && GCC_TESTS_RUNTESTFLAGS+=" --target_board=unix{,-m32}"
2023+
# XXX: Disabled until validate_failures.py can handle 'variants'
2024+
# XXX: https://gcc.gnu.org/PR116260
2025+
#is_multilib && GCC_TESTS_RUNTESTFLAGS+=" --target_board=unix{,-m32}"
20312026

20322027
# nonfatal here as we die if the comparison below fails. Also, note that
20332028
# the exit code of targets other than 'check' may be unreliable.
20342029
#
20352030
# CFLAGS and so on are repeated here because of tests vs building test
20362031
# deps like libbacktrace.
2032+
#
2033+
# TODO: Should we try pass in the regular user flags for the non-RUNTESTFLAGS
2034+
# instances below for building e.g. libbacktrace?
20372035
nonfatal emake -C "${WORKDIR}"/build -k "${GCC_TESTS_CHECK_TARGET}" \
20382036
RUNTESTFLAGS=" \
20392037
${GCC_TESTS_RUNTESTFLAGS} \
2040-
CFLAGS_FOR_TARGET='${CFLAGS_FOR_TARGET:-${CFLAGS}}' \
2041-
CXXFLAGS_FOR_TARGET='${CXXFLAGS_FOR_TARGET:-${CXXFLAGS}}' \
2042-
LDFLAGS_FOR_TARGET='${LDFLAGS_FOR_TARGET:-${LDFLAGS}}' \
2043-
CFLAGS='${CFLAGS}' \
2044-
CXXFLAGS='${CXXFLAGS}' \
2045-
FCFLAGS='${FCFLAGS}' \
2046-
FFLAGS='${FFLAGS}' \
2047-
LDFLAGS='${LDFLAGS}' \
2038+
CFLAGS_FOR_TARGET='${GCC_TESTS_CFLAGS_FOR_TARGET:-${GCC_TESTS_CFLAGS}}' \
2039+
CXXFLAGS_FOR_TARGET='${GCC_TESTS_CXXFLAGS_FOR_TARGET:-${GCC_TESTS_CXXFLAGS}}' \
2040+
LDFLAGS_FOR_TARGET='${TEST_LDFLAGS_FOR_TARGET:-${GCC_TESTS_LDFLAGS}}' \
2041+
CFLAGS='${GCC_TESTS_CFLAGS}' \
2042+
CXXFLAGS='${GCC_TESTS_CXXFLAGS}' \
2043+
FCFLAGS='${GCC_TESTS_FCFLAGS}' \
2044+
FFLAGS='${GCC_TESTS_FFLAGS}' \
2045+
LDFLAGS='${GCC_TESTS_LDFLAGS}' \
20482046
" \
2049-
CFLAGS_FOR_TARGET="${CFLAGS_FOR_TARGET:-${CFLAGS}}" \
2050-
CXXFLAGS_FOR_TARGET="${CXXFLAGS_FOR_TARGET:-${CXXFLAGS}}" \
2051-
LDFLAGS_FOR_TARGET="${LDFLAGS_FOR_TARGET:-${LDFLAGS}}" \
2052-
CFLAGS="${CFLAGS}" \
2053-
CXXFLAGS="${CXXFLAGS}" \
2054-
FCFLAGS="${FCFLAGS}" \
2055-
FFLAGS="${FFLAGS}" \
2056-
LDFLAGS="${LDFLAGS}"
2047+
CFLAGS_FOR_TARGET="${GCC_TESTS_CFLAGS_FOR_TARGET:-${GCC_TESTS_CFLAGS}}" \
2048+
CXXFLAGS_FOR_TARGET="${GCC_TESTS_CXXFLAGS_FOR_TARGET:-${GCC_TESTS_CXXFLAGS}}" \
2049+
LDFLAGS_FOR_TARGET="${GCC_TESTS_LDFLAGS_FOR_TARGET:-${GCC_TESTS_LDFLAGS}}" \
2050+
CFLAGS="${GCC_TESTS_CFLAGS}" \
2051+
CXXFLAGS="${GCC_TESTS_CXXFLAGS}" \
2052+
FCFLAGS="${GCC_TESTS_FCFLAGS}" \
2053+
FFLAGS="${GCC_TESTS_FFLAGS}" \
2054+
LDFLAGS="${GCC_TESTS_LDFLAGS}"
20572055
)
20582056

20592057
# Produce an updated failure manifest.
2060-
# XXX: Manifests aren't ideal w/ multilib because of https://gcc.gnu.org/PR116260
20612058
einfo "Generating a new failure manifest ${T}/${CHOST}.xfail"
20622059
rm -f "${T}"/${CHOST}.xfail
20632060
edo "${T}"/validate_failures.py \
@@ -2109,7 +2106,7 @@ toolchain_src_test() {
21092106
eerror "GCC_TESTS_IGNORE_NO_BASELINE is set, ignoring test result and creating a new baseline..."
21102107
elif [[ -n ${GCC_TESTS_REGEN_BASELINE} ]] ; then
21112108
eerror "GCC_TESTS_REGEN_BASELINE is set, ignoring test result and creating using a new baseline..."
2112-
elif [[ ${ret} != 0 ]]; then
2109+
elif [[ ${ret} != 0 ]] ; then
21132110
eerror "(Set GCC_TESTS_IGNORE_NO_BASELINE=1 to make this non-fatal and generate a baseline.)"
21142111
die "Tests failed (failures occurred with no reference data)"
21152112
fi
@@ -2337,7 +2334,7 @@ toolchain_src_install() {
23372334
pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
23382335
pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
23392336

2340-
if use test ; then
2337+
if [[ -n ${TOOLCHAIN_HAS_TESTS} ]] && use test ; then
23412338
mkdir "${T}"/test-results || die
23422339
cd "${WORKDIR}"/build || die
23432340
find . -name \*.sum -exec cp --parents -v {} "${T}"/test-results \; || die
@@ -2510,7 +2507,7 @@ create_revdep_rebuild_entry() {
25102507
#---->> pkg_pre* <<----
25112508

25122509
toolchain_pkg_preinst() {
2513-
if [[ ${MERGE_TYPE} != binary ]] && use test ; then
2510+
if [[ -n ${TOOLCHAIN_HAS_TESTS} && ${MERGE_TYPE} != binary ]] && use test ; then
25142511
# Install as orphaned to allow comparison across more versions even
25152512
# after unmerged. Also useful for historical records and tracking
25162513
# down regressions a while after they first appeared, but were only

0 commit comments

Comments
 (0)