Skip to content

Commit a222989

Browse files
committed
fix: disable LTO/ThinLTO in binding.gyp for Windows + Node 26 builds
Node.js 26 was built with clang-cl + lld and ThinLTO enabled. Its installed common.gypi propagates `enable_thin_lto=true` to downstream native addons, and the conditions inside common.gypi append `-flto=thin` to cl.exe's AdditionalOptions and `/opt:lldltojobs=<n>` to link.exe's AdditionalOptions whenever that variable is true. That's fine when the addon is also built with clang-cl, but the overwhelmingly common case for consumers is the regular MSVC toolchain where: - cl.exe warns and ignores `-flto=thin` (D9002) - link.exe warns and ignores `/flto=thin` (LNK4044) - link.exe fails with `LNK1117: syntax error in option 'opt:lldltojobs=2'` because /OPT: only accepts REF/ICF/NOREF/NOICF/LBR/NOLBR Force enable_lto and enable_thin_lto off in binding.gyp's `variables` so the common.gypi conditions evaluate false and the flags are never emitted. Affects every consumer building node-libcurl from source on Windows against Node 26; harmless on Linux/macOS and on older Node versions.
1 parent 7670677 commit a222989

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
### Breaking Change
1010

1111
### Fixed
12+
- Fixed Windows source builds against Node.js 26 failing with `LINK : fatal error LNK1117: syntax error in option 'opt:lldltojobs=2'`. Node 26 was built with clang-cl + lld + ThinLTO and its installed `common.gypi` propagates `enable_thin_lto=true` to downstream addons, which then appends `-flto=thin` to `cl.exe` and `/opt:lldltojobs=<n>` to `link.exe` — both invalid for the regular MSVC toolchain. Force `enable_lto` and `enable_thin_lto` off in `binding.gyp` so those conditions evaluate to false. Affects every consumer building node-libcurl from source on Windows + Node 26.
1213

1314
### Added
1415

binding.gyp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,22 @@
1414
'node_libcurl_debug%': 'false',
1515
'node_libcurl_asan_debug%': 'false',
1616
'node_libcurl_cpp_std%': 'c++20',
17-
'macos_universal_build%': 'false'
17+
'macos_universal_build%': 'false',
18+
# Node.js 26 was built with clang-cl + lld and ThinLTO enabled, and
19+
# its installed common.gypi propagates `enable_thin_lto=true` to
20+
# downstream native addons. When the addon is then built with the
21+
# regular MSVC toolchain (the overwhelmingly common case for
22+
# consumers), the conditions inside common.gypi append `-flto=thin`
23+
# to cl.exe's AdditionalOptions and `/opt:lldltojobs=<n>` to
24+
# link.exe's AdditionalOptions. cl.exe warns and ignores `-flto=thin`,
25+
# but link.exe bails with `LNK1117: syntax error in option` on the
26+
# bogus `/OPT:lldltojobs=` value (link.exe's /OPT: only takes
27+
# REF/ICF/NOREF/NOICF/LBR/NOLBR). Force these off so the conditions
28+
# evaluate false and the flags are never emitted. Affects every
29+
# consumer trying to build node-libcurl from source against Node 26
30+
# on Windows; harmless everywhere else.
31+
'enable_lto': 'false',
32+
'enable_thin_lto': 'false',
1833
},
1934
'targets': [
2035
{

0 commit comments

Comments
 (0)