Skip to content

Enforce in bootstrap that dist and install must have stage at least 1 #145472

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 26 commits into
base: master
Choose a base branch
from

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Aug 15, 2025

This is a continuation of my efforts to fix staging in bootstrap after the stage0 redesign. This PR gets rid of all compiler_for usages in the dist steps 🎉 The only remaining usages are in the test steps, which are my next goal, and which will be the final boss.. both because they are quite tricky, and because most of the the rest of the steps have been already fixed.

The changes are relatively straightforward, x dist defaults to stage 2, so in that case we want to use a stage 1 build compiler for everything (except stdlib, but we usually use it even there because of uplifting).

What I didn't fix yet are the docs steps, because they are very implicit right now, and fixing them deserves its own PR.

The first commit reverts the tests that I accidentally removed in #145340 🤦‍♂️ I did it in this PR to avoid further git conflicts..

Best reviewed commit-by-commit.

r? @jieyouxu

try-job: dist-i686-linux
try-job: dist-armhf-linux
try-job: dist-x86_64-linux
try-job: dist-x86_64-msvc
try-job: dist-apple-various
try-job: dist-x86_64-apple

@rustbot rustbot added A-bootstrap-stamp Area: bootstrap stamp logic A-testsuite Area: The testsuite used to check the correctness of rustc 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 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 15, 2025

This PR modifies src/bootstrap/src/core/config.

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

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors

This comment was marked as outdated.

@rustbot
Copy link
Collaborator

rustbot commented Aug 20, 2025

This PR was rebased onto a different master 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.

@Kobzol
Copy link
Member Author

Kobzol commented Aug 20, 2025

@bors try

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 20, 2025
Enforce in bootstrap that dist and install must have stage at least 1

try-job: dist-i686-linux
try-job: dist-armhf-linux
try-job: dist-x86_64-linux
try-job: dist-x86_64-msvc
try-job: dist-apple-various
try-job: dist-x86_64-apple
@rust-bors
Copy link

rust-bors bot commented Aug 20, 2025

☀️ Try build successful (CI)
Build commit: f9464d8 (f9464d83262ce8f495c129d9e1059a8d108f3df9, parent: f605b57042ffeb320d7ae44490113a827139b766)

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 other changes I'm on board with. The only bit I'm not sure is the rust-std build optimization, IMO it's not worth the hack to introduce a special case. WDYT?

let sysroot = self.sysroot;
let dst = sysroot.join("lib/rustlib/etc");
t!(fs::create_dir_all(&dst));
let cp_debugger_script = |file: &str| {
builder.install(&builder.src.join("src/etc/").join(file), &dst, FileType::Regular);
};
if host.contains("windows-msvc") {
if target.contains("windows-msvc") {
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 really hope in the future we have some way to share an in-tree structured target spec with rustc... Target tuple string matching feels bad every time I see it 😔

Comment on lines 782 to 783
"Note: stage {top_stage} library for `{}` would be uplifted from stage 1, so stage was downgraded from {top_stage} to 1 to avoid needless compiler build(s)",
run.target
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: maybe say

so build compiler stage was downgraded from {top_stage} to 1 to avoid needless compiler build(s)

?

Comment on lines 772 to 776
// This is a build time optimization for running just `x dist rust-std` (without
// `x dist rustc`).
// If we know that we will be uplifting a stage2+ library from stage 1 anyway,
// there is no point in building a stage2 rustc, which will then not do anything (because
// the stdlib will be uplifted).
Copy link
Member

Choose a reason for hiding this comment

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

Discussion:

  • Who's actually using ./x dist rust-std specifically? Usually, we would be distributing a toolchain together, right? Or at least both compiler and std?
  • I feel uneasy about doing this build optimization, it feels rather "special" (hacky) especially when this is the dist flow. Could we get away with just doing the straightforward ™️ build? I feel like we should just do the "useless" stage 2 rustc build, and then use the same stage 2 std uplifting logic, instead of doing this special casing.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are some CI jobs that do ./x dist --host='' --target i686-unknown-linux-gnu,aarch64-unknown-linux-gnu. But I confirmed it produced the same steps with/without this "optimization".

I agree, let's get rid of it.

@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 20, 2025
@Kobzol
Copy link
Member Author

Kobzol commented Aug 20, 2025

Agreed, removed the special case, and fixed one doc bug that I found when testing the x dist cross-compilation scenarios (the docs dist steps just invoke all default doc steps, which I'm planning to change, so it exposed this issue. Not sure why we didn't hit it on CI...).

@Kobzol
Copy link
Member Author

Kobzol commented Aug 20, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 20, 2025
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!

@@ -994,7 +994,7 @@ macro_rules! tool_doc {
(compilers.build_compiler(), Mode::ToolRustc)
} else {
// bootstrap/host tools have to be documented with the stage 0 compiler
(prepare_doc_compiler(run.builder, target, 1), Mode::ToolBootstrap)
Copy link
Member

Choose a reason for hiding this comment

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

Remark: hecc...

@jieyouxu
Copy link
Member

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Aug 20, 2025

📌 Commit 7da375e 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bootstrap-stamp Area: bootstrap stamp logic A-testsuite Area: The testsuite used to check the correctness of rustc 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