From: Stefan Schulze Frielinghaus <stefa...@gcc.gnu.org> My understand is that during check_compile compiler_flags contains all the options passed to gcc and current_compiler_flags contains options passed via dg-options and dg-additional-options. I did a couple of experiments and printf-style debugging which endorsed that this is true. Nevertheless, would be great if someone with tcl experience could ack this.
Another small experiment shows for gcc.target/s390/foo.c with /* { dg-do run } */ /* { dg-options "-O2 -save-temps" } */ /* { dg-final { check-function-bodies "**" "" "" } } */ /* ** main: ** lghi %r2,0 ** br %r14 */ int main (void) { } and using --target_board='unix{-fstack-protector-all}' we have PASS: gcc.target/s390/foo.c (test for excess errors) PASS: gcc.target/s390/foo.c execution test UNSUPPORTED: gcc.target/s390/foo.c: skip check-function-bodies due to implicit prologue/epilogue changes e.g. by stack protector Whereas without --target_board='unix{-fstack-protector-all}' we have PASS: gcc.target/s390/foo.c (test for excess errors) PASS: gcc.target/s390/foo.c execution test PASS: gcc.target/s390/foo.c check-function-bodies main For gcc.target/s390/bar.c with (note the option -fstack-protector) /* { dg-do run } */ /* { dg-options "-O2 -save-temps -fstack-protector" } */ /* { dg-final { check-function-bodies "**" "" "" } } */ /* ** main: ** lghi %r2,0 ** br %r14 */ int main (void) { } we get with and without --target_board='unix{-fstack-protector-all}' PASS: gcc.target/s390/bar.c (test for excess errors) PASS: gcc.target/s390/bar.c execution test PASS: gcc.target/s390/bar.c check-function-bodies main Bootstrapped and regtested on x86_64. Running the testsuite on x86_64 using --target_board='unix{-fstack-protector-all}' "resolves" the following failures if the patch is applied: FAIL: g++.target/i386/memset-pr101366-1.C check-function-bodies _Z4TestPc FAIL: g++.target/i386/memset-pr101366-2.C check-function-bodies _Z4TestPc FAIL: g++.target/i386/memset-pr108585-1a.C check-function-bodies _Z6squarei FAIL: g++.target/i386/memset-pr108585-1b.C check-function-bodies _Z6squarei FAIL: g++.target/i386/memset-pr118276-1a.C check-function-bodies _Z22makeDefaultConstructedv FAIL: g++.target/i386/memset-pr118276-1b.C check-function-bodies _Z22makeDefaultConstructedv FAIL: g++.target/i386/memset-pr118276-1c.C check-function-bodies _Z22makeDefaultConstructedv FAIL: gcc.target/i386/memset-pr70308-1a.c check-function-bodies foo FAIL: gcc.target/i386/memset-pr70308-1b.c check-function-bodies foo FAIL: gcc.target/i386/memset-strategy-25.c check-function-bodies foo FAIL: gcc.target/i386/memset-strategy-28.c check-function-bodies foo FAIL: gcc.target/i386/memset-strategy-29.c check-function-bodies foo FAIL: gcc.target/i386/memset-strategy-30.c check-function-bodies foo FAIL: gcc.target/i386/memset-strategy-31.c check-function-bodies foo FAIL: gcc.target/i386/pr111673.c check-function-bodies advance FAIL: gcc.target/i386/pr116174.c check-function-bodies foo FAIL: gcc.target/i386/pr119784a.c check-function-bodies start FAIL: gcc.target/i386/pr82142a.c check-function-bodies assignzero FAIL: gcc.target/i386/pr92080-17.c check-function-bodies foo FAIL: gcc.target/i386/pr93492-1.c check-function-bodies f10_endbr FAIL: gcc.target/i386/pr93492-1.c check-function-bodies f10_none FAIL: gcc.target/i386/pr93492-1.c check-function-bodies f11_endbr FAIL: gcc.target/i386/pr93492-1.c check-function-bodies f11_none FAIL: gcc.target/i386/pr93492-1.c check-function-bodies f21_endbr FAIL: gcc.target/i386/pr93492-1.c check-function-bodies f21_none FAIL: gcc.target/i386/preserve-none-25.c check-function-bodies entry FAIL: gcc.target/i386/preserve-none-26.c check-function-bodies entry FAIL: gcc.target/i386/preserve-none-27.c check-function-bodies entry FAIL: gcc.target/i386/preserve-none-30a.c check-function-bodies entry FAIL: gcc.target/i386/preserve-none-30b.c check-function-bodies entry Ok for mainline? -- 8< -- If a check-function-bodies test is compiled using -fstack-protector*, -fhardened, -fstack-check*, or -fstack-clash-protection, but the test is not asking explicitly for those via dg-options or dg-additional-options, then mark the test as unsupported. Since these features influence prologue/epilogue it is rarely useful to check the full function body, if the test is not explicitly prepared for those. This might happen when the testsuite is passed additional options as e.g. via --target_board='unix{-fstack-protector-all}'. Co-Authored-By: Jakub Jelinek <ja...@redhat.com> --- gcc/doc/sourcebuild.texi | 9 +++++++++ gcc/testsuite/lib/scanasm.exp | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 6c5586e4b03..2980b04cb0e 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -3621,6 +3621,15 @@ command line. This can help if a source file is compiled both with and without optimization, since it is rarely useful to check the full function body for unoptimized code. +Similarly, if a check-function-bodies test is compiled using +@samp{-fstack-protector*}, @samp{-fhardened}, @samp{-fstack-check*}, or +@samp{-fstack-clash-protection}, but the test is not asking explicitly for +those via @samp{dg-options} or @samp{dg-additional-options}, then mark the +test as unsupported. Since these features influence prologue/epilogue it is +rarely useful to check the full function body, if the test is not explicitly +prepared for those. This might happen when the testsuite is passed additional +options as e.g.@: via @samp{--target_board='unix@{-fstack-protector-all@}'}. + The first line of the expected output for a function @var{fn} has the form: @smallexample diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index 97935cb23c3..814843306ad 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -1042,6 +1042,23 @@ proc check-function-bodies { args } { # The name might include a list of options; extract the file name. set filename [lindex $testcase 0] + # The set of options passed to gcc + global compiler_flags + # The set of options specified in the individual test case + # including dg-options and dg-additional-options + set current_compiler_flags [current_compiler_flags] + if { ( [lsearch -glob $compiler_flags "-fstack-protector*"] >= 0 + && [lsearch -regex $current_compiler_flags "-f(no-)?stack-protector"] == -1 ) + || ( [lsearch -exact $compiler_flags "-fhardened"] >= 0 + && [lsearch -regex $current_compiler_flags "-f(no-)?hardened"] == -1 ) + || ( [lsearch -glob $compiler_flags "-fstack-check*"] >= 0 + && [lsearch -regex $current_compiler_flags "-f(no-)?stack-check.*"] == -1 ) + || ( [lsearch -exact $compiler_flags "-fstack-clash-protection"] >= 0 + && [lsearch -regex $current_compiler_flags "-f(no-)?stack-clash-protection"] == -1 ) } { + unsupported "$testcase: skip check-function-bodies due to implicit prologue/epilogue changes e.g. by stack protector" + return + } + global srcdir set input_filename "$srcdir/$filename" set output_filename "[file rootname [file tail $filename]]" -- 2.49.0