Skip to content

build.bat: install rustup targets for pinned toolchain#416

Merged
MGudgin merged 1 commit into
mainfrom
user/gudge/fix-buildbat-toolchain
May 26, 2026
Merged

build.bat: install rustup targets for pinned toolchain#416
MGudgin merged 1 commit into
mainfrom
user/gudge/fix-buildbat-toolchain

Conversation

@MGudgin

@MGudgin MGudgin commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Mirrors the rustup target add fix from build-mac.sh (lines 87-92) into build.bat so build.bat --all works for developers whose 1.93 install (pinned in Pin Rust toolchain to match CI (1.93) #399) only includes the host target's stdlib.
  • Cross-target builds (aarch64-pc-windows-msvc from x86_64 hosts, or vice versa) were failing because rustup auto-downloads the pinned channel for the host triple only — the cross-target stdlib still needs an explicit rustup target add.
  • Guarded by where rustup; output silenced; errors swallowed so a missing target falls through to a real cargo build diagnostic rather than a vague rustup one.
  • build.sh doesn't need the equivalent — it builds without --target, so the host-channel auto-install is sufficient.

Test plan

  • build.bat --all from a clean state with only the native target installed under 1.93 — both x86_64-pc-windows-msvc and aarch64-pc-windows-msvc compile, exit 0.
  • Reviewer to sanity-check on an ARM64 host if available.
  • CI green.
Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings May 26, 2026 19:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 add step in build.bat to ensure required Windows targets are installed before building.
  • When --all is used, install both x86_64-pc-windows-msvc and aarch64-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

@MGudgin MGudgin force-pushed the user/gudge/fix-buildbat-toolchain branch from 2fe86fb to 4d2b25c Compare May 26, 2026 19:22
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.
@MGudgin MGudgin force-pushed the user/gudge/fix-buildbat-toolchain branch from 4d2b25c to 44ef584 Compare May 26, 2026 19:48
@MGudgin MGudgin merged commit d7be85e into main May 26, 2026
18 checks passed
@MGudgin MGudgin deleted the user/gudge/fix-buildbat-toolchain branch May 26, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants