On Thu, Jul 03, 2025 at 02:55:37PM +0200, Stefan Schulze Frielinghaus wrote:
> Ok for mainline?

ChangeLog is missing.
And I think I'd appreciate another pair of eyes, Rainer/Mike, what do you
think about this?

> 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

        Jakub

Reply via email to