godot
godot copied to clipboard
Compilation Failing on Windows
Tested versions
master f032af74536b317b23c7fca3bc7318ced5537344
System information
Windows 11 - Intel i5 9600k
Issue description
Compilation randomy fails after a while:
[...}
Compiling scene\gui\box_container.cpp ...
Compiling scene\gui\button.cpp ...
Compiling scene\gui\center_container.cpp ...
Compiling scene\gui\check_box.cpp ...
editor\editor.windows.editor.x86_64.lib : fatal error LNK1248: image size (100764120) exceeds maximum allowable size (FFFFFFFF)
Compiling scene\gui\check_button.cpp ...
Compiling scene\gui\code_edit.cpp ...
Compiling scene\gui\color_mode.cpp ...
Compiling scene\gui\color_picker.cpp ...
Compiling scene\gui\color_rect.cpp ...
Compiling scene\gui\container.cpp ...
scons: *** [editor\editor.windows.editor.x86_64.lib] Error 1248
scons: building terminated because of errors.
[Time elapsed: 00:08:12.40]
Steps to reproduce
clone godot
scons p=windows arch=x86_64 production=yes lto=full target=editor optimize=speed deprecated=no
Minimal reproduction project (MRP)
Bisecting points to #93311 as the culprit, @dsnopek
It is the lto=full causing the Error 1248.
Builds fine with other build options that dont use lto.
Still relevant
Does the problem occur when using clang-cl.exe instead of cl.exe? It can be installed through the visual studio install tool
Sorry for not taking a look at this sooner!
I am able to reproduce locally with scons p=windows lto=full on current master.
However, even if I try completely reverting PR #93311 (so, current master but with those changes reverted, plus removing some other new usages of GDVIRTUAL*_REQUIRED()), I still get the same LNK1248 error.
So, I think my PR was more "the straw that broke the camels back", rather a problematic change, since it seems that other changes after my PR will cause the same issue.
This is a limitation of COFF format. See https://developercommunity.visualstudio.com/t/static-lib-4gb-file-size-limit-lnk1248-image-size/332991
COFF has a 4GB size limit - offset fields in COFF won’t be able to encode anything larger than 4GB due to fields being 4-byte wide.
The only way to workaround this seems to be split the lib file.
Strange though without LTO this lib is only 239MB.
Checking other lib files, LTO bloat file size by a factor of 5-10x. text_server_adv: 10MB -> 46MB webrtc: 2MB -> 23MB
clang-cl doesn't have this issue, use_llvm=yes use_lto=full produce libs even smaller than msvc without lto.
How did you get the FFFFFFFF size? I am on Windows 10 and vs 2019 and it also exceeds the limit, but the limit is only 80000000
No idea; I haven't done any special configuration at all, I just followed the docs with installing the build tools. I also haven't attempted to compile Godot in a while, so I cannot tell you whether it is still relevant.
Today I tried LTO build with MSVC and successfully built it with scons production=yes debug_symbols=yes scu_build=yes lto=full. Either our build system has some updates, or SCU helps reduce the size of the library. Hope this information is helpful.
It still does not work for me.
bin\obj\editor\editor.windows.editor.x86_64.lib : fatal error LNK1248: image size (100962D3A) exceeds maximum allowable size (FFFFFFFF)
scons: *** [bin\obj\editor\editor.windows.editor.x86_64.lib] Error 1248
Steps to reproduce
git clone https://github.com/godotengine/godot --depth 1
cd godot
scons p=windows arch=x86_64 production=yes lto=full target=editor optimize=speed deprecated=no