Skip to content

Windows Node 26 enable_thin_lto=true breaks MSVC native addon builds (lldltojobs / -flto=thin) #64674

Description

@steve02081504

Version

  • Node.js v26.5.0 (Windows x64)
  • process.config.variables: clang=1, enable_thin_lto=true, enable_lto=false, llvm_version=19.1.5
  • node-gyp 12.4.0
  • Visual Studio 2026 Insiders / MSVC (cl / link.exe)

What goes wrong

Building a native addon with node-gyp rebuild on this Node binary injects Clang/lld thin-LTO flags into the MSVC project:

  • compiler: -flto=thin (MSVC warns D9002 and ignores)
  • linker: /opt:lldltojobs=2LINK : fatal error LNK1117: 选项“opt:lldltojobs=2”中的语法错误

Reproduced while installing @stoprocent/bluetooth-hci-socket@2.2.6 (dependency of @stoprocent/noble / @stoprocent/bleno). The package binding.gyp does not set these flags; they come from Node’s common.gypi LTO conditions once enable_thin_lto is true in the generated build/config.gypi.

Generated addon config.gypi snippet from the failed build:

"clang": 0,
"enable_lto": "false",
"enable_thin_lto": "true",
"lto_jobs": "2",

So the addon build is treated as non-clang MSVC (clang: 0) while still enabling thin LTO options that only make sense for lld.

Expected

Addon builds on Windows with MSVC should not inherit enable_thin_lto / lld-only linker options from the Node binary’s process config when the toolchain is MSVC.

Either:

  1. Official Windows Node builds that still use MSVC for addons should ship enable_thin_lto=false in the config that node-gyp copies, or
  2. common.gypi should gate -flto=thin / /opt:lldltojobs=… on clang==1 (and/or an lld linker), not only on enable_thin_lto.

Impact (downstream)

  • Deno/npm installs of optional BLE stacks fail hard on Windows under Node 26.5.0.
  • @steve02081504/fount-p2p documents whitelisting only node-datachannel scripts under Deno to avoid pulling these optional builds.

When fixed: re-test npm rebuild @stoprocent/bluetooth-hci-socket (and Deno --allow-scripts for noble/bleno) on Windows Node 26+.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions