Commit 28b50fb0169 for nodejs
commit 28b50fb01694fb7adf07e98f7bcabe87fecef9a8
Author: Ved Chaudhari <84765263+vedchaudhari@users.noreply.github.com>
Date: Wed Oct 21 23:21:42 2026 +0530
build,win: fail fast in vcbuild without cargo
On Windows, configure.py returns from check_compiler() before it gets
to the cargo and rustc check, so Temporal stays enabled even when no
Rust toolchain is installed. The build then runs for a long time and
fails in node_crates.vcxproj with MSB8066.
Check for cargo in vcbuild.bat before configuring and building, in the
same places deps/crates/cargo_build.py looks, and stop with a message
pointing to BUILDING.md. The check is skipped for nobuild, clean, and
when Temporal is disabled or provided as a shared library.
Assisted-by: a closed-source coding agent
Signed-off-by: vedchaudhari <vedc2853@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66858
Fixes: https://github.com/nodejs/node/issues/66848
Refs: https://github.com/nodejs/node/issues/63451
Reviewed-By: Mike McCready <66998419+MikeMcC399@users.noreply.github.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
diff --git a/tools/msvs/find_cargo.cmd b/tools/msvs/find_cargo.cmd
new file mode 100644
index 00000000000..4ee20de5687
--- /dev/null
+++ b/tools/msvs/find_cargo.cmd
@@ -0,0 +1,18 @@
+@IF NOT DEFINED DEBUG_HELPER @ECHO OFF
+SETLOCAL
+
+ECHO Looking for cargo
+
+REM Look in the same places as deps\crates\cargo_build.py.
+SET "cargo_cmd=cargo"
+IF DEFINED CARGO SET "cargo_cmd=%CARGO%"
+
+IF EXIST "%cargo_cmd%" EXIT /B 0
+
+FOR /F "delims=" %%a IN ('where "%cargo_cmd%" 2^> NUL') DO (
+ EXIT /B 0
+)
+
+IF EXIST "%USERPROFILE%\.cargo\bin\cargo.exe" EXIT /B 0
+
+EXIT /B 1
diff --git a/vcbuild.bat b/vcbuild.bat
index d1a6d8fb7f3..8b8c393133c 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -297,6 +297,18 @@ REM NASM is only needed on x86_64.
if not defined openssl_no_asm if "%target_arch%" NEQ "arm64" call tools\msvs\find_nasm.cmd
if errorlevel 1 echo Could not find NASM, install it or build with openssl-no-asm. See BUILDING.md.
+REM cargo is needed to build the Rust crates used for Temporal.
+if defined nobuild goto skip-find-cargo
+if "%target%"=="Clean" goto skip-find-cargo
+echo %configure_flags% | findstr /C:"--v8-disable-temporal-support" /C:"--shared-temporal_capi" >NUL && goto skip-find-cargo
+call tools\msvs\find_cargo.cmd
+if errorlevel 1 (
+ echo Could not find cargo, install the Rust toolchain. See BUILDING.md.
+ set exit_code=1
+ goto exit
+)
+:skip-find-cargo
+
call :getnodeversion || exit /b 1
@REM Forcing ClangCL usage for version 24 and above