Bug 2356219

Summary: LTO-related i686 build failures on gcc 15
Product: [Fedora] Fedora Reporter: Panu Matilainen <pmatilai>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: dmalcolm, fweimer, jakub, jlaw, josmyers, jwakely, mcermak, mpolacek, msebor, nickc, nixuser, sipoyare
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: gcc-15.1.1-1.fc42 Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-04-28 01:32:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Panu Matilainen 2025-03-31 13:51:27 UTC
I've been observing a mysterious build failure on i686 for a while now, just haven't had a chance to investigate enough for a proper report until now.

This only occurs on i686, and the symptom is that the build bails out with this an error message about opening a file without a file name failing:

> lto1: fatal error: open  failed: No such file or directory
> compilation terminated.
> lto-wrapper: fatal error: /usr/bin/gcc returned 1 exit status
> compilation terminated.

I first observed this in copr in January or so, then it recently appeared to have been fixed - there was a period where this build succeeded on rawhide but failed on F42 unless this update was applied:
https://bodhi.fedoraproject.org/updates/FEDORA-2025-6a12d86df4

Here's a successful build from a couple of weeks back: https://koji.fedoraproject.org/koji/buildinfo?buildID=2667874
And here's a failing build from today:
https://koji.fedoraproject.org/koji/taskinfo?taskID=130937076

So with gcc-15.0.1-0.8 this succeeded, with gcc-15.0.1-0.11 it now fails on i686 again. It has to do with LTO: disabling LTO with "%global _lto_cflags %{nil}" the spec makes the build succeed. It appears entirely reproducable here, observed in koji, copr and local mock build.

Reproducible: Always

Steps to Reproduce:
1. mock -r fedora-rawhide-i386 https://kojipkgs.fedoraproject.org//packages/rpm/4.20.1/1.fc43/src/rpm-4.20.1-1.fc43.src.rpm

Actual Results:  
Build fails with "lto1: fatal error: open  failed: No such file or directory"

Expected Results:  
Build succeeds.

Comment 1 Panu Matilainen 2025-03-31 14:06:14 UTC
FWIW, I've applied the following workaround to disable LTO on i686 so we're not blocked by this:
https://src.fedoraproject.org/rpms/rpm/pull-request/65

Comment 2 Jakub Jelinek 2025-04-04 12:06:04 UTC
I can reproduce in f43 mock with just
echo 'void foo (void) {}' > a.c; gcc -O2 -flto=auto -ffat-lto-objects -fhardened -o a.o -c a.c; gcc -O2 -flto=auto -r -o a.lo a.o
lto1: fatal error: open  failed: No such file or directory
...
The -fhardened option seems to be essential, without that it doesn't fail, and the problem is that somehow a.lo.lto.o-args.0 doesn't contain
just the expected a.o, but
""
a.o
and the "" file (literally length zero name) can't be opened.
I can't reproduce it with latest trunk and older binutils though.

Comment 3 Jakub Jelinek 2025-04-04 12:36:20 UTC
Somehow
gcc -O2 -flto=auto -ffat-lto-objects -fhardened -o a.s -S a.c
writes
        .section        .gnu.lto_.opts,"e",@progbits
        .string "'-fno-openmp' '-fno-openacc' '-fPIC' '' '-mtune=generic' '-march=i686' '-O2' '-flto=auto' '-ffat-lto-objects'"
(note the '' in there).

Comment 4 Fedora Update System 2025-04-26 06:17:24 UTC
FEDORA-2025-9bcdcfb5cd (gcc-15.1.1-1.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-9bcdcfb5cd

Comment 5 Fedora Update System 2025-04-27 03:10:52 UTC
FEDORA-2025-9bcdcfb5cd has been pushed to the Fedora 42 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2025-9bcdcfb5cd`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2025-9bcdcfb5cd

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 6 Fedora Update System 2025-04-28 01:32:07 UTC
FEDORA-2025-9bcdcfb5cd (gcc-15.1.1-1.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 7 Panu Matilainen 2025-04-28 08:24:27 UTC
Thanks for the fix! Just rebuilt rpm on rawhide with the workaround dropped, worked fine.