]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
outputs.exp: skip @file -save-temps if target has -L or -I
authorHans-Peter Nilsson <hp@axis.com>
Thu, 25 Feb 2021 04:07:37 +0000 (05:07 +0100)
committerHans-Peter Nilsson <hp@axis.com>
Tue, 2 Mar 2021 23:15:17 +0000 (00:15 +0100)
The outputs.exp tests check what temporary files are created
and left behind with e.g. -save-temps.

Additional files are created in presence of @file option.
Adding an -I or -L option causes *another* temporary file to
appear.  I take it that's deliberate, as there are tests for
that behavior.

For native testing, the default test-framework baseboard
file unix.exp doesn't add any -I or -L options and all tests
pass.  For a newlib target however, you'll have a couple of
-L options (see the nopts handling in outputs.exp), leading
to:

Running /x/gcc/gcc/testsuite/gcc.misc-tests/outputs.exp ...
FAIL: outputs exe savetmp namedb: extra
outputs.args.1
FAIL: outputs exe savetmp named2: extra
outputs.args.1
FAIL: outputs exe savetmp named2: extra
outputs.args.3
FAIL: outputs lto sing unnamed: extra
a.args.1

The failing tests are among the actual tests that check the
behavior of @file, and are confused by the additional -L.

Identify presence of -I or -L from the test framework and
skip those tests.

Tested cris-elf and x86_64-pc-linux-gnu.

gcc/testsuite:
* gcc.misc-tests/outputs.exp: Skip @file -save-temps
tests if target test-framework has -L or -I options.

gcc/testsuite/gcc.misc-tests/outputs.exp

index 4d904bde31d536514db052b34a531b45f1a3f7d4..ebd61448bfdd67d3329adb4b982c2bd207a08022 100644 (file)
@@ -57,10 +57,18 @@ set gld [check_effective_target_gld]
 # We do not compile to an executable, because that requires naming an output.
 set link_options ""
 set dest [target_info name]
+set skip_atsave 0
 foreach i { ldflags libs ldscript } {
     if {[board_info $dest exists $i]} {
        set opts [board_info $dest $i]
        set nopts [gcc_adjust_linker_flags_list $opts]
+
+       # Options -I<X> and -L<X> affect the behavior of @files
+       # wrt. temporary files.  Skip @file -save-temps tests if we
+       # have any of them in the board-flags.
+       if { [string match "* -\[LI\]*" " $nopts"]} {
+           set skip_atsave 1
+       }
        foreach opt $nopts {
            append link_options " additional_flags=$opt"
        }
@@ -298,10 +306,12 @@ outest "$b exe savetmp namedb" $sing "-o $b.exe -save-temps" {} {{--0.i --0.s --
 outest "$b exe savetmp named2" $mult "-o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o .exe}}
 
 # Additional files are created when an @file is used
+if !$skip_atsave {
 outest "$b exe savetmp namedb" $sing "@/dev/null -o $b.exe -save-temps" {} {{--0.i --0.s --0.o .args.0 !!$gld .ld1_args !0 .exe}}
 outest "$b exe savetmp named2" $mult "@/dev/null -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o .args.0 !!$gld .ld1_args !0 .exe}}
 outest "$b exe savetmp named2" $mult "@/dev/null -I dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 !!$gld .ld1_args !0 .exe}}
 outest "$b exe savetmp named2" $mult "@/dev/null -I dummy -L dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 .args.3 !!$gld .ld1_args !0 .exe}}
+}
 
 # Setting the main output to a dir selects it as the default aux&dump
 # location.
@@ -657,8 +667,10 @@ outest "$b lto sing named" $sing "-o $b.exe -O2 -flto -fno-use-linker-plugin -fl
 outest "$b lto mult named" $mult "-o $b.exe -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {} {{--1.c.???i.icf --1.c.???r.final --2.c.???i.icf --2.c.???r.final .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .exe}}
 outest "$b lto sing nameddir" $sing "-o dir/$b.exe -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--0.c.???i.icf --0.c.???r.final .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .exe} {}}
 outest "$b lto mult nameddir" $mult "-o dir/$b.exe -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--1.c.???i.icf --1.c.???r.final --2.c.???i.icf --2.c.???r.final .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .exe} {}}
+if !$skip_atsave {
 outest "$b lto sing unnamed" $sing "@/dev/null -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage -save-temps $oaout" {} {{a--0.c.???i.icf a--0.c.???r.final a.wpa.???i.icf a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a--0.o a--0.s a--0.i a.ltrans0.o a.ltrans.out a.ltrans0.ltrans.o a.ltrans0.ltrans_args a.args.0 a.ltrans0.ltrans.s a.wpa.args.0 a.lto_args a.ld1_args a.ltrans_args a.ltrans0.ltrans.args.0 a.ld_args $aout}}
 }
+}
 
 # -dumpbase without -dumpdir.  The trailing dumppfx dash after it is
 # combined with dumpbase turns into a period when passed to lto as