-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MinGW GCC LTO internal compiler error when linking: cannot read 'LTO_section_decls' #102867
Comments
So I actually tested reproducing the issue in a If that's the case, we could just update to Fedora 42 already for official builds, or backport binutils 2.43.1. |
macOS MinGW build I was able to reproduce it with seems to be using binutils 2.43.1. Sources for the MinGW package are:
|
Yeah I tested too in a So there might be another component in Fedora 42 that's different, or it's just a coincidence. |
I've been able to reproduce this, I'm doing some work with gdb on the wrapper to see if I can work out what's going on. |
I have not been able to figure out what the problem is exactly, but I have been able to build Godot successfully with LTO with the following ccflags and linkflags: At least for now I recommend using this while I try and figure out with the gcc folk what is up. |
Retested it with current |
@bruvzg it is not likely timing sensitive. The problem reproduces with or without using multiple threads. The problem is almost certainly in the "Whole Program Analysis" (WPA) phase of LTO. This is the phase that will partition the LTO work into smaller objects to be processed in series or in parallel. This phase seems to partition the work wrong, which then results in the 115th partition to not be linkable. The issue is that almost any change to the build will cause the problem to go away. For instance just turning LTO off for literally any of the .a or .o files, just one, causes the link to succeed. Because of this the problem is turning out to be very hard to debug. But I'm afraid that it is not a race condition. |
…gram` - Works around and closes godotengine#102867. - Works around and closes godotengine#102982. Co-authored-by: Hein-Pieter van Braam-Stewart <[email protected]>
…gram` - Works around and closes godotengine#102867. - Works around and closes godotengine#102982. Co-authored-by: Hein-Pieter van Braam-Stewart <[email protected]>
Tested versions
master
(b607110) with Workaround mingw-gcc LTO ICE by re-adding some dead code... #102506 revertedSystem information
Fedora 41, mingw64-gcc-14.2.1-3.fc41, mingw64-headers-12.0.0-3.fc41, mingw64-binutils-2.42-2.fc41
Issue description
This is the bug report I promised in #102506, describing the actual bug that #102506 just hacks around, but that PR should be reverted and the bug fixed properly. This is very likely to be a GCC or binutils bug, and not a Godot bug.
Reproducible this bug requires (for now) to revert #102506 locally, as it seems like reintroducing this unnecessary code prevents the LTO internal compiler error. It's all fairly brittle though and I'm not confident it won't come back as we add/change other code, hence why this is a release blocker.
When compiling current
master
(b607110) with #102506 reverted and the following command, using MinGW-GCC:(mono module and LTO are important)
The linking steps fails with:
Or this:
I debugged a bit with @bruvzg, who could also reproduce this with mingw-gcc on macOS with GCC 14.2.0. He tried with
-freport-bug
as advised by the error but that seems to prevent the bug.@Repiteo noted that the second error is similar to the one in #92585 (note:
x86_32
there, while here it's onx86_64
), which we just worked around at the time by updating the base Fedora version to get newer mingw/gcc/binutils.But here we're using the latest version provided on Fedora 41. mingw-headers and mingw-gcc on Fedora 42 aren't newer, but mingw-binutils is at 2.43.1, might be worth testing against.
Since the error popped up between 4.4.beta2 and 4.4.beta3, I bisected it and landed on #102179. There's evidently nothing egregious in that patch that should trigger a LTO crash. Through trial and error, I manage to find a workaround in #102506 by doing a minimal partial revert of #102179. Reintroducing some of that code, even in a path that will never be executed (but could be, as it's checked by an undocumented project setting), seems to prevent the crash.
We also noticed that the presence of LTO objects from a previous build can also be a cause for the issue. But with a
git clean -fxd
this issue is still reproducible when reverting #102179.Obviously, the problem is deeper so we need to dig. That's where I page @hpvb as the resident expert in debugging GCC bugs :D
Steps to reproduce
Set up latest mingw with GCC 14.2.
Minimal reproduction project (MRP)
n/a
The text was updated successfully, but these errors were encountered: