]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Let each 'lto_init' determine the default 'LTO_OPTIONS', and 'torture-init' the ...
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 2 May 2023 17:57:47 +0000 (19:57 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Mon, 8 May 2023 13:59:24 +0000 (15:59 +0200)
Otherwise, for example for 'RUNTESTFLAGS' of '--target_board=unix\{-m64,-m32\}'
vs. '--target_board=unix\{-m32,-m64\}', both variants exercise testing with
always the first flag variant's 'LTO_OPTIONS'/'LTO_TORTURE_OPTIONS', which
results in unequal test results between the two 'RUNTESTFLAGS' variants if one
of the flag variants has 'check_linker_plugin_available' but the other doesn't.

Fix-up for r180245 (commit c1a7cdbbcca90ad5260bfc543f8c10f3514e76c1)
"Update testsuite to run with slim LTO".

gcc/testsuite/
* g++.dg/guality/guality.exp: Move 'torture-init' earlier.
* gcc.dg/guality/guality.exp: Likewise.
* gfortran.dg/guality/guality.exp: Likewise.
* lib/c-torture.exp (LTO_TORTURE_OPTIONS): Don't set.
* lib/gcc-dg.exp (LTO_TORTURE_OPTIONS): Don't set.
* lib/lto.exp (lto_init, lto_finish): Let each 'lto_init'
determine the default 'LTO_OPTIONS'.
* lib/torture-options.exp (torture-init, torture-finish): Let each
'torture-init' determine the 'LTO_TORTURE_OPTIONS'.

gcc/testsuite/g++.dg/guality/guality.exp
gcc/testsuite/gcc.dg/guality/guality.exp
gcc/testsuite/gfortran.dg/guality/guality.exp
gcc/testsuite/lib/c-torture.exp
gcc/testsuite/lib/gcc-dg.exp
gcc/testsuite/lib/lto.exp
gcc/testsuite/lib/torture-options.exp

index 2d736d292e93bbe1b7d04373229b6212b6fc40ec..cd56b06f2f0b844823b7c2c62aaaa8a84b7a5850 100644 (file)
@@ -37,6 +37,7 @@ proc check_guality {args} {
 }
 
 dg-init
+torture-init
 
 global GDB
 if ![info exists ::env(GUALITY_GDB_NAME)] {
@@ -54,7 +55,6 @@ report_gdb $::env(GUALITY_GDB_NAME) [info script]
 
 global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
 set guality_dg_torture_options [guality_minimal_options $DG_TORTURE_OPTIONS]
-torture-init
 set-torture-options \
     $guality_dg_torture_options \
     [list {}] \
index 075bebe34e8999fd56ada8a1b50bde5d4e9923f7..a8f2921d888106e5d112e7fae1c993dee5a92a0e 100644 (file)
@@ -37,6 +37,7 @@ proc check_guality {args} {
 }
 
 dg-init
+torture-init
 
 global GDB
 if ![info exists ::env(GUALITY_GDB_NAME)] {
@@ -69,7 +70,6 @@ global DG_TORTURE_OPTIONS
 set guality_dg_torture_options [guality_minimal_options $DG_TORTURE_OPTIONS]
 set guality_dg_torture_options [guality_transform_options $guality_dg_torture_options]
 set guality_lto_torture_options [guality_transform_options $LTO_TORTURE_OPTIONS]
-torture-init
 set-torture-options \
     $guality_dg_torture_options \
     [list {}] \
index 86a966a9133c77a11191e80babbebc349c04a46c..610449523f06f5ff09eb95078567aaf6a3a9a3dc 100644 (file)
@@ -18,6 +18,7 @@ if { [istarget "powerpc-ibm-aix*"] } {
 }
 
 dg-init
+torture-init
 
 global GDB
 if ![info exists ::env(GUALITY_GDB_NAME)] {
@@ -35,7 +36,6 @@ report_gdb $::env(GUALITY_GDB_NAME) [info script]
 
 global DG_TORTURE_OPTIONS
 set guality_dg_torture_options [guality_minimal_options $DG_TORTURE_OPTIONS]
-torture-init
 set-torture-options \
     $guality_dg_torture_options \
 
index e54437d5f87893a6a0fc627077360799efb59780..f62c6e9fe6ce74b96d1b9c79dbefcfc6d0329da1 100644 (file)
@@ -38,7 +38,6 @@ if { $orig_environment_saved == 0 } {
 # The default option list can be overridden by
 # TORTURE_OPTIONS="{ list1 } ... { listN }"
 
-set LTO_TORTURE_OPTIONS ""
 if [info exists TORTURE_OPTIONS] {
     set C_TORTURE_OPTIONS $TORTURE_OPTIONS
 } else {
@@ -57,22 +56,6 @@ if [info exists TORTURE_OPTIONS] {
        { -O3 -g } \
        { -Os } \
        { -Og -g } ]
-
-    if [check_effective_target_lto] {
-        # When having plugin test both slim and fat LTO and plugin/nonplugin
-        # path.
-        if [check_linker_plugin_available] {
-          set LTO_TORTURE_OPTIONS [list \
-             { -O2 -flto -fno-use-linker-plugin -flto-partition=none } \
-             { -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects }
-          ]
-        } else {
-          set LTO_TORTURE_OPTIONS [list \
-             { -O2 -flto -flto-partition=none } \
-             { -O2 -flto }
-          ]
-        }
-    }
 }
 
 if [info exists ADDITIONAL_TORTURE_OPTIONS] {
index 9d79b9402e9e4f0c45314c579f0d76d987fb456c..693cbdd7511af65bebfd4ffa45a0395ebd7a1228 100644 (file)
@@ -73,7 +73,6 @@ if { $orig_environment_saved == 0 } {
 global gcc_force_conventional_output
 set gcc_force_conventional_output ""
 
-set LTO_TORTURE_OPTIONS ""
 if [info exists TORTURE_OPTIONS] {
     set DG_TORTURE_OPTIONS $TORTURE_OPTIONS
 } else {
@@ -93,19 +92,6 @@ if [info exists TORTURE_OPTIONS] {
        { -Os } ]
 
     if [check_effective_target_lto] {
-        # When having plugin test both slim and fat LTO and plugin/nonplugin
-        # path.
-       if [check_linker_plugin_available] {
-           set LTO_TORTURE_OPTIONS [list \
-             { -O2 -flto -fno-use-linker-plugin -flto-partition=none } \
-             { -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects }
-           ]
-        } else {
-           set LTO_TORTURE_OPTIONS [list \
-             { -O2 -flto -flto-partition=none } \
-             { -O2 -flto }
-           ]
-        }
         set gcc_force_conventional_output "-ffat-lto-objects"
     }
 }
index 9e44c443bdbd906687355bc1e9b07bbc8f852718..c95e7d0a505d3cd2765906be31550aa275c0b3fd 100644 (file)
@@ -215,6 +215,11 @@ proc lto_init { args } {
              {-O2 -flto}               \
          ]
        }
+       global lto_init_set_LTO_OPTIONS
+       if [info exists lto_init_set_LTO_OPTIONS] {
+           error "lto_init_set_LTO_OPTIONS already set"
+       }
+       set lto_init_set_LTO_OPTIONS 1
     }
 }
 
@@ -233,6 +238,14 @@ proc lto_finish { } {
     } elseif [board_info $dest exists mathlib] {
        unset board_info($dest,mathlib)
     }
+
+    # Let the next 'lto_init' redetermine the default 'LTO_OPTIONS'.
+    global lto_init_set_LTO_OPTIONS
+    if [info exists lto_init_set_LTO_OPTIONS] {
+       global LTO_OPTIONS
+       unset LTO_OPTIONS
+       unset lto_init_set_LTO_OPTIONS
+    }
 }
 
 # Subsets of tests can be selectively disabled by members of this list:
index 61295604b5bfa8c8241558c8cc77e596a27be9b6..394418e9a02fa1ca561bf88fd0096c1dd82f06c8 100644 (file)
@@ -28,6 +28,27 @@ proc torture-init { args } {
     if [info exists torture_with_loops] {
        error "torture-init: torture_with_loops is not empty as expected"
     }
+
+    global LTO_TORTURE_OPTIONS
+    if [info exists LTO_TORTURE_OPTIONS] {
+       error "torture-init: LTO_TORTURE_OPTIONS is not empty as expected"
+    }
+    set LTO_TORTURE_OPTIONS ""
+    if [check_effective_target_lto] {
+       # When having plugin test both slim and fat LTO and plugin/nonplugin
+       # path.
+       if [check_linker_plugin_available] {
+           set LTO_TORTURE_OPTIONS [list \
+             { -O2 -flto -fno-use-linker-plugin -flto-partition=none } \
+             { -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects }
+           ]
+       } else {
+           set LTO_TORTURE_OPTIONS [list \
+             { -O2 -flto -flto-partition=none } \
+             { -O2 -flto }
+           ]
+       }
+    }
 }
 
 # Return 1 if torture options have already been set, 0 otherwise.
@@ -100,6 +121,13 @@ proc torture-finish { args } {
     } else {
        error "torture-finish: torture_with_loops is not defined"
     }
+
+    global LTO_TORTURE_OPTIONS
+    if [info exists LTO_TORTURE_OPTIONS] {
+       unset LTO_TORTURE_OPTIONS
+    } else {
+       error "torture-finish: LTO_TORTURE_OPTIONS is not defined"
+    }
 }
 
 # Useful for debugging .exp files.