feat(ci): upgrade python and remove LLVM LTO flags from MSVC build to fix Node 26 Windows CI by styfle · Pull Request #1330 · vercel/ncc (original) (raw)
Root Cause
Node.js 26 on Windows is compiled using Clang with thin LTO enabled (enable_thin_lto=true, lto_jobs=2). When node-gyp rebuild runs without --nodedir, it generates build/config.gypi from the running Node.js binary's process.config. This causes Node.js's common.gypi to inject LLVM/Clang-specific flags into the MSVC build:
-flto=thin→ compiler/linker warning (ignored by MSVC)/opt:lldltojobs=2→ fatal linker errorLNK1117(MSVC does not understand LLVM LTO job flags)
Fix
Modified test/binary/binding.gyp to strip the incompatible LLVM LTO flags when building on Windows with MSVC:
- Added a
"lto_jobs%": ""default variable as a safe fallback for Node versions that do not define this variable - Added a Windows-specific
conditionsblock using GYP'sAdditionalOptions!list-removal operator to remove-flto=thin,-flto=full, and/opt:lldltojobs=<(lto_jobs)from bothVCCLCompilerToolandVCLinkerTooloptions
The fix is a no-op on Node 22/24 (LTO not enabled, no flags to remove) and does not affect Linux or macOS builds.