Skip to content

Commit

Permalink
toolchain.eclass: don't pass user flags in src_test
Browse files Browse the repository at this point in the history
This is obvious in hindsight. The flags we were passing *precisely because*
we wanted e.g. -Wno-format to be passed to every test also included
-O2 or whatever from the user's flags which breaks tests that may require
no optimisation and so on.

Instead of trying to filter out options in a whack-a-mole game, let's
introduce special GCC_TESTS_* *FLAGS variables which we append
the needed -Wno-* to (etc.) which users can also specify if they really want
or need to.

Note that this isn't as scary or as weird as it sounds. We were only
trying to jam these flags in **purely** to counteract some defaults
we set, these tests really aren't supposed to be run with arbitrary
flags stuck in, but a workaround we added started to introduce way
more than intended.

The torture tests are fine with being run with various optimisation flags
but the rest of the testesuite isn't.

This fixes 361c375 and some of the
attempts afterwards, although not everything in those commits was bad.

Fixes: 361c375
Signed-off-by: Sam James <[email protected]>
  • Loading branch information
thesamesam committed Aug 12, 2024
1 parent 5ea011f commit 15ce827
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions eclass/toolchain.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -1941,15 +1941,19 @@ toolchain_src_test() {

# Workaround our -Wformat-security default which breaks
# various tests as it adds unexpected warning output.
append-flags -Wno-format-security -Wno-format
GCC_TESTS_CFLAGS+=" -Wno-format-security -Wno-format"
GCC_TESTS_CXXFLAGS+=" -Wno-format-security -Wno-format"

# Workaround our -Wtrampolines default which breaks
# tests too.
append-flags -Wno-trampolines
GCC_TESTS_CFLAGS+=" -Wno-trampolines"
GCC_TESTS_CXXFLAGS+=" -Wno-trampolines"
# A handful of Ada (and objc++?) tests need an executable stack
append-ldflags -Wl,--no-warn-execstack
GCC_TESTS_LDFLAGS+=" -Wl,--no-warn-execstack"
# Avoid confusing tests like Fortran/C interop ones where
# CFLAGS are used.
append-flags -Wno-complain-wrong-lang
GCC_TESTS_CFLAGS+=" -Wno-complain-wrong-lang"
GCC_TESTS_CXXFLAGS+=" -Wno-complain-wrong-lang"

# Issues with Ada tests:
# gnat.dg/align_max.adb
Expand All @@ -1960,11 +1964,12 @@ toolchain_src_test() {
#
# TODO: This isn't ideal given it obv. affects codegen
# and we want to be sure it works.
append-flags -fno-stack-clash-protection
GCC_TESTS_CFLAGS+=" -fno-stack-clash-protection"
GCC_TESTS_CXXFLAGS+=" -fno-stack-clash-protection"

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

# TODO: Does this handle s390 (-m31) correctly?
# TODO: What if there are multiple ABIs like x32 too?
Expand All @@ -1980,23 +1985,23 @@ toolchain_src_test() {
nonfatal emake -C "${WORKDIR}"/build -k "${GCC_TESTS_CHECK_TARGET}" \
RUNTESTFLAGS=" \
${GCC_TESTS_RUNTESTFLAGS} \
CFLAGS_FOR_TARGET='${CFLAGS_FOR_TARGET:-${CFLAGS}}' \
CXXFLAGS_FOR_TARGET='${CXXFLAGS_FOR_TARGET:-${CXXFLAGS}}' \
LDFLAGS_FOR_TARGET='${LDFLAGS_FOR_TARGET:-${LDFLAGS}}' \
CFLAGS='${CFLAGS}' \
CXXFLAGS='${CXXFLAGS}' \
FCFLAGS='${FCFLAGS}' \
FFLAGS='${FFLAGS}' \
LDFLAGS='${LDFLAGS}' \
CFLAGS_FOR_TARGET='${GCC_TESTS_CFLAGS_FOR_TARGET:-${GCC_TESTS_CFLAGS}}' \
CXXFLAGS_FOR_TARGET='${GCC_TESTS_CXXFLAGS_FOR_TARGET:-${GCC_TESTS_CXXFLAGS}}' \
LDFLAGS_FOR_TARGET='${TEST_LDFLAGS_FOR_TARGET:-${GCC_TESTS_LDFLAGS}}' \
CFLAGS='${GCC_TESTS_CFLAGS}' \
CXXFLAGS='${GCC_TESTS_CXXFLAGS}' \
FCFLAGS='${GCC_TESTS_FCFLAGS}' \
FFLAGS='${GCC_TESTS_FFLAGS}' \
LDFLAGS='${GCC_TESTS_LDFLAGS}' \
" \
CFLAGS_FOR_TARGET="${CFLAGS_FOR_TARGET:-${CFLAGS}}" \
CXXFLAGS_FOR_TARGET="${CXXFLAGS_FOR_TARGET:-${CXXFLAGS}}" \
LDFLAGS_FOR_TARGET="${LDFLAGS_FOR_TARGET:-${LDFLAGS}}" \
CFLAGS="${CFLAGS}" \
CXXFLAGS="${CXXFLAGS}" \
FCFLAGS="${FCFLAGS}" \
FFLAGS="${FFLAGS}" \
LDFLAGS="${LDFLAGS}"
CFLAGS_FOR_TARGET="${GCC_TESTS_CFLAGS_FOR_TARGET:-${GCC_TESTS_CFLAGS}}" \
CXXFLAGS_FOR_TARGET="${GCC_TESTS_CXXFLAGS_FOR_TARGET:-${GCC_TESTS_CXXFLAGS}}" \
LDFLAGS_FOR_TARGET="${GCC_TESTS_LDFLAGS_FOR_TARGET:-${GCC_TESTS_LDFLAGS}}" \
CFLAGS="${GCC_TESTS_CFLAGS}" \
CXXFLAGS="${GCC_TESTS_CXXFLAGS}" \
FCFLAGS="${GCC_TESTS_FCFLAGS}" \
FFLAGS="${GCC_TESTS_FFLAGS}" \
LDFLAGS="${GCC_TESTS_LDFLAGS}"
)

# Produce an updated failure manifest.
Expand Down

0 comments on commit 15ce827

Please sign in to comment.