build.bat: install rustup targets for pinned toolchain#416
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Windows build script to proactively install Rust stdlib targets via rustup for the repository’s pinned toolchain (src/rust-toolchain.toml), fixing cross-target builds when the non-host target isn’t already installed.
Changes:
- Add a guarded
rustup target addstep inbuild.batto ensure required Windows targets are installed before building. - When
--allis used, install bothx86_64-pc-windows-msvcandaarch64-pc-windows-msvc; otherwise install only the selected/native target.
Show a summary per file
| File | Description |
|---|---|
| build.bat | Installs required rustup targets before invoking cross-target cargo build, improving reliability of build.bat --all under the pinned toolchain. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
2fe86fb to
4d2b25c
Compare
After #399 pinned the local Rust toolchain to 1.93 via src/rust-toolchain.toml, `build.bat --all` started failing for developers whose 1.93 install only has the host target's stdlib — rustup auto-downloads the pinned channel on first cargo invocation from src/, but only for the host triple, so the cross-target build (aarch64 from x86_64 hosts, or vice versa) fails with a missing stdlib. Mirror the fix already in build-mac.sh (lines 87-92): before running cargo, gate on `where rustup` and `rustup target add` each requested triple inside src/ so the pin applies. Output is silenced and errors swallowed — if rustup itself can't add the target, the subsequent `cargo build` will produce the real diagnostic. build.sh on Linux doesn't need this because it builds for the host target without --target, which rustup's channel auto-install already covers. Verified: `build.bat --all` now builds both x86_64-pc-windows-msvc and aarch64-pc-windows-msvc cleanly on a host with only the native target previously installed under 1.93.
4d2b25c to
44ef584
Compare
adpa-ms
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rustup target addfix frombuild-mac.sh(lines 87-92) intobuild.batsobuild.bat --allworks for developers whose 1.93 install (pinned in Pin Rust toolchain to match CI (1.93) #399) only includes the host target's stdlib.aarch64-pc-windows-msvcfrom x86_64 hosts, or vice versa) were failing becauserustupauto-downloads the pinned channel for the host triple only — the cross-target stdlib still needs an explicitrustup target add.where rustup; output silenced; errors swallowed so a missing target falls through to a realcargo builddiagnostic rather than a vague rustup one.build.shdoesn't need the equivalent — it builds without--target, so the host-channel auto-install is sufficient.Test plan
build.bat --allfrom a clean state with only the native target installed under 1.93 — bothx86_64-pc-windows-msvcandaarch64-pc-windows-msvccompile, exit 0.Microsoft Reviewers: Open in CodeFlow