Skip to content

Conversation

@bruvzg
Copy link
Member

@bruvzg bruvzg commented Jul 19, 2024

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Code looks good. I'll give it a try.

@bruvzg
Copy link
Member Author

bruvzg commented Jul 19, 2024

Tested only classic build so far, clang LTO is extremely slow. Probably will check .NET builds on Monday.

@bruvzg bruvzg marked this pull request as ready for review July 19, 2024 13:48
@akien-mga
Copy link
Member

Oh right I'm not looking forward to 6 new Clang LTO builds :|

We should evaluate whether Clang LTO is really worth it compared to Clang ThinLTO for each Clang target platform, and switch the ones where the size/performance difference is negligible. ThinLTO can be multithreaded but not full LTO with Clang sadly.

@Calinou
Copy link
Member

Calinou commented Jul 19, 2024

Oh right I'm not looking forward to 6 new Clang LTO builds :|

I think it's reasonable to drop x86_32 Windows builds once we have Windows ARM64 builds. This could also be done for Linux (especially for Linux in fact) to further reduce the build matrix.

That said, ThinLTO should be worth trying as it'll likely perform closer to full LTO than no LTO at all while being easily 3× faster to link.

@bruvzg
Copy link
Member Author

bruvzg commented Jul 19, 2024

Tested .NET builds as well, seem to work fine.

Thin LTO build is fast (and unlike full LTO do not use 30GB of RAM), size difference is about 2MB for templates and 3MB for editor:

Full LTO Thin LTO
Editor 139.2 MB 142.8 MB
Release template 76.5 MB 78.8 MB
Debug template 84.8 MB 86.6 MB

So size difference is not critical, will test performance later.

rm -rf bin

$SCONS platform=windows arch=arm64 $OPTIONS $OPTIONS_MONO $OPTIONS_LLVM target=editor
./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --godot-platform=windows
Copy link
Member Author

@bruvzg bruvzg Jul 19, 2024

Choose a reason for hiding this comment

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

Unrelated to the PR, but do we need to build .NET assemblies for each architecture, it seems to contain only managed code, and scripts aren't even taking arch as argument, so it probably can be done once.

@bruvzg
Copy link
Member Author

bruvzg commented Jul 20, 2024

Tested both full and thin LTO builds with benchmarks, seems like for most of the tests thin LTO is either faster by (2-3%) or the same, with the exception of GDScript Array and String tests (which are 1-2% slower). Results are similar for both release and debug builds.

So I guess it is a reasonable option, at least for ARM64 builds.

@akien-mga
Copy link
Member

I would keep full LTO for now for 4.3 as that's what we've tested most.

But for 4.4 I think we could try using ThinLTO for all LLVM builds (Windows arm64, macOS, Android, Web).

@akien-mga
Copy link
Member

akien-mga commented Jul 22, 2024

Some more changes are needed:

diff --git a/build-release.sh b/build-release.sh
index dba9ccd..b84826d 100755
--- a/build-release.sh
+++ b/build-release.sh
@@ -274,10 +274,8 @@ if [ "${build_classical}" == "1" ]; then
   binname="${godot_basename}_win64.exe"
   wrpname="${godot_basename}_win64_console.exe"
   cp out/windows/x86_64/tools/godot.windows.editor.x86_64.exe ${binname}
-  strip ${binname}
   sign_windows ${binname}
   cp out/windows/x86_64/tools/godot.windows.editor.x86_64.console.exe ${wrpname}
-  strip ${wrpname}
   sign_windows ${wrpname}
   zip -q -9 "${reldir}/${binname}.zip" ${binname} ${wrpname}
   rm ${binname} ${wrpname}
@@ -285,21 +283,17 @@ if [ "${build_classical}" == "1" ]; then
   binname="${godot_basename}_win32.exe"
   wrpname="${godot_basename}_win32_console.exe"
   cp out/windows/x86_32/tools/godot.windows.editor.x86_32.exe ${binname}
-  strip ${binname}
   sign_windows ${binname}
   cp out/windows/x86_32/tools/godot.windows.editor.x86_32.console.exe ${wrpname}
-  strip ${wrpname}
   sign_windows ${wrpname}
   zip -q -9 "${reldir}/${binname}.zip" ${binname} ${wrpname}
   rm ${binname} ${wrpname}
 
   binname="${godot_basename}_arm64.exe"
   wrpname="${godot_basename}_arm64_console.exe"
-  cp out/windows/arm64/tools/godot.windows.editor.arm64.exe ${binname}
-  strip ${binname}
+  cp out/windows/arm64/tools/godot.windows.editor.arm64.llvm.exe ${binname}
   sign_windows ${binname}
-  cp out/windows/arm64/tools/godot.windows.editor.arm64.console.exe ${wrpname}
-  strip ${wrpname}
+  cp out/windows/arm64/tools/godot.windows.editor.arm64.llvm.console.exe ${wrpname}
   sign_windows ${wrpname}
   zip -q -9 "${reldir}/${binname}.zip" ${binname} ${wrpname}
   rm ${binname} ${wrpname}
@@ -309,15 +303,14 @@ if [ "${build_classical}" == "1" ]; then
   cp out/windows/x86_64/templates/godot.windows.template_debug.x86_64.exe ${templatesdir}/windows_debug_x86_64.exe
   cp out/windows/x86_32/templates/godot.windows.template_release.x86_32.exe ${templatesdir}/windows_release_x86_32.exe
   cp out/windows/x86_32/templates/godot.windows.template_debug.x86_32.exe ${templatesdir}/windows_debug_x86_32.exe
-  cp out/windows/arm64/templates/godot.windows.template_release.arm64.exe ${templatesdir}/windows_release_arm64.exe
-  cp out/windows/arm64/templates/godot.windows.template_debug.arm64.exe ${templatesdir}/windows_debug_arm64.exe
+  cp out/windows/arm64/templates/godot.windows.template_release.arm64.llvm.exe ${templatesdir}/windows_release_arm64.exe
+  cp out/windows/arm64/templates/godot.windows.template_debug.arm64.llvm.exe ${templatesdir}/windows_debug_arm64.exe
   cp out/windows/x86_64/templates/godot.windows.template_release.x86_64.console.exe ${templatesdir}/windows_release_x86_64_console.exe
   cp out/windows/x86_64/templates/godot.windows.template_debug.x86_64.console.exe ${templatesdir}/windows_debug_x86_64_console.exe
   cp out/windows/x86_32/templates/godot.windows.template_release.x86_32.console.exe ${templatesdir}/windows_release_x86_32_console.exe
   cp out/windows/x86_32/templates/godot.windows.template_debug.x86_32.console.exe ${templatesdir}/windows_debug_x86_32_console.exe
-  cp out/windows/arm64/templates/godot.windows.template_release.arm64.console.exe ${templatesdir}/windows_release_arm64_console.exe
-  cp out/windows/arm64/templates/godot.windows.template_debug.arm64.console.exe ${templatesdir}/windows_debug_arm64_console.exe
-  strip ${templatesdir}/windows*.exe
+  cp out/windows/arm64/templates/godot.windows.template_release.arm64.llvm.console.exe ${templatesdir}/windows_release_arm64_console.exe
+  cp out/windows/arm64/templates/godot.windows.template_debug.arm64.llvm.console.exe ${templatesdir}/windows_debug_arm64_console.exe
 
   ## macOS (Classical) ##
 
@@ -464,11 +457,9 @@ if [ "${build_mono}" == "1" ]; then
   wrpname="${godot_basename}_mono_win64_console"
   mkdir -p ${binname}
   cp out/windows/x86_64/tools-mono/godot.windows.editor.x86_64.mono.exe ${binname}/${binname}.exe
-  strip ${binname}/${binname}.exe
   sign_windows ${binname}/${binname}.exe
   cp -rp out/windows/x86_64/tools-mono/GodotSharp ${binname}/
   cp out/windows/x86_64/tools-mono/godot.windows.editor.x86_64.mono.console.exe ${binname}/${wrpname}.exe
-  strip ${binname}/${wrpname}.exe
   sign_windows ${binname}/${wrpname}.exe
   zip -r -q -9 "${reldir_mono}/${binname}.zip" ${binname}
   rm -rf ${binname}
@@ -477,11 +468,9 @@ if [ "${build_mono}" == "1" ]; then
   wrpname="${godot_basename}_mono_win32_console"
   mkdir -p ${binname}
   cp out/windows/x86_32/tools-mono/godot.windows.editor.x86_32.mono.exe ${binname}/${binname}.exe
-  strip ${binname}/${binname}.exe
   sign_windows ${binname}/${binname}.exe
   cp -rp out/windows/x86_32/tools-mono/GodotSharp ${binname}/
   cp out/windows/x86_32/tools-mono/godot.windows.editor.x86_32.mono.console.exe ${binname}/${wrpname}.exe
-  strip ${binname}/${wrpname}.exe
   sign_windows ${binname}/${wrpname}.exe
   zip -r -q -9 "${reldir_mono}/${binname}.zip" ${binname}
   rm -rf ${binname}
@@ -489,12 +478,10 @@ if [ "${build_mono}" == "1" ]; then
   binname="${godot_basename}_mono_arm64"
   wrpname="${godot_basename}_mono_arm64_console"
   mkdir -p ${binname}
-  cp out/windows/arm64/tools-mono/godot.windows.editor.arm64.mono.exe ${binname}/${binname}.exe
-  strip ${binname}/${binname}.exe
+  cp out/windows/arm64/tools-mono/godot.windows.editor.arm64.llvm.mono.exe ${binname}/${binname}.exe
   sign_windows ${binname}/${binname}.exe
   cp -rp out/windows/arm64/tools-mono/GodotSharp ${binname}/
-  cp out/windows/arm64/tools-mono/godot.windows.editor.arm64.mono.console.exe ${binname}/${wrpname}.exe
-  strip ${binname}/${wrpname}.exe
+  cp out/windows/arm64/tools-mono/godot.windows.editor.arm64.llvm.mono.console.exe ${binname}/${wrpname}.exe
   sign_windows ${binname}/${wrpname}.exe
   zip -r -q -9 "${reldir_mono}/${binname}.zip" ${binname}
   rm -rf ${binname}
@@ -504,15 +491,14 @@ if [ "${build_mono}" == "1" ]; then
   cp out/windows/x86_64/templates-mono/godot.windows.template_release.x86_64.mono.exe ${templatesdir_mono}/windows_release_x86_64.exe
   cp out/windows/x86_32/templates-mono/godot.windows.template_debug.x86_32.mono.exe ${templatesdir_mono}/windows_debug_x86_32.exe
   cp out/windows/x86_32/templates-mono/godot.windows.template_release.x86_32.mono.exe ${templatesdir_mono}/windows_release_x86_32.exe
-  cp out/windows/arm64/templates-mono/godot.windows.template_debug.arm64.mono.exe ${templatesdir_mono}/windows_debug_arm64.exe
-  cp out/windows/arm64/templates-mono/godot.windows.template_release.arm64.mono.exe ${templatesdir_mono}/windows_release_arm64.exe
+  cp out/windows/arm64/templates-mono/godot.windows.template_debug.arm64.llvm.mono.exe ${templatesdir_mono}/windows_debug_arm64.exe
+  cp out/windows/arm64/templates-mono/godot.windows.template_release.arm64.llvm.mono.exe ${templatesdir_mono}/windows_release_arm64.exe
   cp out/windows/x86_64/templates-mono/godot.windows.template_debug.x86_64.mono.console.exe ${templatesdir_mono}/windows_debug_x86_64_console.exe
   cp out/windows/x86_64/templates-mono/godot.windows.template_release.x86_64.mono.console.exe ${templatesdir_mono}/windows_release_x86_64_console.exe
   cp out/windows/x86_32/templates-mono/godot.windows.template_debug.x86_32.mono.console.exe ${templatesdir_mono}/windows_debug_x86_32_console.exe
   cp out/windows/x86_32/templates-mono/godot.windows.template_release.x86_32.mono.console.exe ${templatesdir_mono}/windows_release_x86_32_console.exe
-  cp out/windows/arm64/templates-mono/godot.windows.template_debug.arm64.mono.console.exe ${templatesdir_mono}/windows_debug_arm64_console.exe
-  cp out/windows/arm64/templates-mono/godot.windows.template_release.arm64.mono.console.exe ${templatesdir_mono}/windows_release_arm64_console.exe
-  strip ${templatesdir_mono}/windows*.exe
+  cp out/windows/arm64/templates-mono/godot.windows.template_debug.arm64.llvm.mono.console.exe ${templatesdir_mono}/windows_debug_arm64_console.exe
+  cp out/windows/arm64/templates-mono/godot.windows.template_release.arm64.llvm.mono.console.exe ${templatesdir_mono}/windows_release_arm64_console.exe
 
   ## macOS (Mono) ##
 

@bruvzg
Copy link
Member Author

bruvzg commented Jul 22, 2024

strip doesn't work on arm64 binaries. But it's actually not needed anymore, we strip at build time with -s. I'll make a separate PR to remove it from existing builds, to keep the history clear.

I guess it depends on strip version used (MinGW/LLVM toolchain have its own version that should work), but it seems like it indeed is redundant.

@akien-mga akien-mga merged commit 0c96c1e into godotengine:main Jul 22, 2024
@akien-mga
Copy link
Member

Thanks!

@bruvzg bruvzg deleted the arm64_win branch July 22, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants