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

Web build/Emscripten needs optimization flags passed to the linker too (LINKFLAGS) #94088

Closed
akien-mga opened this issue Jul 8, 2024 · 0 comments · Fixed by #94109
Closed

Comments

@akien-mga
Copy link
Member

Tested versions

  • Reproducible in 4.3.beta (ec02d40)

System information

Fedora Linux 40 (KDE Plasma) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 7600M XT (RADV NAVI33) - AMD Ryzen 7 7840HS w/ Radeon 780M Graphics (16 Threads)

Issue description

With @Faless we noticed that our optimization flags are passed to the linker currently for Emscripten Web builds, but Emscripten documents that they're needed there too:

https://emscripten.org/docs/tools_reference/emcc.html#emcc-os

Note that there's currently a regression so by default web builds use -O3 instead of -Os (#94087), but in both cases this should be added to the LINKFLAGS.

We should do a review of other emcc flags which need to be passed to both the compiler and the linker (which doesn't seem to be a requirement for GCC/Clang/MSVC, though that assumption might be worth revisiting too).

It does seem to make a significant difference, on a test "minimal" build with:

scons p=web target=template_release build_profile=../blank.build modules_enabled_by_default=no disable_3d=yes disable_advanced_gui=yes module_gdscript_enabled=yes production=yes verbose=yes

(which requires adding env.Append(LINKFLAGS=["-Wl,-u,htonl"]) for LTO to pass)
And with a manual fix for #94087, I get the following metrics:

-Os on CCFLAGS only:

  • 16M for wasm
  • 3.2M for zip

-Os on CCFLAGS and LINKFLAGS:

  • 13M for wasm
  • 3.0M for zip

Steps to reproduce

  • scons p=web target=template_release verbose=yes
  • See no -O[0-9s] option on the em++ linking call

Minimal reproduction project (MRP)

n/a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Release Blocker
Development

Successfully merging a pull request may close this issue.

1 participant