Skip to content

build,tools: fix shared library cross-compile#63963

Open
PickBas wants to merge 1 commit into
nodejs:mainfrom
JaneaSystems:win-dll-fix
Open

build,tools: fix shared library cross-compile#63963
PickBas wants to merge 1 commit into
nodejs:mainfrom
JaneaSystems:win-dll-fix

Conversation

@PickBas

@PickBas PickBas commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fix Windows DLL build

Fixes building Node.js as a shared library on Windows, including cross-compiling (e.g. arm64 on an x64 host).

  • tools/gen_node_def: parse the PE export table statically instead of LoadLibrary/GetProcAddress, so a host-arch tool can read a cross-compiled target-arch libnode.dll. Output is byte-identical to the old tool on native x64 builds.
  • node.gyp: when cross-compiling, build gen_node_def for the host so it can run during the build, and have generate_node_def depend on that host build. Also link Dbghelp.lib, winmm.lib, and Ws2_32.lib into the shared library, and don't define BUILDING_NODE_EXTENSION for node_mksnapshot (it links node_base statically, so its symbols must not be marked dllimport).

Testing

Comparing the original gen_node_def with changed (x64):

C:\dev\node_projects\node> cl /EHsc gen_node_def_orig.cc /Fe:gen_node_def_orig.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.51.36244 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

gen_node_def_orig.cc
Microsoft (R) Incremental Linker Version 14.51.36244.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:gen_node_def_orig.exe
gen_node_def_orig.obj

C:\dev\node_projects\node>gen_node_def_orig.exe out\Release\libnode.dll old.def

C:\dev\node_projects\node>fc old.def out\Release\node.def
Comparing files old.def and OUT\RELEASE\NODE.DEF
FC: no differences encountered

Attempt of .def file generation of the original gen_node_def (arm64):

C:\dev\node_projects\node>gen_node_def_orig.exe out\Release\libnode.dll old.def
ERROR: Failed to load out\Release\libnode.dll

Fixes: #52664

Fixes: nodejs#52664
Signed-off-by: PickBas <sayed.kirill@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory. labels Jun 17, 2026
@StefanStojanovic StefanStojanovic added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 14, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jul 14, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/63963
βœ”  Done loading data for nodejs/node/pull/63963
----------------------------------- PR info ------------------------------------
Title      build,tools: fix shared library cross-compile (#63963)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     PickBas:win-dll-fix -> nodejs:main
Labels     build, tools, needs-ci
Commits    1
 - build,tools: fix shared library cross-compile
Committers 1
 - PickBas <sayed.kirill@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63963
Fixes: https://github.com/nodejs/node/issues/52664
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/63963
Fixes: https://github.com/nodejs/node/issues/52664
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
--------------------------------------------------------------------------------
   β„Ή  This PR was created on Wed, 17 Jun 2026 12:31:08 GMT
   βœ”  Approvals: 1
   βœ”  - Stefan Stojanovic (@StefanStojanovic): https://github.com/nodejs/node/pull/63963#pullrequestreview-4644512383
   ✘  8 GitHub CI job(s) failed:
   ✘    - github-actions: ACTION_REQUIRED
   ✘    - github-actions: ACTION_REQUIRED
   ✘    - github-actions: ACTION_REQUIRED
   ✘    - github-actions: ACTION_REQUIRED
   ✘    - github-actions: ACTION_REQUIRED
   ✘    - github-actions: ACTION_REQUIRED
   ✘    - github-actions: ACTION_REQUIRED
   ✘    - github-actions: ACTION_REQUIRED
   ✘  No Jenkins CI runs detected
--------------------------------------------------------------------------------
   βœ”  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/29321997377

@StefanStojanovic StefanStojanovic added request-ci Add this label to start a Jenkins CI on a PR. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jul 14, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 14, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cross-compilation bug when compiling for ARM64 on a non-ARM64 host with Windows

3 participants