Hi,
Consider the test-case gcc.c-torture/compile/pr42717.c, which has:
...
/* { dg-xfail-if "ptxas crashes" { nvptx-*-* } { "-O0" } { "" } } */
...
When running make check-gcc, I get:
...
XPASS: gcc.c-torture/compile/pr42717.c -O0 (test for excess errors)
...
but when forcing to run only that test-case using
RUNTESTFLAGS=compile.exp=pr42717.c I get instead:
...
PASS: gcc.c-torture/compile/pr42717.c -O0 (test for excess errors)
...
Using RUNTESTFLAGS="-v -v -v" we can see what happens:
...
check_cached_effective_target exceptions_enabled: \
returning 1 for nvptx-none-run
Limited to targets: *-*-*
Will search for options "-O0"
Will exclude for options ""
Compiler flags are: exceptions_enabled9848.cc -fdiagnostics-plain-output \
--sysroot=/home/vries/nvptx/trunk/install/nvptx-none -S -isystem \
/home/vries/nvptx/trunk/build-gcc/nvptx-none/./newlib/targ-include \
-isystem /home/vries/nvptx/trunk/source-gcc/newlib/libc/include \
-o exceptions_enabled9848.s
Checking "*-*-*" against "nvptx-unknown-none"
Looking for -O0 to include in the compiler flags
Looking for to exclude in the compiler flags
This is not a conditional match
PASS: gcc.c-torture/compile/pr42717.c -O0 (test for excess errors)
...
The effective target exceptions_enabled is tested from gcc-dg-prune, but
the calculation overwrites $compiler_flags, which is subsequently tested for
-O0.
Fix this by saving and restoring $compiler_flags when calling
${tool}_target_compile in check_compile.
Tested on nvptx.
OK for trunk?
Thanks,
- Tom
[testsuite] Don't overwrite compiler_flags in check_compile
gcc/testsuite/ChangeLog:
2020-10-14 Tom de Vries
* lib/target-supports.exp (check_compile): Save and restore
$compiler_flags when calling ${tool}_target_compile.
---
gcc/testsuite/lib/target-supports.exp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gcc/testsuite/lib/target-supports.exp
b/gcc/testsuite/lib/target-supports.exp
index ecf8be3e567..8439720baea 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -86,7 +86,10 @@ proc check_compile {basename type contents args} {
set f [open $src "w"]
puts $f $contents
close $f
+global compiler_flags
+set save_compiler_flags $compiler_flags
set lines [${tool}_target_compile $src $output $compile_type "$options"]
+set compiler_flags $save_compiler_flags
file delete $src
set scan_output $output