Bootstrapping GCC (c, c++) on ia64 w/o support for LTO ([1]) showed that
the testsuite (specifically c-c++-common/guality) executes tests with
`-flto` although there was no support for LTO configured:

[1]: https://gcc.gnu.org/pipermail/gcc-testresults/2025-December/865397.html

Here for g++, but identical for gcc, too:
```
[...]
FAIL: c-c++-common/guality/Og-dce-1.c  -Og  line 13 *ptr == 1
FAIL: c-c++-common/guality/Og-dce-1.c  -Og -flto (test for excess errors)
UNRESOLVED: c-c++-common/guality/Og-dce-1.c  -Og -flto compilation failed to 
produce executable
FAIL: c-c++-common/guality/Og-dce-2.c  -Og -flto (test for excess errors)
UNRESOLVED: c-c++-common/guality/Og-dce-2.c  -Og -flto compilation failed to 
produce executable
FAIL: c-c++-common/guality/Og-dce-3.c  -Og  line 17 x == 1
FAIL: c-c++-common/guality/Og-dce-3.c  -Og  line 18 x == 101
FAIL: c-c++-common/guality/Og-dce-3.c  -Og  line 20 x == 102
FAIL: c-c++-common/guality/Og-dce-3.c  -Og -flto (test for excess errors)
UNRESOLVED: c-c++-common/guality/Og-dce-3.c  -Og -flto compilation failed to 
produce executable
FAIL: c-c++-common/guality/Og-global-dse-1.c  -Og  line 13 gs1.i == 1
FAIL: c-c++-common/guality/Og-global-dse-1.c  -Og  line 14 gs1.j == 2
FAIL: c-c++-common/guality/Og-global-dse-1.c  -Og -flto (test for excess errors)
UNRESOLVED: c-c++-common/guality/Og-global-dse-1.c  -Og -flto compilation 
failed to produce executable
FAIL: c-c++-common/guality/Og-static-wo-1.c  -Og  line 13 x == 1
FAIL: c-c++-common/guality/Og-static-wo-1.c  -Og -flto (test for excess errors)
UNRESOLVED: c-c++-common/guality/Og-static-wo-1.c  -Og -flto compilation failed 
to produce executable
[...]

                === g++ Summary ===

# of expected passes            245668
# of unexpected failures        282
# of unexpected successes       3
# of expected failures          2188
# of unresolved testcases       5
# of unsupported tests          2221
```

This is because [...]/guality.exp adds test permutations w/`-flto`
unconditionally. Fix that by checking for LTO support and drop
permutations w/`-flto` if unsupported.

Tested successfully with `check-gcc RUNTESTFLAGS="dg.exp"`:

Again for g++, but same for gcc:
```
[...]
FAIL: c-c++-common/guality/Og-dce-1.c  -Og  line 13 *ptr == 1
FAIL: c-c++-common/guality/Og-dce-3.c  -Og  line 17 x == 1
FAIL: c-c++-common/guality/Og-dce-3.c  -Og  line 18 x == 101
FAIL: c-c++-common/guality/Og-dce-3.c  -Og  line 20 x == 102
FAIL: c-c++-common/guality/Og-global-dse-1.c  -Og  line 13 gs1.i == 1
FAIL: c-c++-common/guality/Og-global-dse-1.c  -Og  line 14 gs1.j == 2
FAIL: c-c++-common/guality/Og-static-wo-1.c  -Og  line 13 x == 1
[...]
                === g++ Summary ===

# of expected passes            245668
# of unexpected failures        278
# of unexpected successes       3
# of expected failures          2188
# of unsupported tests          2208
```

If there's a way to just execute the above c-c++-common/guality
tests, please let me know, because I didn't find the correct
RUNTESTFLAGS to achieve that.

Suggested by Sam.

****

Posting as RFC, as I'm unsure if this is the right approach to "fix"
the testsuite in regard to LTO support.

Cheers,
Frank
From dffab8da8f7e1fc3fec77bd47f1afea93e074fde Mon Sep 17 00:00:00 2001
From: Frank Scheiner <[email protected]>
Date: Mon, 12 Jan 2026 10:48:58 +0100
Subject: [PATCH] testsuite: only test with LTO if LTO support is actually
 configured

Bootstrapping GCC (c, c++) on ia64 w/o support for LTO ([1]) showed that
the testsuite (specifically c-c++-common/guality) executes tests with
`-flto` although there was no support for LTO configured.

[1]: https://gcc.gnu.org/pipermail/gcc-testresults/2025-December/865397.html

This is because [...]/guality.exp adds test permutations w/`-flto`
unconditionally. Fix that by checking for LTO support and drop
permutations w/`-flto` if unsupported.

gcc/testsuite/ChangeLog:
        * gcc.dg/guality/guality.exp: Only test with LTO if supported.
        * g++.dg/guality/guality.exp: Likewise.

Signed-off-by: Frank Scheiner <[email protected]>
---
 gcc/testsuite/g++.dg/guality/guality.exp | 9 ++++++++-
 gcc/testsuite/gcc.dg/guality/guality.exp | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/guality/guality.exp b/gcc/testsuite/g++.dg/guality/guality.exp
index 6de5e8091a..25d22422e6 100644
--- a/gcc/testsuite/g++.dg/guality/guality.exp
+++ b/gcc/testsuite/g++.dg/guality/guality.exp
@@ -86,10 +86,17 @@ if {[check_guality "
 
     gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C]] "" ""
     gcc-dg-runtest $general "" ""
+
+    if [check_effective_target_lto] {
+        set lto_option_list [list "-Og -flto"]
+    } else {
+        set lto_option_list ""  
+    }
+
     set-torture-options \
 	[list "-O0" "-Og"] \
 	[list {}] \
-	[list "-Og -flto"]
+	$lto_option_list
     gcc-dg-runtest $Og "" ""
 }
 
diff --git a/gcc/testsuite/gcc.dg/guality/guality.exp b/gcc/testsuite/gcc.dg/guality/guality.exp
index 0dc8f10762..f7eca2a811 100644
--- a/gcc/testsuite/gcc.dg/guality/guality.exp
+++ b/gcc/testsuite/gcc.dg/guality/guality.exp
@@ -101,10 +101,17 @@ if {[check_guality "
 
     gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] "" ""
     gcc-dg-runtest $general "" "-Wc++-compat"
+
+    if [check_effective_target_lto] {
+        set lto_option_list [list "-Og -flto"]
+    } else {
+        set lto_option_list ""  
+    }
+
     set-torture-options \
 	[list "-O0" "-Og"] \
 	[list {}] \
-	[list "-Og -flto"]
+	$lto_option_list
     gcc-dg-runtest $Og "" "-Wc++-compat"
 }
 
-- 
2.25.1

Reply via email to