Skip to content

rustc_session: Add a structure for keeping both explicit and default sysroots #142799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petrochenkov
Copy link
Contributor

Also avoid creating and cloning sysroot unnecessarily.

Implements the suggestion from #142089 (comment).
r? @bjorn3

…sysroots

Also avoid creating and cloning sysroot unnecessarily.
@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 20, 2025

rustc_error_messages was changed

cc @davidtwco, @compiler-errors, @TaKO8Ki

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

}

/// Returns both explicit sysroot if it was passed with `--sysroot` and the default sysroot.
pub fn all_paths(&self) -> impl Iterator<Item = &Path> {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe return &[PathBuf] instead? Then fluent_bundle won't need to be made generic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How? Can't do that without changing the storage in Sysroot to something like SmallVec<[PathBuf; 2]>.

fluent_bundle could also be made non-generic by collecting the iterator at its call site.

Copy link
Member

Choose a reason for hiding this comment

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

Right

@bjorn3
Copy link
Member

bjorn3 commented Jun 21, 2025

I've been meaning to split --sysroot into a host sysroot (for codegen backends and executables) and target sysroot (for the standard library and self-contained libraries) option and then only access the default sysroot when the respective option is not set. The current fallback behavior is necessary because someone may pass --sysroot to override the standard library without copying all host executables and libraries into the passed sysroot. If the host and target sysroot can be configured separately, fallback for missing artifacts shouldn't be necessary anymore. Until that is implemented, I do think this PR is an improvement though.

r=me with the all_paths return type change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants