Bootstrapping rust 1.89.0 on Windows fails at "Building tool cargo (stage1 -> stage2, x86_64-pc-windows-gnu)" when using a custom dlltool.
Somewhat complicated to describe. We build a Rust toolchain for Android with a script that is a wrapper around x.py that creates a custom bootstrap.toml and sets some environment variables. Slightly out-of-date version of build scripts is at https://android.googlesource.com/toolchain/android_rust/+/refs/heads/main
We are specifying a custom dlltool in RUSTFLAGS with "-Cdlltool=XXXX". In practice, this doesn't actually work. There seem to be a number of things going on:
This does not appear to be a new issue; it's probably been latent for awhile. It looks like what changed between rust 1.88 and 1.89 is the Cargo.lock file for cargo (src/tools/cargo/Cargo.lock) bumped the version of getrandom from 0.3.1 to 0.3.3, which changes the dependencies and compilation behavior on windows (see rust-random/getrandom#627 and rust-random/getrandom#723).
"AR_x86_64_pc_windows_gnu", Some("C:/src/main-rust-toolchain/prebuilts/clang/host/windows-x86/clang-r574158/bin/llvm-ar.exe")
"CARGO_INCREMENTAL", Some("0")
"CARGO_PROFILE_RELEASE_DEBUG", Some("0")
"CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", Some("false")
"CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS", Some("false")
"CARGO_PROFILE_RELEASE_STRIP", Some("false")
"CARGO_TARGET_DIR", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\x86_64-pc-windows-gnu\\stage1-tools")
"CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER", Some("C:/src/main-rust-toolchain/out/wrappers/linker-x86_64-pc-windows-gnu.cmd")
"CC_x86_64_pc_windows_gnu", Some("C:/src/main-rust-toolchain/out/wrappers/clang-x86_64-pc-windows-gnu.cmd")
"CFG_COMMIT_DATE", Some("2025-06-23")
"CFG_COMMIT_HASH", Some("c24e1064277fe51ab72011e2612e556ac56addf7")
"CFG_COMPILER_BUILD_TRIPLE", Some("x86_64-pc-windows-gnu")
"CFG_COMPILER_HOST_TRIPLE", Some("x86_64-pc-windows-gnu")
"CFG_RELEASE", Some("1.89.0-dev")
"CFG_RELEASE_CHANNEL", Some("dev")
"CFG_RELEASE_NUM", Some("1.89.0")
"CFG_SHORT_COMMIT_HASH", Some("c24e10642")
"CFG_VERSION", Some("1.89.0-dev (29483883e 2025-08-04) (Android Rust Toolchain version windows)")
"CFG_VER_DATE", Some("2025-08-04")
"CFG_VER_DESCRIPTION", Some("Android Rust Toolchain version windows")
"CFG_VER_HASH", Some("29483883eed69d5fb4db01964cdf2af4d86e9cb2")
"CFLAGS_x86_64_pc_windows_gnu", Some("")
"CXXFLAGS_x86_64_pc_windows_gnu", Some("")
"CXX_x86_64_pc_windows_gnu", Some("C:/src/main-rust-toolchain/out/wrappers/clang++-x86_64-pc-windows-gnu.cmd")
"DOC_RUST_LANG_ORG_CHANNEL", Some("https://doc.rust-lang.org/nightly")
"LIBC_CHECK_CFG", Some("1")
"LIBZ_SYS_STATIC", Some("1")
"LZMA_API_STATIC", Some("1")
"MAKEFLAGS", None
"MFLAGS", None
"RANLIB_x86_64_pc_windows_gnu", Some("C:/src/main-rust-toolchain/prebuilts/clang/host/windows-x86/clang-r574158/bin/llvm-ar.exe s")
"REAL_LIBRARY_PATH", Some("C:\\src\\main-rust-toolchain\\prebuilts\\python\\windows-x86;C:\\src\\main-rust-toolchain\\prebuilts\\rust\\windows-x86\\1.88.0\\bin;C:\\src\\main-rust-toolchain\\prebuilts\\cmake\\windows-x86\\bin;C:\\src\\main-rust-toolchain\\prebuilts\\ninja\\windows-x86;C:\\src\\main-rust-toolchain\\prebuilts\\build-tools\\path\\windows-x86;C:\\src\\main-rust-toolchain\\prebuilts\\build-tools\\windows-x86\\bin;C:\\src\\main-rust-toolchain\\out\\rust-toolchain\\bin;C:\\program files\\git\\usr\\bin;C:\\src\\main-rust-toolchain\\prebuilts\\gcc\\linux-x86\\host\\x86_64-w64-mingw32-4.8\\x86_64-w64-mingw32\\bin;C:\\src\\main-rust-toolchain\\prebuilts\\gcc\\linux-x86\\host\\x86_64-w64-mingw32-4.8\\x86_64-w64-mingw32\\lib")
"REAL_LIBRARY_PATH_VAR", Some("PATH")
"RUSTBUILD_NATIVE_DIR", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\x86_64-pc-windows-gnu\\native")
"RUSTC", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\bootstrap\\debug\\rustc")
"RUSTC_BOOTSTRAP", Some("1")
"RUSTC_BREAK_ON_ICE", Some("1")
"RUSTC_CARGO_REGISTRY_SRC_TO_REMAP", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\vendor=/rust/deps")
"RUSTC_DEBUGINFO_MAP", Some("C:\\src\\main-rust-toolchain\\out\\rustc=/rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2")
"RUSTC_ERROR_METADATA_DST", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\tmp/extended-error-metadata")
"RUSTC_HOST_FLAGS", Some("--check-cfg=cfg(bootstrap) -Ctarget-feature=-crt-static -Clinker=C:/src/main-rust-toolchain/out/wrappers/linker-x86_64-pc-windows-gnu.cmd")
"RUSTC_INSTALL_BINDIR", Some("bin")
"RUSTC_LIBDIR", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\x86_64-pc-windows-gnu\\stage1\\bin")
"RUSTC_LINK_STD_INTO_RUSTC_DRIVER", Some("0")
"RUSTC_LINT_FLAGS", Some("")
"RUSTC_REAL", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\x86_64-pc-windows-gnu\\stage1\\bin\\rustc.exe")
"RUSTC_SNAPSHOT", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\x86_64-pc-windows-gnu\\stage1\\bin\\rustc.exe")
"RUSTC_SNAPSHOT_LIBDIR", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\x86_64-pc-windows-gnu\\stage1\\bin")
"RUSTC_STAGE", Some("1")
"RUSTC_SYSROOT", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\x86_64-pc-windows-gnu\\stage1")
"RUSTC_TLS_MODEL_INITIAL_EXEC", Some("1")
"RUSTC_VERBOSE", Some("1")
"RUSTC_WRAPPER", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\bootstrap\\debug\\rustc")
"RUSTDOC", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\bootstrap\\debug\\rustdoc")
"RUSTDOCFLAGS", Some("-Crelocation-model=pic -Csave-temps -Cdlltool=C:\\src\\main-rust-toolchain\\prebuilts\\clang\\host\\windows-x86\\clang-r574158\\bin\\llvm-dlltool.exe --cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(llvm_enzyme) --check-cfg=cfg(rust_analyzer) -Clinker=C:\\src\\main-rust-toolchain\\out\\wrappers\\linker-x86_64-pc-windows-gnu.cmd --crate-version 1.89.0-dev\t(29483883e\t2025-08-04)\t(Android\tRust\tToolchain\tversion\twindows) -Clinker=C:/src/main-rust-toolchain/out/wrappers/linker-x86_64-pc-windows-gnu.cmd")
"RUSTDOC_REAL", Some("/path/to/nowhere/rustdoc/not/required")
"RUSTFLAGS", Some("-Crelocation-model=pic -Csave-temps -Cdlltool=C:\\src\\main-rust-toolchain\\prebuilts\\clang\\host\\windows-x86\\clang-r574158\\bin\\llvm-dlltool.exe --cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(llvm_enzyme) --check-cfg=cfg(rust_analyzer) -Zmacro-backtrace -Csplit-debuginfo=packed -Ctarget-feature=-crt-static -Clink-arg=-LC:/src/main-rust-toolchain/out/rustc/build/x86_64-pc-windows-gnu/llvm/lib -Alinker-messages -Zunstable-options")
"RUST_TEST_THREADS", Some("64")
"SYSROOT", Some("C:\\src\\main-rust-toolchain\\out\\rustc\\build\\x86_64-pc-windows-gnu\\stage1")
"__CARGO_DEFAULT_LIB_METADATA", Some("devtool-rustc1.89.0")
Summary
Bootstrapping rust 1.89.0 on Windows fails at "Building tool cargo (stage1 -> stage2, x86_64-pc-windows-gnu)" when using a custom dlltool.
Command used
Somewhat complicated to describe. We build a Rust toolchain for Android with a script that is a wrapper around x.py that creates a custom bootstrap.toml and sets some environment variables. Slightly out-of-date version of build scripts is at https://android.googlesource.com/toolchain/android_rust/+/refs/heads/main
Expected behaviour
Actual behaviour
C:/src/main-rust-toolchain/prebuilts/rust/windows-x86/1.88.0/bin/cargo.exe build --target x86_64-pc-windows-gnu -Zbinary-dep-depinfo -j 64 -Zroot-dir=C:\src\main-rust-toolchain\out\rustc -v --frozen --release --manifest-path C:\src\main-rust-toolchain\out\rustc\src/tools/cargo\Cargo.toml --features all-staticWe are specifying a custom dlltool in RUSTFLAGS with "-Cdlltool=XXXX". In practice, this doesn't actually work. There seem to be a number of things going on:
-Cdlltool=XXXRUSTC_HOST_FLAGS = "--check-cfg=cfg(bootstrap) -Ctarget-feature=-crt-static -Clinker=C:/src/main-rust-toolchain/out/wrappers/linker-x86_64-pc-windows-gnu.cmd"This does not appear to be a new issue; it's probably been latent for awhile. It looks like what changed between rust 1.88 and 1.89 is the Cargo.lock file for cargo (src/tools/cargo/Cargo.lock) bumped the version of getrandom from 0.3.1 to 0.3.3, which changes the dependencies and compilation behavior on windows (see rust-random/getrandom#627 and rust-random/getrandom#723).
Bootstrap configuration (bootstrap.toml)
Operating system
Windows 11
HEAD
2948388
With some patches: https://android.googlesource.com/toolchain/android_rust/+/refs/heads/main/patches/ (somewhat out-of-date due to AOSP turndown)
Additional context
Full set of environment variables used when invoking std::process::Command: