From 1ee545e6c1ef45e67e2e000c8828bbf0231b92d6 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Wed, 11 Nov 2026 18:00:27 -0300 Subject: [PATCH] perf: fold identical code when linking the optimized runtime Link the optimized runtimes with -Wl,--icf=all. libNativeScript.so (arm64) drops from 27.3 MB to 24.5 MB, and the optimized-with-inspector one from 28.3 MB to 25.4 MB. --icf=safe folds nothing, because the V8 objects have no address-significance tables. --- test-app/runtime/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test-app/runtime/CMakeLists.txt b/test-app/runtime/CMakeLists.txt index 58b536d9a..8f64c421d 100644 --- a/test-app/runtime/CMakeLists.txt +++ b/test-app/runtime/CMakeLists.txt @@ -273,7 +273,10 @@ if (OPTIMIZED_BUILD OR OPTIMIZED_WITH_INSPECTOR_BUILD) NativeScript # The version script keeps V8's public API linkable for plugins while hiding # the ~60k v8::internal:: symbols the static monolith would otherwise export. - PROPERTIES LINK_FLAGS "-Wl,--allow-multiple-definition -Wl,--gc-sections -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exported-symbols.map ${NS_SYMBOLIC_FUNCTIONS}" + # --icf=all folds identical functions even when their addresses are taken; + # --icf=safe folds nothing here, as V8's objects carry no address-significance + # tables. + PROPERTIES LINK_FLAGS "-Wl,--allow-multiple-definition -Wl,--gc-sections -Wl,--icf=all -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exported-symbols.map ${NS_SYMBOLIC_FUNCTIONS}" INTERFACE_INCLUDE_DIRECTORIES NATIVES_BLOB_INCLUDE_DIRECTORIES ) else ()