Skip to content

build: add synchronization.lib to crates build on Windows - #67590

Open
Renegade334 wants to merge 1 commit into
nodejs:mainfrom
Renegade334:crates-win32-synchronization
Open

Renegade334 wants to merge 1 commit into
nodejs:mainfrom
Renegade334:crates-win32-synchronization

Conversation

@Renegade334

Copy link
Copy Markdown
Member

Fixes: #67589

Signed-off-by: René <rene@renegade334.me.uk>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added dependencies PRs that add, update, or configure Node.js dependencies. needs-ci PRs that need a full CI run. labels Nov 18, 2026
@Renegade334 Renegade334 added windows Issues and PRs related to the Windows platform. build Issues and PRs related to Node.js builds or CI infrastructure. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. labels Nov 18, 2026
@Renegade334

Copy link
Copy Markdown
Member Author

The coverage-windows job in this PR ran on a GHA runner that still had rustc 1.99, whereas the build errors only materialised with 1.100. A manual GHA run with 1.100 was successful.

@Renegade334 Renegade334 added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. crates Issues and PRs related to the Rust crate dependencies. labels Nov 18, 2026
@MikeMcC399

Copy link
Copy Markdown
Member

I ran a local test on this branch on Windows 11 26H2 with Node.js 26.13.1 installed using PowerShell 7
Both Visual Studio 2022 (17.14.45) & 2026 (18.12.1) are installed
Python is 3.15.2 (py install --update)

rustup update
git clean -xfd
rustup override set 1.88
.\vcbuild.bat ccache c:\ccache\

git clean -xfd
rustup override set 1.99.1
.\vcbuild.bat ccache c:\ccache\

git clean -xfd
rustup override unset
.\vcbuild.bat ccache c:\ccache\
Version Comment Result main cdd0687 Result #67590
1.88 minimum supported success success
1.99.1 windows-2025 image 20261103.298.1 success success
1.100.0 windows-2025 image 20261116.315.1 undefined symbol success

Original failure rust 1.100.0

lld-link : error : undefined symbol: __declspec(dllimport) WakeByAddressSingle
...
lld-link : error : undefined symbol: __declspec(dllimport) WakeByAddressAll
...
lld-link : error : undefined symbol: __declspec(dllimport) WaitOnAddress

Conclusion

Resolves #67589 without regressions.

Due to successful landing of #67591, CI in the main branch will now be running with RUSTC_VERSION: '1.88' so the issue would now only affect installations that are using Rust toolchain >=1.100.0, for instance local installations.

@MikeMcC399 MikeMcC399 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 19, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@Renegade334 Renegade334 added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Nov 19, 2026
wszgrcy pushed a commit to wszgrcy/GodotJS-Dependencies that referenced this pull request Nov 20, 2026
Run 44652514543 lost windows x86_64/arm64, macos x86_64 and both iOS entries;
linux, android and macOS arm64 were fine. Each failure had its own cause.

Windows (both arches): every link of node_crates.lib stopped with
  error LNK2019: unresolved external symbol __imp_WaitOnAddress /
  __imp_WakeByAddressSingle / __imp_WakeByAddressAll
referenced from std-*.rcgu.o. Meaning: Temporal is Rust, cargo builds it into a
static library, and Node hands that library to link.exe like any other archive -
so every symbol std references has to be findable through an import library.
WaitOnAddress/WakeByAddress* live in Synchronization.lib (MSDN: header synchapi.h,
served by API-MS-Win-Core-Synch-l1-2-0.dll) and Node never names it. Until Rust
1.99 std declared those three with a raw-dylib link attribute, which needs no
import library - verified by comparing library/std/src/sys/pal/windows/c.rs at
1.99.0 and 1.100.0: the block is gone in 1.100.0, only the win7 runtime-loading
fallback is left. So the same Node source built green with the image's 1.99.1 on
Nov 18 and red with 1.100.0 on Nov 20.

The fix is to name the library, not to hold the compiler back:
patches/godotjs-node-crates-win-synchronization.patch adds -lsynchronization to
the Windows link_settings of deps/crates/crates.gyp - the same one-line change as
nodejs/node#67590 for nodejs/node#67589, still open upstream, so this patch can be
deleted once that lands. Checked against real Node 26.13.1 sources: applies
forward, and the reverse check recognises it as already applied.

On the Rust version, since the pin first suggested here was the wrong instinct:
Node sets only a floor, rustc and cargo >= 1.86 with LLVM >= 19 (BUILDING.md, and
deps/crates/Cargo.toml's rust-version), and carries no rust-toolchain file. Node's
Windows CI declares RUSTC_VERSION 1.88, but nodejs/node#67589 says that override
has been failing quietly, so upstream really builds against the image's rolling
stable - which is why the runner's version moving is what surfaced this. The
workflow therefore uses the image's Rust, and NODE_RUST_TOOLCHAIN can name a
version when reproducing a build matters.

windows arm64 also never got GODOTJS_NODE_CLANG_CL: "is this the runner's own
architecture" was asked with uname -m, and Git Bash on a Windows-on-ARM runner
reports x86_64 there (log: "arch arm64 is not the runner's arch (x86_64)"), so the
entry took the cross branch. VSCMD_ARG_HOST_ARCH from the Visual Studio step says
it correctly; uname -m stays as a warned fallback.

macos x86_64 and ios: the workflow called $GITHUB_WORKSPACE/tools/apple_toolchain.sh,
but the build job checks this repository out under Scripts/ (only pick uses the
default path), so it died with 127 before configure. Both call sites name
Scripts/tools/ now.

ios x86_64 (the simulator): rustup target add x86_64-apple-ios-sim is rejected by
stable Rust, and rightly - neither the 1.99.1 nor the 1.100.0 dist manifest has a
standard library for that triple (both have aarch64-apple-ios-sim). The matrix
entry declares temporal=off, the job turns that into NODE_TEMPORAL=off, and the
args file records what the bundle lacks. The device bundle keeps Temporal.

lws iOS simulator: lipo takes the file before the command (usage is
"lipo <input_file> <command>"), so "lipo -verify_arch x86_64 <file>" read the path
as an architecture flag. The check now passes the file first and reads
LC_BUILD_VERSION from extracted archive members, so it no longer depends on how
otool happens to treat archives.
wszgrcy pushed a commit to wszgrcy/GodotJS-Dependencies that referenced this pull request Nov 20, 2026
Runs 44652514543 and 44664449521 lost windows x86_64/arm64 and both iOS entries;
linux, android and macOS arm64 built. Five separate causes, each with its own fix.

Windows: every link of node_crates.lib stopped with
  error LNK2019: unresolved external symbol __imp_WaitOnAddress /
  __imp_WakeByAddressSingle / __imp_WakeByAddressAll
referenced from std-*.rcgu.o. Temporal is Rust, cargo builds it into a static
library, and Node hands that archive to link.exe like any other one - so every
symbol std references has to be reachable through an import library.
WaitOnAddress/WakeByAddress* live in Synchronization.lib (MSDN: header synchapi.h,
served by API-MS-Win-Core-Synch-l1-2-0.dll) and Node never names it. Until Rust
1.99 std declared them through a raw-dylib link attribute, which needs no import
library - compared library/std/src/sys/pal/windows/c.rs at 1.99.0 and 1.100.0: the
block is gone in 1.100.0, only the win7 runtime-loading fallback is left - so the
same Node source built green with the image's 1.99.1 and red with 1.100.0. Naming
the library is the fix, and upstream agrees: patches/
godotjs-node-crates-win-synchronization.patch adds -lsynchronization to the
Windows link_settings of deps/crates/crates.gyp, the one line of nodejs/node#67590
(for nodejs/node#67589), still open there, so this patch can go once that lands.
Verified against real Node 26.13.1 sources: applies forward, reverse check reads it
as already applied.

Nothing holds the compiler back over this. Node sets only a floor (rustc and cargo
>= 1.86 with LLVM >= 19 in BUILDING.md, rust-version = "1.86" in
deps/crates/Cargo.toml) and carries no rust-toolchain file; its own Windows CI
declares 1.88 while nodejs/node#67589 says that override has been failing quietly,
so upstream builds against the image's rolling stable too. The workflow uses the
runner's Rust, and NODE_RUST_TOOLCHAIN can name a version when reproducing a build
matters.

Windows architecture detection, both places it was wrong. Git Bash on the
Windows-on-ARM runner reports x86_64 on an arm64 machine, so:
  - the workflow's "is clang-cl allowed here" test took the cross branch and left
    GODOTJS_NODE_CLANG_CL unset, and prepare_node_build.sh then refused to run;
  - prepare_node_build.sh read the same lie and called a native arm64 build a cross
    build, which is exactly the case where Temporal is refused (crates.gyp names the
    Rust archive after the target architecture, so host and target would collide).
Both now ask Visual Studio's own environment first: VSCMD_ARG_HOST_ARCH, which the
Visual Studio step publishes for the whole job and which spells the answer x64 or
arm64 (the run logs show x64 on windows-2022 and arm64 on windows-11-arm). uname -m
stays as a fallback and says out loud when it is used. prepare_node_build.sh also
accepts NODE_HOST_CPU for a job that wants to say it directly.

iOS: the compile lines carried no C++ standard at all, so the first C++ file stopped
at deps/v8/include/v8config.h, "C++20 or later required." - and it stopped on the
host toolset (obj.host/...), which is why it looked like a toolchain problem rather
than a flag problem. Cause: gyp's ninja generator turns xcode_settings into flags
only for the mac flavour (tools/gyp/pylib/gyp/generator/ninja.py, `if self.flavor ==
"mac"`), and Node names its standard and exception setting there (common.gypi:
CLANG_CXX_LANGUAGE_STANDARD=gnu++20, GCC_ENABLE_CPP_EXCEPTIONS=NO). With
--dest-os=ios the flavour is ios, so nothing ever passed -std=. tools/
apple_toolchain.sh now bakes -std=gnu++20 -fno-exceptions into the iOS C++ wrappers,
plus a host_cxx that adds the same flags without aiming the compiler at the SDK, and
it prints CXX_host pointing at it; macOS is untouched because gyp handles that
flavour itself. tools/test_apple_toolchain.sh grew the matching assertions (44
checks, no Xcode needed).

ios x86_64 (the simulator): rustup target add x86_64-apple-ios-sim is rejected by
stable Rust, and rightly - neither the 1.99.1 nor the 1.100.0 dist manifest carries
a standard library for that triple (both have aarch64-apple-ios-sim). The matrix
entry declares temporal=off, the job turns that into NODE_TEMPORAL=off, and the args
file records what the bundle lacks. The device bundle keeps Temporal.

macos x86_64 and ios called $GITHUB_WORKSPACE/tools/apple_toolchain.sh, but the build
job checks this repository out under Scripts/ (only pick uses the default path), so
it died with 127 before configure. Both call sites name Scripts/tools/ now.

lws iOS simulator: lipo takes the file before the command ("lipo <input_file>
<command>"), so "lipo -verify_arch x86_64 <file>" read the path as an architecture
flag. The check now passes the file first and reads LC_BUILD_VERSION from extracted
archive members, so it no longer depends on how otool happens to treat archives.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. build Issues and PRs related to Node.js builds or CI infrastructure. crates Issues and PRs related to the Rust crate dependencies. dependencies PRs that add, update, or configure Node.js dependencies. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. needs-ci PRs that need a full CI run. windows Issues and PRs related to the Windows platform.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI/Windows: build failing on newer rustc

3 participants