From 4cd9b3747117c0feedd72dd84c8b8402de581658 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 26 Apr 2025 16:40:46 +0100 Subject: [PATCH] Remove nodejs cargo profile The cargo profile in the nodejs folder gets ignored because the crate is in a workspace, but it got me thinking about LTO. Enabling fat LTO more than doubles the build time, and although it shrinks the binary size, if there is a performance impact it's not very obvious (based on sorting in LOOT with the built DLL). On the other hand, thin LTO only only adds a second to the cargo build time and reduced binary size by ~ 1.4 MB, and adding /LTCG on top reduces it by another ~ 1.6 MB. MSVC doesn't output how long linking takes, but it seemed to only add a second or two. --- Cargo.toml | 1 + cxx/CMakeLists.txt | 4 ++-- nodejs/Cargo.toml | 4 ---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5b2cf756..9f4eccd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ loot-condition-interpreter = "5.3.1" [profile.release] debug = "limited" +lto = "thin" [profile.rel-with-deb-info] inherits = "release" diff --git a/cxx/CMakeLists.txt b/cxx/CMakeLists.txt index 2a55eb68..f3653d58 100644 --- a/cxx/CMakeLists.txt +++ b/cxx/CMakeLists.txt @@ -154,7 +154,6 @@ target_include_directories(loot SYSTEM PRIVATE if(CMAKE_SYSTEM_NAME STREQUAL "Windows") target_compile_definitions(loot PRIVATE UNICODE _UNICODE LOOT_EXPORT) - target_compile_options(loot PRIVATE "/Zc:__cplusplus") set(LOOT_LIBS ntdll ws2_32 bcrypt) @@ -167,7 +166,8 @@ endif() if(MSVC) # Turn off permissive mode to be more standards-compliant and avoid compiler errors. - target_compile_options(loot PRIVATE "/permissive-" "/W4") + target_compile_options(loot PRIVATE "/permissive-" "/W4" "/Zc:__cplusplus" "/GL") + target_link_options(loot PRIVATE "/LTCG") endif() ############################## diff --git a/nodejs/Cargo.toml b/nodejs/Cargo.toml index 07e0ba7b..904239a1 100644 --- a/nodejs/Cargo.toml +++ b/nodejs/Cargo.toml @@ -16,7 +16,3 @@ napi-derive = "2.12.2" [build-dependencies] napi-build = "2.0.1" - -[profile.release] -lto = true -strip = "symbols"