Skip to content

Commit 1ee545e

Browse files
committed
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.
1 parent 560b3bf commit 1ee545e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎test-app/runtime/CMakeLists.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ if (OPTIMIZED_BUILD OR OPTIMIZED_WITH_INSPECTOR_BUILD)
273273
NativeScript
274274
# The version script keeps V8's public API linkable for plugins while hiding
275275
# the ~60k v8::internal:: symbols the static monolith would otherwise export.
276-
PROPERTIES LINK_FLAGS "-Wl,--allow-multiple-definition -Wl,--gc-sections -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exported-symbols.map ${NS_SYMBOLIC_FUNCTIONS}"
276+
# --icf=all folds identical functions even when their addresses are taken;
277+
# --icf=safe folds nothing here, as V8's objects carry no address-significance
278+
# tables.
279+
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}"
277280
INTERFACE_INCLUDE_DIRECTORIES NATIVES_BLOB_INCLUDE_DIRECTORIES
278281
)
279282
else ()

0 commit comments

Comments
 (0)