On 08.01.26 12:31, Sam James wrote:
> Frank Scheiner via Gcc <[email protected]> writes:
> [...]
>> Fortunately this was ignored during the testsuite run, so it kept going
>> despite these errors, though of course these resulted in failing tests:
>>
>> ```
>> FAIL: c-c++-common/guality/Og-dce-1.c -Og -flto (test for excess errors)
>> FAIL: c-c++-common/guality/Og-dce-2.c -Og -flto (test for excess errors)
>> [...]
>> FAIL: c-c++-common/guality/Og-dce-3.c -Og -flto (test for excess errors)
>> [...]
>> FAIL: c-c++-common/guality/Og-global-dse-1.c -Og -flto (test for excess
>> errors)
>> [...]
>> FAIL: c-c++-common/guality/Og-static-wo-1.c -Og -flto (test for excess
>> errors)
>> [...]
>> FAIL: c-c++-common/guality/Og-dce-3.c -Og -flto (test for excess errors)
>> [...]
>> FAIL: c-c++-common/guality/Og-global-dse-1.c -Og -flto (test for excess
>> errors)
>> [...]
>> FAIL: c-c++-common/guality/Og-static-wo-1.c -Og -flto (test for excess
>> errors)
>> [...]
>> FAIL: c-c++-common/guality/Og-dce-1.c -Og -flto (test for excess errors)
>> FAIL: c-c++-common/guality/Og-dce-2.c -Og -flto (test for excess errors)
>> [...]
>> ```
>>
>> I wonder, is LTO considered a default? Or should these tests actually
>> not run for a non-LTO config?
>>
>
> The guality ones look like missing dg-require-effective-target lto.
So I looked into this and it seems like it's not so easy, because the
respective tests are also made w/o `-flto`, e.g. for
`c-c++-common/guality/Og-dce-2.c` we have:
```
[...]
PASS: c-c++-common/guality/Og-dce-2.c -O0 execution test
[...]
PASS: c-c++-common/guality/Og-dce-2.c -O0 line 17 ptr->a == 1
[...]
PASS: c-c++-common/guality/Og-dce-2.c -O0 line 18 ptr->a == 5
[...]
PASS: c-c++-common/guality/Og-dce-2.c -Og execution test
[...]
PASS: c-c++-common/guality/Og-dce-2.c -Og line 17 ptr->a == 1
[...]
PASS: c-c++-common/guality/Og-dce-2.c -Og line 18 ptr->a == 5
[...]
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
[...]
UNSUPPORTED: c-c++-common/guality/Og-dce-2.c -Og -flto line 18 ptr->a == 5
```
...so maybe LTO support should not be required per se for these tests?
Unless the rule is to require LTO if at least one test (run) is using
`-flto[...]`.
If not, looking into `gcc/testsuite/gcc.dg/guality/guality.exp` the
following lines could be the right place to skip the LTO tests when LTO
is not supported:
```
78 set guality_lto_torture_options [guality_transform_options
$LTO_TORTURE_OPTIONS]
79 set-torture-options \
80 $guality_dg_torture_options \
81 [list {}] \
82 $guality_lto_torture_options
[...]
104 set-torture-options \
105 [list "-O0" "-Og"] \
106 [list {}] \
107 [list "-Og -flto"]
```
Actually only lines 104 and 107, because as per [1], without support for
LTO, LTO_TORTURE_OPTIONS stays empty.
[1]:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/lib/torture-options.exp;h=51e4a356a618c1b44b54ead9577deaf84a519782;hb=HEAD#l36
So a solution could be to only add that list containing `-flto` (line
107 of `gcc/testsuite/gcc.dg/guality/guality.exp`) if proc
check_effective_target_lto succeeds, like in the above case ([1]).
I now posted a corresponding RFC patch for this, see [2].
[2]: https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705623.html
Cheers,
Frank