Skip to content

Commit 3c7cc0f

Browse files
committed
fix(smol): disable LTCG on Windows to prevent LNK2005 linker errors
Removes --with-ltcg flag for Windows builds due to multiply defined symbol errors between abseil.lib and v8_libbase.lib. Error: abseil.lib(abseil.mutex.obj) : error LNK2005: absl::Mutex::Dtor already defined in v8_libbase.lib(v8_libbase.mutex.obj) Node.js made LTCG optional and disabled by default in PR #21186 specifically to avoid these types of linker conflicts. LTCG remains enabled for Unix/Linux/macOS builds via --enable-lto. Trade-off: Slightly larger binary (~5-10MB) but successful builds. References: - nodejs/node#21186 - nodejs/node@76ef7ac
1 parent 1220a09 commit 3c7cc0f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/node-smol-builder/scripts/build.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,9 +1410,10 @@ async function main() {
14101410
if (IS_PROD_BUILD) {
14111411
configureFlags.push('--v8-lite-mode') // -15-20 MB: Disables TurboFan JIT (JS slower, WASM unaffected)
14121412
// Link Time Optimization (very slow, saves ~5-10MB).
1413-
if (WIN32) {
1414-
configureFlags.push('--with-ltcg') // Windows: Use MSVC's Link Time Code Generation.
1415-
} else {
1413+
// NOTE: LTCG disabled on Windows due to LNK2005 multiply defined symbol errors.
1414+
// See: https://github.com/nodejs/node/pull/21186 (Node.js made LTCG optional)
1415+
// Error: abseil.lib(mutex.obj) conflicts with v8_libbase.lib(mutex.obj)
1416+
if (!WIN32) {
14161417
configureFlags.push('--enable-lto') // Unix/Linux/macOS: Use standard LTO.
14171418
}
14181419
}

0 commit comments

Comments
 (0)