]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[testsuite] add linkonly to dg-additional-sources [PR115295]
authorAlexandre Oliva <oliva@adacore.com>
Mon, 2 Sep 2024 14:31:51 +0000 (11:31 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Mon, 2 Sep 2024 14:31:51 +0000 (11:31 -0300)
The D testsuite shows it was a mistake to assume that
dg-additional-sources are never to be used for compilation tests.
Even if an output file is specified for compilation, extra module
files can be named and used in the compilation without being flagged
as errors.

Introduce a 'linkonly' flag for dg-additional-sources, and use it in
pr95401.cc and other vector tests that default to run, so that its
additional sources get discarded when vector tests downgrade to
compile-only.  This reverts previous workarounds for this very
circumstance, that relied on being able to run vector tests anyway,
even after failing to detect runtime or hardware vector support.

for  gcc/ChangeLog

PR d/115295
* doc/sourcebuild.texi (dg-additional-sources): Add linkonly.

for  gcc/testsuite/ChangeLog

PR d/115295
* g++.dg/vect/pr95401.cc: Add linkonly to dg-additional-sources.
* g++.dg/vect/pr68762-1.cc: Likewise.
* g++.dg/vect/simd-clone-3.cc: Likewise.
* g++.dg/vect/simd-clone-5.cc: Likewise.
* gcc.dg/vect/vect-simd-clone-10.c: Likewise.  Drop dg-do run.
* gcc.dg/vect/vect-simd-clone-12.c: Likewise.  Likewise.
* lib/gcc-defs.exp (additional_sources_omit_on_compile): New.
(dg-additional-sources): Add to it on linkonly.
(dg-additional-files-options): Omit select sources on compile.

gcc/doc/sourcebuild.texi
gcc/testsuite/g++.dg/vect/pr68762-1.cc
gcc/testsuite/g++.dg/vect/pr95401.cc
gcc/testsuite/g++.dg/vect/simd-clone-3.cc
gcc/testsuite/g++.dg/vect/simd-clone-5.cc
gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c
gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c
gcc/testsuite/lib/gcc-defs.exp

index 0636fc0567c523dae4e81c280b240fb40f78430a..7c7094dc5a9221de01b5b2fbeea29f1963e66c38 100644 (file)
@@ -1328,15 +1328,16 @@ 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}" [@{ target @var{selector} @}] @}
+@item @{ dg-additional-sources "@var{filelist}" [@{ \[linkonly\] \[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.
+If @samp{linkonly} is specified, additional sources are 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
index 118a301ab90d5f22cf52d537905a7945b43073dc..53cc6e4c6dfa7ea66bb7d4c9e23dd68d1a0f41e3 100644 (file)
@@ -2,7 +2,7 @@
 // { dg-require-effective-target vect_simd_clones }
 // { dg-additional-options "-fopenmp-simd -fno-inline" }
 // { dg-additional-options "-mavx" { target avx_runtime } }
-// { dg-additional-sources "pr68762-2.cc" }
+// { dg-additional-sources "pr68762-2.cc" linkonly }
 
 #include "pr68762.h"
 
index 6a56dab095722b01d912416352df17f0d91dfd27..8b1be4f2425211044e7ca37565c1604923f94baa 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-additional-options "-mavx2 -O3" { target avx2_runtime } }
-// { dg-additional-sources pr95401a.cc }
+// { dg-additional-sources pr95401a.cc linkonly }
 
 extern int var_9;
 extern unsigned var_14;
index 1057a7eb5f6a51dcf5b756af665e7af368e0774c..4dd9d15d1a3bd7e7f671399ec4fc84a638e406e1 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-require-effective-target vect_simd_clones }
 // { dg-additional-options "-fopenmp-simd -fno-inline" }
 // { dg-additional-options "-mavx" { target avx_runtime } }
-// { dg-additional-sources "simd-clone-2.cc" }
+// { dg-additional-sources "simd-clone-2.cc" linkonly }
 
 #include "simd-clone-2.h"
 
index 07ec8a8079efc327f9d0e9702133416857241009..aca64a03c3aa9884ee6d5043dadd7d92774ab591 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-require-effective-target vect_simd_clones }
 // { dg-additional-options "-fopenmp-simd -fno-inline" }
 // { dg-additional-options "-mavx" { target avx_runtime } }
-// { dg-additional-sources "simd-clone-4.cc" }
+// { dg-additional-sources "simd-clone-4.cc" linkonly }
 
 #include "simd-clone-4.h"
 
index 009c849b7e7ea8e5de054f1575eb29e67ad981af..06fbdef1da9c604d01f8fef0ce907f20520b5d1c 100644 (file)
@@ -1,9 +1,7 @@
-/* Since this uses dg-additional-sources, need to specify `dg-do run` instead of the default. */
-/* { dg-do run } */
 /* { dg-require-effective-target vect_simd_clones } */
 /* { dg-additional-options "-fopenmp-simd" } */
 /* { dg-additional-options "-mavx" { target avx_runtime } } */
-/* { dg-additional-sources vect-simd-clone-10a.c } */
+/* { dg-additional-sources vect-simd-clone-10a.c linkonly } */
 
 #include "tree-vect.h"
 
index 4699a3f3c8001671a180b93b206df2ad98686c4e..f640c8bc9dd8bd48f0215f201c214cd47ceea7b9 100644 (file)
@@ -1,9 +1,7 @@
-/* Since this uses dg-additional-sources, need to specify `dg-do run` instead of the default. */
-/* { dg-do run } */
 /* { dg-require-effective-target vect_simd_clones } */
 /* { dg-additional-options "-fopenmp-simd" } */
 /* { dg-additional-options "-mavx" { target avx_runtime } } */
-/* { dg-additional-sources vect-simd-clone-12a.c } */
+/* { dg-additional-sources vect-simd-clone-12a.c linkonly } */
 
 #include "vect-simd-clone-10.c"
 
index cdca4c254d6ec33c1063a347ffbc79cb27d59765..c6ec490f0092e764f67f97bcd7d4e98d57390cd9 100644 (file)
@@ -303,18 +303,26 @@ proc dg-additional-options { args } {
 # main source file.
 
 set additional_sources ""
+set additional_sources_omit_on_compile ""
 set additional_sources_used ""
 
 proc dg-additional-sources { args } {
     global additional_sources
+    global additional_sources_omit_on_compile
 
     if { [llength $args] > 3 } {
        error "[lindex $args 0]: too many arguments"
        return
     }
 
-    if { [llength $args] >= 3 } {
-       switch [dg-process-target [lindex $args 2]] {
+    set target [lindex $args 2]
+    if { [llength $args] >= 3 && [lindex $target 0] == "linkonly" } {
+       append additional_sources_omit_on_compile " [lindex $args 1]"
+       set target [lreplace $target 0 1]
+    }
+
+    if { [llength $args] >= 3 && $target != ""} {
+       switch [dg-process-target $target] {
            "S" { append additional_sources " [lindex $args 1]" }
            "N" { }
            "F" { error "[lindex $args 0]: `xfail' not allowed here" }
@@ -407,16 +415,29 @@ proc dg-additional-files-options { options source dest type } {
     gcc_adjust_linker_flags
 
     global additional_sources
+    global additional_sources_omit_on_compile
     global additional_sources_used
     global additional_files
     set to_download [list]
-    if { $additional_sources == "" } then {
-    } elseif { $type != "executable" && $dest != "" } then {
+    if { $additional_sources_omit_on_compile != "" \
+            && $additional_sources != "" \
+            && $type != "executable" && $dest != "" } then {
+       set linkonly ""
        foreach s $additional_sources {
-           unsupported "$s: additional-source will not be used to build $dest"
+           foreach s2 $additional_sources_omit_on_compile {
+               if { $s == $s2 } {
+                   unsupported "$s: additional-source will not be used to build $dest"
+                   set s ""
+                   break
+               }
+           }
+           if { $s != "" } {
+               append linkonly " $s"
+           }
        }
-       set additional_sources_used ""
-       set additional_sources ""
+       set additional_sources "$linkonly"
+    }
+    if { $additional_sources == "" } then {
     } else {
        if [is_remote host] {
            lappend options "additional_flags=$additional_sources"