Skip to content

Reduce usage of compiler_for in bootstrap #145310

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

Merged
merged 4 commits into from
Aug 15, 2025

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Aug 12, 2025

While working on refactoring/fixing dist steps, I realized that build.full-bootstrap does much more than it should, and that it its documentation is wrong. It seems that the main purpose of this option should be to enable/disable stdlib/compiler uplifting (https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Purpose.20of.20.60build.2Efull-bootstrap.60/with/533985624), but currently it also affects staging, or more precisely which compiler will be used to build selected steps, because this option is used in the cursed compiler_for function.

I would like to change the option it so that it only affects uplifting, and doesn't affect stage selection, which I (partially) did in this PR. I removed the usage of compiler_for from the Std and Rustc steps, and explicitly implemented uplifting, without going through compiler_for.

The only remaining usages of compiler_for are in dist steps (which I'm currently refactoring, will send a PR later) and test steps (which I will take a look at after dist). After that we can finally remove the function.

I tried to document the case when uplifting was happening during cross-compilation, which was very implicit before. I also did a slight change in the uplifting logic for rustc when cross-compiling. Before, we would attempt to uplift a stage1 rustc, but that is not really a thing when cross-compiling.

r? @jieyouxu

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 12, 2025

This PR modifies bootstrap.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@rust-log-analyzer

This comment has been minimized.

@Kobzol Kobzol force-pushed the compiler-for-revamp branch from b4c6c8e to 39ff9a3 Compare August 12, 2025 18:15
@bors
Copy link
Collaborator

bors commented Aug 13, 2025

☔ The latest upstream changes (presumably #145295) made this pull request unmergeable. Please resolve the merge conflicts.

@Kobzol Kobzol force-pushed the compiler-for-revamp branch from 39ff9a3 to 4d9cbfd Compare August 13, 2025 06:06
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks. The staging reasoning looks right to me. You can r=me once the tracing PR merges then rebase, as I think there might be a merge conflict there.

@@ -143,7 +144,7 @@ impl Step for Std {
skip_all,
fields(
target = ?self.target,
compiler = ?self.compiler,
build_compiler = ?self.build_compiler,
Copy link
Member

Choose a reason for hiding this comment

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

Remark: I think this will merge-conflict with #145340

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, why should it? That only modified check and this modifies compile 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, you probably meant the #[instrument] removal PR.

@jieyouxu
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2025
@bors
Copy link
Collaborator

bors commented Aug 15, 2025

☔ The latest upstream changes (presumably #145407) made this pull request unmergeable. Please resolve the merge conflicts.

@Kobzol Kobzol force-pushed the compiler-for-revamp branch from 4d9cbfd to f2c2d3e Compare August 15, 2025 06:24
@Kobzol
Copy link
Member Author

Kobzol commented Aug 15, 2025

Rebased.

@bors r=jieyouxu

@bors
Copy link
Collaborator

bors commented Aug 15, 2025

📌 Commit f2c2d3e has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 15, 2025
bors added a commit that referenced this pull request Aug 15, 2025
Rollup of 11 pull requests

Successful merges:

 - #144210 (std: thread: Return error if setting thread stack size fails)
 - #145310 (Reduce usage of `compiler_for` in bootstrap)
 - #145311 (ci: clean windows disk space in background)
 - #145340 (Split codegen backend check step into two and don't run it with `x check compiler`)
 - #145408 (Deduplicate -L search paths)
 - #145412 (Windows: Replace `GetThreadId`+`GetCurrentThread` with `GetCurrentThreadId`)
 - #145413 (bootstrap: Reduce dependencies)
 - #145426 (Fix typos in bootstrap.example.toml)
 - #145430 (Fix wrong spans with external macros in the `dropping_copy_types` lint)
 - #145431 (Enhance UI test output handling for runtime errors)
 - #145448 (Autolabel `src/tools/{rustfmt,rust-analyzer}` changes with `T-{rustfmt,rust-analyzer}`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 87d677b into rust-lang:master Aug 15, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 15, 2025
@Kobzol Kobzol deleted the compiler-for-revamp branch August 15, 2025 18:52
rust-timer added a commit that referenced this pull request Aug 15, 2025
Rollup merge of #145310 - Kobzol:compiler-for-revamp, r=jieyouxu

Reduce usage of `compiler_for` in bootstrap

While working on refactoring/fixing `dist` steps, I realized that `build.full-bootstrap` does much more than it should, and that it its documentation is wrong. It seems that the main purpose of this option should be to enable/disable stdlib/compiler uplifting (https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Purpose.20of.20.60build.2Efull-bootstrap.60/with/533985624), but currently it also affects staging, or more precisely which compiler will be used to build selected steps, because this option is used in the cursed `compiler_for` function.

I would like to change the option it so that it *only* affects uplifting, and doesn't affect stage selection, which I (partially) did in this PR. I removed the usage of `compiler_for` from the `Std` and `Rustc` steps, and explicitly implemented uplifting, without going through `compiler_for`.

The only remaining usages of `compiler_for` are in dist steps (which I'm currently refactoring, will send a PR later) and test steps (which I will take a look at after dist). After that we can finally remove the function.

I tried to document the case when uplifting was happening during cross-compilation, which was very implicit before. I also did a slight change in the uplifting logic for rustc when cross-compiling. Before, we would attempt to uplift a stage1 rustc, but that is not really a thing when cross-compiling.

r? `@jieyouxu`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants