Skip to content

fix(cli): honor rustup +toolchain on direct cargo-zigbuild invocations - #522

Open
1998LJ wants to merge 2 commits into
rust-cross:mainfrom
1998LJ:fix/512-direct-rustup-toolchain
Open

1998LJ wants to merge 2 commits into
rust-cross:mainfrom
1998LJ:fix/512-direct-rustup-toolchain

Conversation

@1998LJ

@1998LJ 1998LJ commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #512.

  • Support cargo-zigbuild +nightly build --target ... (and other +toolchain selectors) as a Zig-aware build, instead of treating +nightly as an external command and delegating directly to Cargo without Zig linker configuration.
  • Set RUSTUP_TOOLCHAIN before rustc-version probes and child Cargo command execution so the selected toolchain is consistent throughout the build.
  • Preserve the existing cargo +nightly zigbuild plugin path and generic external Cargo subcommands.
  • Add regression tests for parsing and actual toolchain propagation through a fake Cargo process, plus README examples.

Verification

  • cargo test --locked: passed (library, CLI and integration tests).
  • cargo fmt --all -- --check: passed.
  • cargo clippy --all-targets --all-features --locked -- -D warnings -A clippy::useless_conversion -A clippy::useless_borrows_in_formatting -A clippy::chunks_exact_to_as_chunks: passed (these three lint groups are triggered by pre-existing code under Rust 1.99).
  • Test covers direct +stable invocation without needing Zig or a cross-compiler. The original Windows GNU getrandom compilation with nightly/Zig was not run locally.

The implementation and tests were prepared with AI coding assistance and verified locally.

Signed-off-by: 1998LJ wenjinjia4@gmail.com

Recognize a leading rustup +toolchain selector before clap parsing and
propagate it via RUSTUP_TOOLCHAIN to rustc probes and child Cargo commands.
This keeps direct cargo-zigbuild +nightly build on the Zig-aware build path
instead of delegating to raw Cargo without Zig linker configuration.

Add regression coverage for dispatch, environment propagation, and existing
plugin / external commands.

Fixes rust-cross#512.

Signed-off-by: 1998LJ <wenjinjia4@gmail.com>
Keep new PR documentation changes in distinct README sections to reduce
future merge conflicts with the separate target-mappings PR.

Signed-off-by: 1998LJ <wenjinjia4@gmail.com>

This branch has not been deployed

No deployments
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.

"cargo zigbuild" and "cargo-zigbuild build" act differently when using the nightly toolchain.

1 participant