On Wed, Jul 02, 2025 at 11:43:13AM +0200, Stefan Schulze Frielinghaus wrote: > On Tue, Jul 01, 2025 at 06:33:12PM +0200, Jakub Jelinek wrote: > > On Tue, Jul 01, 2025 at 03:47:53PM +0200, Stefan Schulze Frielinghaus wrote: > > > In the past years I have started to use more and more function body > > > checks whenever gcc emits optimal code for a function. With that I > > > wanted to make sure that we do not regress like introducing unnecessary > > > extends or whatever which might not have been caught by only testing the > > > "interesting"/actual part of a patch. Thus, as long as those function > > > body checks are stable enough, i.e., not subject to insn reordering or > > > the like, I would like to make use of them in the future, too. That > > > being said I'm wondering whether it would make sense to automatically > > > add option -fno-stack-protector for tests which make use function-body > > > checks? If the testsuite infrastructure doesn't provide this > > > functionality trivially, I will try to keep this in mind and always add > > > the option manually. > > > > I think even better would be to make the check-function-body UNSUPPORTED > > if there is no explicit -f{,no-}stack-protector* among > > dg-options/dg-additional-options and the option is still used. > > Because the test can be also dg-do run and it might be useful to run the > > test. > > So maybe something along the lines? > > diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp > index 97935cb23c3..bb16ae897c1 100644 > --- a/gcc/testsuite/lib/scanasm.exp > +++ b/gcc/testsuite/lib/scanasm.exp > @@ -1042,6 +1042,15 @@ proc check-function-bodies { args } { > # The name might include a list of options; extract the file name. > set filename [lindex $testcase 0] > > + global compiler_flags > + set current_compiler_flags [current_compiler_flags] > + if { [string match "* -fstack-protector* *" " ${compiler_flags} "] > + && ![string match "* -fstack-protector* *" " > ${current_compiler_flags} "] > + && ![string match "* -fno-stack-protector* *" " > ${current_compiler_flags} "] } { > + unsupported "$testcase: skip check-function-bodies due to stack > protector" > + return > + } > + > global srcdir > set input_filename "$srcdir/$filename" > set output_filename "[file rootname [file tail $filename]]" > > I'm pretty new to tcl and didn't do extensive testing but for my few > experiments it worked so far. I guess `string match` uses globbing so > something like "* -f(no-)?stack-protector* *" doesn't work which is why > I used two matches.
Yes. Though maybe it could/should include other options known to change the prologue/epilogue substantially, I think e.g. -fstack-clash-protection or -fhardened or -fstack-check* might be other candidates. I admit I haven't looked out what compiler_flags and current_compiler_flags are at that point, which one is the effective command line after all RUNTESTFLAGS and dg-options/dg-additional-options options and what is just from the latter two. And we'd need to document it. That said, I think some distros (Debian?) configure with -fhardened on by default or similar options, not sure if those tests fail in all those cases and if those distros have been just ignoring it or what. Jakub