fix(windows): strip ClangCL ThinLTO flags and gate http3 on OpenSSL >= 3.5#34
Merged
Conversation
…= 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.gypiNode 26's official build switched to ClangCL + ThinLTO. This causes
common.gypito inject-flto=thin(compiler) andopt:lldltojobs=N(linker) into every Release target, including third-party native addons. MSVC'scl.exesilently ignores-flto=thin(D9002 warning), butlink.exefatally rejectsopt:lldltojobs=Nwith:This was already affecting Node 24/25 builds on the
v5.0.14-0run because the samecommon.gypiinjection had landed in their node-gyp version.Fix: Add a
target_defaultsblock inbinding.gypthat uses GYP'sAdditionalOptions/regex-exclude mechanism to strip bothfltoandlldltojobsfromVCCLCompilerTool,VCLibrarianTool, andVCLinkerToolon Release configuration. This block is entirely inert on Linux and macOS GYP generators.2.
http3/ngtcp2 vcpkg compile failure on Windows with OpenSSL < 3.5vcpkg.template.jsonunconditionally includes thehttp3feature, which pulls in ngtcp2. ngtcp2's OpenSSL crypto backend requiresSSL_set_quic_tls_cbs, which is only available in OpenSSL >= 3.5 built withenable-quic. Node 22 and 24 bundle OpenSSL 3.x < 3.5, so ngtcp2 fails to compile via vcpkg.Fix: In
vcpkg-setup.js, remove thehttp3feature from the generatedvcpkg.jsonwhen the resolved OpenSSL version is < 3.5.0, with a clear log message explaining why.Changes
binding.gyptarget_defaultswithAdditionalOptions/exclude rules forflto/lldltojobson all three MSVC tool sectionsscripts/vcpkg-setup.jshttp3feature onopensslVersion >= 3.5.0; refactor to parse vcpkg.json once for both the http3 gate and the gssapi additionVerification
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 thedeveloptarget.