Skip to content

fix(rustup-mode): backfill non-native targets on rustup toolchain pin - #5248

Merged
rami3l merged 5 commits into
rust-lang:mainfrom
rami3l:refactor/component-is-std
Nov 24, 2026
Merged

rami3l merged 5 commits into
rust-lang:mainfrom
rami3l:refactor/component-is-std

Conversation

@rami3l

@rami3l rami3l commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Closes #5240 by addressing the concern No. 1 in #5240 (comment):

Previously, non-native targets are populated in the components section like so, causing confusion for both users and rustup toolchain install:

[toolchain]
channel = "beta"
components = ["cargo", "rust-docs", "rust-std", "rust-std-[CROSS_ARCH_I]", "rustc"]

This PR has fixed the resulting TOML format so non-native rust-std components are put into the targets section rather than in the components section:

[toolchain]
channel = "beta"
components = ["cargo", "rust-docs", "rust-std", "rustc"]
targets = ["[CROSS_ARCH_I]"]

API migration and generation of tests assisted by Copilot on Claude Sonnet 5.5.

@rami3l
rami3l force-pushed the refactor/component-is-std branch 2 times, most recently from 13ec0ca to b109aee Compare November 23, 2026 14:18
@rami3l
rami3l marked this pull request as ready for review November 23, 2026 14:19
@rami3l
rami3l requested review from djc and removed request for djc November 23, 2026 14:19
@rami3l

rami3l commented Nov 23, 2026 •

Copy link
Copy Markdown
Member Author

Concern: putting all rust-std in the components section as fully qualified is fair since it's not biased towards any toolchain's host target. However after this patch it may be. Also, the interaction with --qualified should be reconsidered.

I see that there are essentially two cases where we want to have the targets section: cross-compiling to non-host targets such as wasm32, or to be able to cross compile to a series of targets (including host targets, e.g. Windows + macOS + Linux). In the former case I'd like to have rust-std biased towards my host, so that the same file works for both macOS and Linux hosts for instance. In the latter case, however, rust-std from the toolchain host is irrelevant.

I eventually decided that since most users are in the first case, this bias is still preferable. If the user is really in the second case, then they can always adjust the generated TOML file just like how we conventionally audit generated SQL migration scripts when working with ORMs.

As such, --qualified continues to qualify the toolchain host as it does right now.

@rami3l
rami3l marked this pull request as draft November 23, 2026 14:42
@rami3l
rami3l marked this pull request as ready for review November 23, 2026 14:54
@rami3l
rami3l requested a review from djc November 23, 2026 14:58
Comment thread src/cli/rustup_mode.rs Resolved
@rami3l
rami3l force-pushed the refactor/component-is-std branch from e23bdf5 to 74a9054 Compare November 24, 2026 10:16
@rustbot

rustbot commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

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.

🟡 Changes recommended

The component guard uses the default host instead of the toolchain target, causing an explicitly qualified toolchain’s pinned file to omit an installed target that is then lost on reinstall.

1 open issue
What changed in this PR

This PR updates rustup toolchain pin to record installed non-native standard libraries under targets, addressing the generated-file format problem reported in #5240.

Changes:

  • Separate installed components and cross-compilation targets when generating pinned toolchain files.
  • Add a shared Component::is_std() helper for standard-library checks.
  • Add regression coverage for pinning and reinstalling a toolchain with an extra target.
File Description
tests/​suite/​cli_rustup.rs Add extra-target pinning and reinstall coverage; update snapshots.
src/​toolchain/​channels.rs Use the shared standard-library predicate.
src/​dist/​manifest.rs Introduce Component::is_std().
src/​config.rs Expose targets for pinned-file generation.
src/​cli/​rustup_mode.rs Separate pinned targets from components and adopt the helper.
src/​cli/​completions.rs Use the helper when selecting target completions.

Review effort: Balanced

View changes since this review

Comment thread src/cli/rustup_mode.rs Resolved
rami3l and others added 4 commits November 24, 2026 11:30
… extra target

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…pin`

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@rami3l
rami3l force-pushed the refactor/component-is-std branch from 74a9054 to 6b51fd7 Compare November 24, 2026 10:33
@rami3l
rami3l enabled auto-merge November 24, 2026 10:37
@rami3l
rami3l added this pull request to the merge queue Nov 24, 2026
Merged via the queue into rust-lang:main with commit da02c7c Nov 24, 2026
29 checks passed
@rami3l
rami3l deleted the refactor/component-is-std branch November 24, 2026 11:18
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.

toolchain pin puts installed targets under components

4 participants