diff options
author | Alexandre Oliva <oliva@adacore.com> | 2024-05-30 02:06:48 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2024-05-30 02:06:48 -0300 |
commit | bdc264a16e327c63d133131a695a202fbbc0a6a0 (patch) | |
tree | c55313e92ec97846fe3f6d9b77cabc50f1fb6bb3 /gcc | |
parent | c9842f99042454bef99fe82506c6dd50f34e283e (diff) | |
download | gcc-bdc264a16e327c63d133131a695a202fbbc0a6a0.zip gcc-bdc264a16e327c63d133131a695a202fbbc0a6a0.tar.gz gcc-bdc264a16e327c63d133131a695a202fbbc0a6a0.tar.bz2 |
[testsuite] conditionalize dg-additional-sources on target and type
g++.dg/vect/pr95401.cc has dg-additional-sources, and that fails when
check_vect_support_and_set_flags finds vector support lacking for
execution tests: tests decay to compile tests, and additional sources
are rejected by the compiler when compiling to a named output file.
At first I considered using some effective target to conditionalize
the additional sources. There was no support for target-specific
additional sources, so I added that.
But then, I found that adding an effective target to check whether the
test involves linking would just make for busy work in this case, and
so I went ahead and adjusted the handling of additional sources to
refrain from adding them on compile tests, reporting them as
unsupported.
That solves the problem without using the newly-added machinery for
per-target additional sources, but I figured since I'd implemented it
I might as well contribute it, since there might be other uses for it.
for gcc/ChangeLog
* doc/sourcebuild.texi (dg-additional-sources): Document
newly-added support for target selectors, and implicit discard
on non-linking tests that name the compiler output explicitly.
for gcc/testsuite/ChangeLog
* lib/gcc-defs.exp (dg-additional-sources): Support target
selectors. Make it cumulative.
(dg-additional-files-options): Take dest and type. Note
unsupported additional sources when not linking and naming the
compiler output. Adjust source dirname prepending to cope
with leading blanks.
* lib/g++.exp (g++_target_compile): Pass dest and type on to
dg-additional-files-options.
* lib/gcc.exp (gcc_target_compile): Likewise.
* lib/gdc.exp (gdb_target_compile): Likewise.
* lib/gfortran.exp (gfortran_target_compile): Likewise.
* lib/go.exp (go_target_compile): Likewise.
* lib/obj-c++.exp (obj-c++_target_compile): Likewise.
* lib/objc.exp (objc_target_compile): Likewise.
* lib/rust.exp (rust_target_compile): Likewise.
* lib/profopt.exp (profopt-execute): Likewise-ish.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/doc/sourcebuild.texi | 8 | ||||
-rw-r--r-- | gcc/testsuite/lib/g++.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/gcc-defs.exp | 35 | ||||
-rw-r--r-- | gcc/testsuite/lib/gcc.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/gdc.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/gfortran.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/go.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/obj-c++.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/objc.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/profopt.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/rust.exp | 2 |
11 files changed, 46 insertions, 15 deletions
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 8e4e59a..e997dbe 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1320,9 +1320,15 @@ to @var{var_value} before execution of the program created by the test. Specify additional files, other than source files, that must be copied to the system where the compiler runs. -@item @{ dg-additional-sources "@var{filelist}" @} +@item @{ dg-additional-sources "@var{filelist}" [@{ target @var{selector} @}] @} Specify additional source files to appear in the compile line following the main test file. +If the directive includes the optional @samp{@{ @var{selector} @}} +then the additional sources are only added if the target system +matches the @var{selector}. +Additional sources are generally used only in @samp{link} and @samp{run} +tests; they are reported as unsupported and discarded in other kinds of +tests that direct the compiler to output to a single file. @end table @subsubsection Add checks at the end of a test diff --git a/gcc/testsuite/lib/g++.exp b/gcc/testsuite/lib/g++.exp index 0e47769..a6b34d5 100644 --- a/gcc/testsuite/lib/g++.exp +++ b/gcc/testsuite/lib/g++.exp @@ -326,7 +326,7 @@ proc g++_target_compile { source dest type options } { append board_info($tboard,multilib_flags) " $flags_to_postpone" } - set options [dg-additional-files-options $options $source] + set options [dg-additional-files-options $options $source $dest $type] if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { lappend options "libs=${gluefile}" diff --git a/gcc/testsuite/lib/gcc-defs.exp b/gcc/testsuite/lib/gcc-defs.exp index 70215ed..cdca4c2 100644 --- a/gcc/testsuite/lib/gcc-defs.exp +++ b/gcc/testsuite/lib/gcc-defs.exp @@ -307,7 +307,22 @@ set additional_sources_used "" proc dg-additional-sources { args } { global additional_sources - set additional_sources [lindex $args 1] + + if { [llength $args] > 3 } { + error "[lindex $args 0]: too many arguments" + return + } + + if { [llength $args] >= 3 } { + switch [dg-process-target [lindex $args 2]] { + "S" { append additional_sources " [lindex $args 1]" } + "N" { } + "F" { error "[lindex $args 0]: `xfail' not allowed here" } + "P" { error "[lindex $args 0]: `xfail' not allowed here" } + } + } else { + append additional_sources " [lindex $args 1]" + } } # Record additional files -- other than source files -- that must be @@ -383,20 +398,30 @@ proc gcc_adjust_linker_flags {} { # Return an updated version of OPTIONS that mentions any additional # source files registered with dg-additional-sources. SOURCE is the -# name of the test case. +# name of the test case. If DEST is given and TYPE does not require +# linking, additional sources are noted as unsupported rather than +# added, because the compiler rejects a single output for multiple +# sources. -proc dg-additional-files-options { options source } { +proc dg-additional-files-options { options source dest type } { gcc_adjust_linker_flags global additional_sources global additional_sources_used global additional_files set to_download [list] - if { $additional_sources != "" } then { + if { $additional_sources == "" } then { + } elseif { $type != "executable" && $dest != "" } then { + foreach s $additional_sources { + unsupported "$s: additional-source will not be used to build $dest" + } + set additional_sources_used "" + set additional_sources "" + } else { if [is_remote host] { lappend options "additional_flags=$additional_sources" } - regsub -all "^| " $additional_sources " [file dirname $source]/" additional_sources + regsub -all {^ *| *} $additional_sources " [file dirname $source]/" additional_sources if ![is_remote host] { lappend options "additional_flags=$additional_sources" } diff --git a/gcc/testsuite/lib/gcc.exp b/gcc/testsuite/lib/gcc.exp index 63e61c3..3bcd98e 100644 --- a/gcc/testsuite/lib/gcc.exp +++ b/gcc/testsuite/lib/gcc.exp @@ -159,7 +159,7 @@ proc gcc_target_compile { source dest type options } { lappend options "timeout=[timeout_value]" lappend options "compiler=$GCC_UNDER_TEST" - set options [dg-additional-files-options $options $source] + set options [dg-additional-files-options $options $source $dest $type] if {[target_info needs_status_wrapper] != "" && \ [target_info needs_status_wrapper] != "0" && \ diff --git a/gcc/testsuite/lib/gdc.exp b/gcc/testsuite/lib/gdc.exp index 3c28422..fd9cea6 100644 --- a/gcc/testsuite/lib/gdc.exp +++ b/gcc/testsuite/lib/gdc.exp @@ -327,6 +327,6 @@ proc gdc_target_compile { source dest type options } { lappend options "compiler=$GDC_UNDER_TEST" set options [concat "$always_dflags" $options] - set options [dg-additional-files-options $options $source] + set options [dg-additional-files-options $options $source $dest $type] return [target_compile $source $dest $type $options] } diff --git a/gcc/testsuite/lib/gfortran.exp b/gcc/testsuite/lib/gfortran.exp index 1ccb81c..3a9e81b 100644 --- a/gcc/testsuite/lib/gfortran.exp +++ b/gcc/testsuite/lib/gfortran.exp @@ -295,7 +295,7 @@ proc gfortran_target_compile { source dest type options } { lappend options "timeout=[timeout_value]" set options [concat "$ALWAYS_GFORTRANFLAGS" $options] - set options [dg-additional-files-options $options $source] + set options [dg-additional-files-options $options $source $dest $type] set return_val [target_compile $source $dest $type $options] if {[board_info $tboard exists multilib_flags]} { diff --git a/gcc/testsuite/lib/go.exp b/gcc/testsuite/lib/go.exp index 714afb1..509d528 100644 --- a/gcc/testsuite/lib/go.exp +++ b/gcc/testsuite/lib/go.exp @@ -221,6 +221,6 @@ proc go_target_compile { source dest type options } { lappend options "compiler=$GOC_UNDER_TEST" set options [concat "$ALWAYS_GOCFLAGS" $options] - set options [dg-additional-files-options $options $source] + set options [dg-additional-files-options $options $source $dest $type] return [target_compile $source $dest $type $options] } diff --git a/gcc/testsuite/lib/obj-c++.exp b/gcc/testsuite/lib/obj-c++.exp index 854dc26..1c5ef57 100644 --- a/gcc/testsuite/lib/obj-c++.exp +++ b/gcc/testsuite/lib/obj-c++.exp @@ -388,7 +388,7 @@ proc obj-c++_target_compile { source dest type options } { set options [concat "$ALWAYS_OBJCXXFLAGS" $options]; - set options [dg-additional-files-options $options $source] + set options [dg-additional-files-options $options $source $dest $type] set result [target_compile $source $dest $type $options] diff --git a/gcc/testsuite/lib/objc.exp b/gcc/testsuite/lib/objc.exp index b02fd77..3d2cc05 100644 --- a/gcc/testsuite/lib/objc.exp +++ b/gcc/testsuite/lib/objc.exp @@ -248,7 +248,7 @@ proc objc_target_compile { source dest type options } { set_ld_library_path_env_vars - set options [dg-additional-files-options $options $source] + set options [dg-additional-files-options $options $source $dest $type] return [target_compile $source $dest $type $options] } diff --git a/gcc/testsuite/lib/profopt.exp b/gcc/testsuite/lib/profopt.exp index 6524d95..6d7159b 100644 --- a/gcc/testsuite/lib/profopt.exp +++ b/gcc/testsuite/lib/profopt.exp @@ -388,7 +388,7 @@ proc profopt-execute { src } { # schedule removal of dump files et al # Do this before the call below destroys additional_sources.. append use_final_code [schedule-cleanups "$option $extra_flags"] - set extra_options [dg-additional-files-options "" "$src"] + set extra_options [dg-additional-files-options "" "$src" $execname1 "executable"] # Remove old profiling data files. Make sure additional_sources_used is # valid, by running it after dg-additional-files-options. diff --git a/gcc/testsuite/lib/rust.exp b/gcc/testsuite/lib/rust.exp index 5ded0ed..4c29622 100644 --- a/gcc/testsuite/lib/rust.exp +++ b/gcc/testsuite/lib/rust.exp @@ -182,7 +182,7 @@ proc rust_target_compile { source dest type options } { lappend options "compiler=$RUST_UNDER_TEST" set options [concat "$ALWAYS_RUSTFLAGS" $options] - set options [dg-additional-files-options $options $source] + set options [dg-additional-files-options $options $source $dest $type] return [target_compile $source $dest $type $options] } |