@@ -22,7 +22,9 @@ _TOOLCHAIN_ECLASS=1
22
22
DESCRIPTION=" The GNU Compiler Collection"
23
23
HOMEPAGE=" https://gcc.gnu.org/"
24
24
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
26
28
27
29
tc_is_live () {
28
30
[[ ${PV} == * 9999* ]]
@@ -60,9 +62,6 @@ is_crosscompile() {
60
62
[[ ${CHOST} != ${CTARGET} ]]
61
63
}
62
64
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
-
66
65
# @FUNCTION: tc_version_is_at_least
67
66
# @USAGE: ver1 [ver2]
68
67
# @DESCRIPTION:
@@ -146,6 +145,12 @@ tc_version_is_between() {
146
145
# @DESCRIPTION:
147
146
# Indicate the developer who hosts the patchset for an ebuild.
148
147
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
+
149
154
# @ECLASS_VARIABLE: GCC_PV
150
155
# @INTERNAL
151
156
# @DESCRIPTION:
@@ -276,14 +281,15 @@ STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VE
276
281
LICENSE=" GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
277
282
IUSE=" test vanilla +nls"
278
283
RESTRICT=" !test? ( test )"
284
+ [[ -z ${TOOLCHAIN_HAS_TESTS} ]] && RESTRICT+=" test"
279
285
280
286
TC_FEATURES=()
281
287
282
288
tc_has_feature () {
283
289
has " $1 " " ${TC_FEATURES[@]} "
284
290
}
285
291
286
- # Prefix : allow gcc-apple post 4.2.1
292
+ # PREFIX_LOCAL : allow gcc-apple post 4.2.1
287
293
if [[ ${PN} != " kgcc64" && ${PN} != gcc-* ]] ||
288
294
[[ ${PN} == " gcc-apple" && $( tc_version_is_at_least 12.1) == 0 ]] ; then
289
295
IUSE+=" debug +cxx +nptl" TC_FEATURES+=( nptl )
358
364
359
365
BDEPEND="
360
366
app-alternatives/yacc
367
+ !elibc_Darwin? ( sys-devel/binutils:* )
361
368
>=sys-devel/flex-2.5.4
362
369
nls? ( sys-devel/gettext )
363
370
test? (
@@ -418,7 +425,7 @@ if tc_has_feature rust && tc_version_is_at_least 14.0.0_pre20230421 ; then
418
425
fi
419
426
420
427
# 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 "
422
429
423
430
# ---->> S + SRC_URI essentials <<----
424
431
@@ -542,7 +549,8 @@ get_gcc_src_uri() {
542
549
[[ -n ${MUSL_VER} ]] && \
543
550
GCC_SRC_URI+=" $( gentoo_urls gcc-${MUSL_GCC_VER} -musl-patches-${MUSL_VER} .tar.${TOOLCHAIN_PATCH_SUFFIX} ) "
544
551
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 )"
546
554
547
555
echo " ${GCC_SRC_URI} "
548
556
}
@@ -574,7 +582,7 @@ toolchain_pkg_setup() {
574
582
# more legible.
575
583
MAKEOPTS=" --output-sync=line ${MAKEOPTS} "
576
584
577
- use test && python-any-r1_pkg_setup
585
+ [[ -n ${TOOLCHAIN_HAS_TESTS} ]] && use test && python-any-r1_pkg_setup
578
586
}
579
587
580
588
# ---->> src_unpack <<----
@@ -599,16 +607,6 @@ toolchain_fetch_git_patches() {
599
607
mkdir " ${WORKDIR} " /musl || die
600
608
mv " ${WORKDIR} " /patch.tmp/${PATCH_GCC_VER} /musl/* " ${WORKDIR} " /musl || die
601
609
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
612
610
}
613
611
614
612
toolchain_src_unpack () {
@@ -661,7 +659,7 @@ toolchain_src_prepare() {
661
659
sed -i -e " /\" \/System\/Library\/Frameworks\" \,/i\ \ \" ${EPREFIX} /MacOSX.sdk/System/Library/Frameworks\" \, \" ${EPREFIX} /Frameworks\" \, " \
662
660
" ${S} " /gcc/config/${darwindriver} || die " sed gcc/config/${darwindriver} failed"
663
661
664
- if use test ; then
662
+ if [[ -n ${TOOLCHAIN_HAS_TESTS} ]] && use test ; then
665
663
cp " ${DISTDIR} " /gcc-validate-failures-${GCC_VALIDATE_FAILURES_VERSION} .py " ${T} " /validate_failures.py || die
666
664
chmod +x " ${T} " /validate_failures.py || die
667
665
fi
@@ -1133,7 +1131,7 @@ toolchain_src_configure() {
1133
1131
# should be /usr, because it's the path to search includes
1134
1132
# for, which is unrelated to TOOLCHAIN_PREFIX, a.k.a.
1135
1133
# PREFIX
1136
- confgcc+=( --with-local-prefix=" ${TPREFIX } /usr" )
1134
+ confgcc+=( --with-local-prefix=" ${EPREFIX } /usr" )
1137
1135
1138
1136
# enable the configured SDK, Apple no longer installs stuff
1139
1137
# into /usr
@@ -1349,7 +1347,9 @@ toolchain_src_configure() {
1349
1347
fi
1350
1348
1351
1349
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
1353
1353
[[ ${CTARGET} == aarch64-* -gnu* ]] && confgcc+=( $( use_enable cet standard-branch-protection) )
1354
1354
fi
1355
1355
@@ -1920,7 +1920,6 @@ gcc_do_make() {
1920
1920
1921
1921
einfo " Compiling ${PN} (${GCC_MAKE_TARGET} )..."
1922
1922
pushd " ${WORKDIR} " /build > /dev/null || die
1923
-
1924
1923
emake " ${emakeargs[@]} " ${GCC_MAKE_TARGET}
1925
1924
1926
1925
if is_ada; then
@@ -1981,34 +1980,27 @@ toolchain_src_test() {
1981
1980
local -x LD_PRELOAD=
1982
1981
1983
1982
# 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.
1984
1985
local -x GCC_TEST_RUN_EXPENSIVE=1
1985
1986
1986
1987
# Use a subshell to allow meddling with flags just for the testsuite
1987
1988
(
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
-
2001
1989
# Workaround our -Wformat-security default which breaks
2002
1990
# 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
+
2004
1994
# Workaround our -Wtrampolines default which breaks
2005
1995
# tests too.
2006
- append-flags -Wno-trampolines
1996
+ GCC_TESTS_CFLAGS+=" -Wno-trampolines"
1997
+ GCC_TESTS_CXXFLAGS+=" -Wno-trampolines"
2007
1998
# 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"
2009
2000
# Avoid confusing tests like Fortran/C interop ones where
2010
2001
# 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"
2012
2004
2013
2005
# Issues with Ada tests:
2014
2006
# gnat.dg/align_max.adb
@@ -2019,45 +2011,50 @@ toolchain_src_test() {
2019
2011
#
2020
2012
# TODO: This isn't ideal given it obv. affects codegen
2021
2013
# 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"
2023
2016
2024
2017
# configure defaults to '-O2 -g' and some tests expect it
2025
2018
# accordingly.
2026
- append-flags -g
2019
+ GCC_TESTS_CFLAGS+= " -g"
2027
2020
2028
2021
# TODO: Does this handle s390 (-m31) correctly?
2029
2022
# 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}"
2031
2026
2032
2027
# nonfatal here as we die if the comparison below fails. Also, note that
2033
2028
# the exit code of targets other than 'check' may be unreliable.
2034
2029
#
2035
2030
# CFLAGS and so on are repeated here because of tests vs building test
2036
2031
# 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?
2037
2035
nonfatal emake -C " ${WORKDIR} " /build -k " ${GCC_TESTS_CHECK_TARGET} " \
2038
2036
RUNTESTFLAGS=" \
2039
2037
${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 } ' \
2048
2046
" \
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 } "
2057
2055
)
2058
2056
2059
2057
# Produce an updated failure manifest.
2060
- # XXX: Manifests aren't ideal w/ multilib because of https://gcc.gnu.org/PR116260
2061
2058
einfo " Generating a new failure manifest ${T} /${CHOST} .xfail"
2062
2059
rm -f " ${T} " /${CHOST} .xfail
2063
2060
edo " ${T} " /validate_failures.py \
@@ -2109,7 +2106,7 @@ toolchain_src_test() {
2109
2106
eerror " GCC_TESTS_IGNORE_NO_BASELINE is set, ignoring test result and creating a new baseline..."
2110
2107
elif [[ -n ${GCC_TESTS_REGEN_BASELINE} ]] ; then
2111
2108
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
2113
2110
eerror " (Set GCC_TESTS_IGNORE_NO_BASELINE=1 to make this non-fatal and generate a baseline.)"
2114
2111
die " Tests failed (failures occurred with no reference data)"
2115
2112
fi
@@ -2337,7 +2334,7 @@ toolchain_src_install() {
2337
2334
pax-mark -r " ${ED} /libexec/gcc/${CTARGET} /${GCC_CONFIG_VER} /cc1"
2338
2335
pax-mark -r " ${ED} /libexec/gcc/${CTARGET} /${GCC_CONFIG_VER} /cc1plus"
2339
2336
2340
- if use test ; then
2337
+ if [[ -n ${TOOLCHAIN_HAS_TESTS} ]] && use test ; then
2341
2338
mkdir " ${T} " /test-results || die
2342
2339
cd " ${WORKDIR} " /build || die
2343
2340
find . -name \* .sum -exec cp --parents -v {} " ${T} " /test-results \; || die
@@ -2510,7 +2507,7 @@ create_revdep_rebuild_entry() {
2510
2507
# ---->> pkg_pre* <<----
2511
2508
2512
2509
toolchain_pkg_preinst () {
2513
- if [[ ${MERGE_TYPE} != binary ]] && use test ; then
2510
+ if [[ -n ${TOOLCHAIN_HAS_TESTS} && ${MERGE_TYPE} != binary ]] && use test ; then
2514
2511
# Install as orphaned to allow comparison across more versions even
2515
2512
# after unmerged. Also useful for historical records and tracking
2516
2513
# down regressions a while after they first appeared, but were only
0 commit comments