Skip to content

fix(windows): strip ClangCL ThinLTO flags and gate http3 on OpenSSL >= 3.5#34

Merged
aborovsky merged 3 commits into
developfrom
fix/windows-lto-http3-build
Jun 26, 2026
Merged

fix(windows): strip ClangCL ThinLTO flags and gate http3 on OpenSSL >= 3.5#34
aborovsky merged 3 commits into
developfrom
fix/windows-lto-http3-build

Conversation

@aborovsky

Copy link
Copy Markdown
Collaborator

Root cause

Two independent bugs cause all Windows CI jobs (windows-2025, Node 22/24/25 + Electron) to fail at the "Build and Package Binary (Windows)" step.

1. LNK1117 — ClangCL ThinLTO linker flags from common.gypi

Node 26's official build switched to ClangCL + ThinLTO. This causes common.gypi to inject -flto=thin (compiler) and opt:lldltojobs=N (linker) into every Release target, including third-party native addons. MSVC's cl.exe silently ignores -flto=thin (D9002 warning), but link.exe fatally rejects opt:lldltojobs=N with:

LNK1117: syntax error in option 'opt:lldltojobs=N'

This was already affecting Node 24/25 builds on the v5.0.14-0 run because the same common.gypi injection had landed in their node-gyp version.

Fix: Add a target_defaults block in binding.gyp that uses GYP's AdditionalOptions/ regex-exclude mechanism to strip both flto and lldltojobs from VCCLCompilerTool, VCLibrarianTool, and VCLinkerTool on Release configuration. This block is entirely inert on Linux and macOS GYP generators.

2. http3/ngtcp2 vcpkg compile failure on Windows with OpenSSL < 3.5

vcpkg.template.json unconditionally includes the http3 feature, which pulls in ngtcp2. ngtcp2's OpenSSL crypto backend requires SSL_set_quic_tls_cbs, which is only available in OpenSSL >= 3.5 built with enable-quic. Node 22 and 24 bundle OpenSSL 3.x < 3.5, so ngtcp2 fails to compile via vcpkg.

Fix: In vcpkg-setup.js, remove the http3 feature from the generated vcpkg.json when the resolved OpenSSL version is < 3.5.0, with a clear log message explaining why.

Changes

File Change
binding.gyp Add target_defaults with AdditionalOptions/ exclude rules for flto/lldltojobs on all three MSVC tool sections
scripts/vcpkg-setup.js Gate http3 feature on opensslVersion >= 3.5.0; refactor to parse vcpkg.json once for both the http3 gate and the gssapi addition

Verification

The fixes are derived from the working implementation in feat/node-23-26-coverage (PR #27). This PR extracts only the Windows-fixing subset, keeping scope focused for the develop target.

…= 3.5

Two independent issues cause all Windows CI jobs to fail:

1. LNK1117 — ClangCL ThinLTO linker flags injected by common.gypi (Node 26+)
   Node's official build switched to ClangCL + ThinLTO, which causes
   common.gypi to inject -flto=thin (compiler) and opt:lldltojobs=N (linker)
   into every Release target. MSVC's cl.exe silently accepts -flto=thin (D9002
   warning), but link.exe fatally rejects opt:lldltojobs=N with LNK1117
   (syntax error in option). Fix: add a target_defaults block in binding.gyp
   that uses GYP's AdditionalOptions/ regex-exclude mechanism to strip both
   flags from VCCLCompilerTool, VCLibrarianTool, and VCLinkerTool on Release.
   This block is entirely inert on Linux and macOS GYP generators.

2. http3/ngtcp2 vcpkg compile failure on Windows with OpenSSL < 3.5
   vcpkg.template.json unconditionally includes the http3 feature, which pulls
   in ngtcp2. ngtcp2's OpenSSL backend requires SSL_set_quic_tls_cbs, only
   available in OpenSSL >= 3.5 built with enable-quic. Node 22/24 bundle
   OpenSSL 3.x < 3.5, so the ngtcp2 build fails. Fix: in vcpkg-setup.js,
   remove the http3 feature from the generated vcpkg.json when the resolved
   OpenSSL version is < 3.5.0.
The windows-2025 runner image was updated and now ships with
Visual Studio 2026 (version major 18) instead of VS 2022 (17).

node-gyp 11.4.2 does not recognise version major 18, so VS detection
fails with 'unknown version "undefined"', which causes the fallback
source compile to abort and pnpm install to exit with code 1.

node-gyp 13.0.0 adds version-major 18 → year 2026 recognition and
adds 2026 to every findVisualStudio2019OrNewer* supported-years list.

Also remove the hard-coded msvs_version=2022 from build.ps1. Pinning
to a specific year makes CI fragile whenever the runner's VS changes;
letting node-gyp auto-detect is more robust.
@aborovsky
aborovsky merged commit ebd6f36 into develop Jun 26, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant