Skip to content
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

Windows: Configure MinGW LTO with -fno-use-linker-plugin -fwhole-program #103077

Merged

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented Feb 20, 2025

This was actually found by @hpvb in #102867 (comment).

Paging them to better description what this does when they have some time, as it's not super clear to me how those two options interact with -flto. But tests have shown that it solves the two linked issues.

I'll make a test build from this PR to validate this and get others to test.

Copy link
Member

@hpvb hpvb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should set the flags we tested. LGTM

@akien-mga akien-mga marked this pull request as draft February 20, 2025 16:44
@akien-mga
Copy link
Member Author

I put the flags on the wrong branch, they apply for LLVM and not GCC :D
Will fix.

akien-mga and others added 2 commits February 20, 2025 17:47
…gram`

- Works around and closes godotengine#102867.
- Works around and closes godotengine#102982.

Co-authored-by: Hein-Pieter van Braam-Stewart <[email protected]>
This reverts commit e12a424.
This is no longer needed after 26fd345.
@akien-mga akien-mga force-pushed the windows-mingw-lto-whole-program branch from f74c894 to 702eb39 Compare February 20, 2025 16:47
@akien-mga
Copy link
Member Author

@akien-mga akien-mga marked this pull request as ready for review February 20, 2025 17:42
@BlueCube3310
Copy link
Contributor

Tested on Windows 10, can confirm it fixes the issue

@akien-mga
Copy link
Member Author

Tested too on Linux with Wine (both win32 and win64 builds) and the MRP from #102982 works.

Let's merge, test in 4.4.rc1 and see if there are any other downsides to these new flags.

@akien-mga akien-mga merged commit f76b76f into godotengine:master Feb 20, 2025
20 checks passed
@akien-mga
Copy link
Member Author

Thanks @hpvb for looking into this!

@wildlachs
Copy link

I think this broke my build pipeline.

This is how I build my windows production build:

# Windows production build
scons platform=windows \
    target=template_release \
    arch=x86_64 \
    use_llvm=yes \
    linker=mold \
    precision=double \
    production=yes \
    scu_build=yes \
    scu_limit=1024 \
    optimize=speed

Using MinGW64 running on Fedora 41:

$ x86_64-w64-mingw32-gcc --version
x86_64-w64-mingw32-gcc (GCC) 14.2.1 20240801 (Fedora MinGW 14.2.1-3.fc41)
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Output of build process:

scons: Reading SConscript files ...
Auto-detected 12 CPU cores available for build parallelism. Using 11 cores by default. You can override it with the `-j` or `num_jobs` arguments.
SCU: Generating build files... (max includes per SCU: 1024)
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "template_release".
Using LTO: full
Checking for C header file mntent.h... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
[ 75%] Compiling scene/gui/scu/scu_scene_gui.gen.cpp ...
[ 77%] Compiling scene/resources/scu/scu_scene_resources.gen.cpp ...
[ 94%] /usr/lib/gcc/x86_64-w64-mingw32/14.2.1/../../../../x86_64-w64-mingw32/bin/as: scene/gui/scu/scu_scene_gui.gen.windows.template_release.double.x86_64.o: too many sections (38865)
/tmp/ccyyzFXX.s: Assembler messages:
/tmp/ccyyzFXX.s: Fatal error: can't write 1 byte to section .text of scene/gui/scu/scu_scene_gui.gen.windows.template_release.double.x86_64.o: 'file too big'
/usr/lib/gcc/x86_64-w64-mingw32/14.2.1/../../../../x86_64-w64-mingw32/bin/as: scene/gui/scu/scu_scene_gui.gen.windows.template_release.double.x86_64.o: too many sections (38865)
/tmp/ccyyzFXX.s: Fatal error: scene/gui/scu/scu_scene_gui.gen.windows.template_release.double.x86_64.o: file too big
scons: *** [scene/gui/scu/scu_scene_gui.gen.windows.template_release.double.x86_64.o] Error 1
/usr/lib/gcc/x86_64-w64-mingw32/14.2.1/../../../../x86_64-w64-mingw32/bin/as: scene/resources/scu/scu_scene_resources.gen.windows.template_release.double.x86_64.o: too many sections (56069)
/tmp/ccwG5nE5.s: Assembler messages:
/tmp/ccwG5nE5.s: Fatal error: can't write 7 bytes to section .text of scene/resources/scu/scu_scene_resources.gen.windows.template_release.double.x86_64.o: 'file too big'
/usr/lib/gcc/x86_64-w64-mingw32/14.2.1/../../../../x86_64-w64-mingw32/bin/as: scene/resources/scu/scu_scene_resources.gen.windows.template_release.double.x86_64.o: too many sections (56069)
/tmp/ccwG5nE5.s: Fatal error: scene/resources/scu/scu_scene_resources.gen.windows.template_release.double.x86_64.o: file too big
scons: *** [scene/resources/scu/scu_scene_resources.gen.windows.template_release.double.x86_64.o] Error 1
scons: building terminated because of errors.
INFO: Time elapsed: 00:01:56.52

I am using an scu build with maximum limit because I hope the compiler is able to perform the maximal level of optimization this way. With beta4 it worked, but now it's throwing "file too big" errors.

When I build with the same settings, but without scu enabled, everything builds fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants