From e52e8b309698adc85c55945d2881b80ea767dbd0 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 21 May 2026 12:33:46 +0000 Subject: [PATCH] Use -O2 instead of -O3 when linking libGD.js/wasm The final link step is dominated by Emscripten's wasm-opt pass on the ~3.4 MB output. Lowering it from -O3 to -O2 makes the link step ~3 min -> ~15 s on a 4-vCPU machine (similar speedup expected on CircleCI's medium+ runner), while the gzipped wasm only grows by ~0.2% and the GDevelop.js test suite runtime is unchanged. --- GDevelop.js/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GDevelop.js/CMakeLists.txt b/GDevelop.js/CMakeLists.txt index fb0841083021..5ff4f5fb596b 100644 --- a/GDevelop.js/CMakeLists.txt +++ b/GDevelop.js/CMakeLists.txt @@ -117,7 +117,11 @@ elseif("${GDEVELOPJS_BUILD_VARIANT}" STREQUAL "debug-sanitizers") target_link_libraries(GD "-fsanitize=return") # Uncomment to auto-detect occurences of undefined behavior - also enable compiling above! else() # Production: link time optimizations and full optimization. - target_link_libraries(GD "-O3 -flto") + # Use -O2 (rather than -O3) at link time: this drastically reduces the + # wasm-opt pass time (~3 min -> ~15 s on CI) while only growing the + # gzipped wasm by ~0.2% and leaving runtime performance unchanged on + # the GDevelop.js test suite. + target_link_libraries(GD "-O2 -flto") endif() # Even if we're building an "executable", prefix it by lib as it's used as a library.