nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.04k stars 28.84k forks source link

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

Open devraymondsh opened 3 months ago

devraymondsh commented 3 months ago

Version

v21.7.3

Platform

Microsoft Windows NT 10.0.20348.0 x64

What steps will reproduce the bug?

Cross-compiling for Windows ARM64 on a Windows x86_64 machine.

What is the expected behavior? Why is that the expected behavior?

Should compile.

What do you see instead?

Here's the log:

--snip--

  NodeWorker.cpp

  NodeTracing.cpp

  NodeRuntime.cpp

     Creating library out\Release\libnode.lib and object out\Release\libnode.exp

  libnode.vcxproj -> out\Release\\libnode.dll

  generate_node_def_action

  '"out\Release\gen_node_def_host.exe"' is not recognized as an internal or external command,
  operable program or batch file.

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for 'out\Release\\libnode.dll' exited with code 1. [D:\a\github\node\generate_node_def.vcxproj]

Additional information

Compiling as a shared library with:

.\vcbuild.bat arm64 dll 
richardlau commented 3 months ago

cc @nodejs/platform-windows-arm

StefanStojanovic commented 3 months ago

I've investigated this and can confirm the behavior. The issue is that the project used for generating the DLL gen_node_def is not compiled for the host architecture but for the target one. That is why there is no gen_node_def_host.exe. gen_node_def.exe does exist but cannot be executed on an x64 machine since it is built for ARM64.

By the looks of things, this never worked but is caught just now.