Skip to content

Commit 82ba321

Browse files
committed
Merge branch 'develop' into master for v5.1.2
2 parents 2d8588b + 2c28d96 commit 82ba321

2 files changed

Lines changed: 20 additions & 0 deletions

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 (PR [nodejs/node#63114](https://github.com/nodejs/node/pull/63114), released in v26.3.0), and node-gyp's `create-config-gypi.js` seeds the addon's `config.gypi` from `process.config` of the running Node binary — picking up `enable_thin_lto: true` and `lto_jobs: <n>` from how Node itself was built. Node's installed `common.gypi` then unconditionally appends `-flto=thin` to MSVC `cl.exe`'s `AdditionalOptions` and `/opt:lldltojobs=<n>` to `link.exe`'s. MSVC ignores `-flto=thin` (warning) but rejects `/opt:lldltojobs=<n>` because `/OPT:` only accepts `REF/ICF/NOREF/NOICF/LBR/NOLBR`. Force them off via `npm_config_enable_thin_lto=false` + `npm_config_enable_lto=false` in the Windows build script, which node-gyp forwards as `-Denable_thin_lto=false` gyp defines (top precedence — `binding.gyp` `variables` don't override `config.gypi`'s, they're a separate gyp scope).
1213

1314
### Added
1415

scripts/ci/windows/build.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,30 @@ $env:npm_config_dist_url = $dist_url
162162
$env:npm_config_target = $target
163163
$env:npm_config_node_gyp = $globalNodeGypPath
164164

165+
# Disable LTO/ThinLTO for the addon build. Node 26 ships with
166+
# enable_thin_lto=true baked into process.config because the Node binary
167+
# itself was built with clang-cl + lld + ThinLTO (PR nodejs/node#63114,
168+
# released in v26.3.0). node-gyp's create-config-gypi.js seeds config.gypi
169+
# from process.config when neither --nodedir nor --dist-url is set, so
170+
# common.gypi's `enable_thin_lto=="true"` conditions fire and emit
171+
# `-flto=thin` to cl.exe and `/opt:lldltojobs=<n>` to link.exe. Those are
172+
# clang-cl/lld-link flags; MSVC's cl.exe warns and ignores `-flto=thin`,
173+
# but link.exe rejects `/opt:lldltojobs=<n>` with `LNK1117` because
174+
# /OPT: only accepts REF/ICF/NOREF/NOICF/LBR/NOLBR.
175+
#
176+
# Setting npm_config_enable_thin_lto/enable_lto here makes node-gyp
177+
# forward them as `-Denable_thin_lto=false -Denable_lto=false` gyp
178+
# defines, which take precedence over config.gypi (binding.gyp variables
179+
# don't — they're a separate scope and lose to config.gypi).
180+
$env:npm_config_enable_thin_lto = "false"
181+
$env:npm_config_enable_lto = "false"
182+
165183
Write-Host "Build configuration:" -ForegroundColor Green
166184
Write-Host " npm_config_build_from_source: $env:npm_config_build_from_source" -ForegroundColor Cyan
167185
Write-Host " npm_config_runtime: $env:npm_config_runtime" -ForegroundColor Cyan
168186
Write-Host " npm_config_dist_url: $env:npm_config_dist_url" -ForegroundColor Cyan
169187
Write-Host " npm_config_target: $env:npm_config_target" -ForegroundColor Cyan
188+
Write-Host " npm_config_enable_thin_lto: $env:npm_config_enable_thin_lto" -ForegroundColor Cyan
170189

171190
# Install dependencies and build
172191
Write-Host "Installing dependencies..." -ForegroundColor Blue

0 commit comments

Comments
 (0)