Skip to content

Enforce in bootstrap that build must have stage at least 1 #142581

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

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,12 @@ impl Step for Rustc {
}

fn make_run(run: RunConfig<'_>) {
// If only `compiler` was passed, do not run this step.
// Instead the `Assemble` step will take care of compiling Rustc.
if run.builder.paths == vec![PathBuf::from("compiler")] {
return;
}
Comment on lines +1016 to +1020
Copy link
Member

Choose a reason for hiding this comment

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

Remark: this kinda feels iffy, in that I feel like the path filtering/handling logic that lead to

Rustc step was invoked twice, once with all crates and once with no crates (even though both of these mean the same thing).

makes this kinda weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would love Rustc and Assemble to be just one step (to avoid things like this), but I guess that it's sort of an optimizatoin, Rustc allows building only selected crates, and doesn't involve building a ton of other things that you might not want for a quick build.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that does make sense.


let crates = run.cargo_crates_in_set();
run.builder.ensure(Rustc {
build_compiler: run
Expand Down
10 changes: 2 additions & 8 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,24 +1244,19 @@ mod staging {
insta::assert_snapshot!(get_steps("compiler", "build", None), @r"
[build] llvm <target1>
[build] rustc 0 <target1> -> rustc 1 <target1>
[build] rustc 0 <target1> -> rustc 1 <target1>
");
}

#[test]
fn build_compiler_stage_0() {
insta::assert_snapshot!(get_steps("compiler", "build", Some(0)), @r"
[build] llvm <target1>
[build] rustc 0 <target1> -> rustc 1 <target1>
");
insta::assert_snapshot!(get_steps("compiler", "build", Some(0)), @"");
}

#[test]
fn build_compiler_stage_1() {
insta::assert_snapshot!(get_steps("compiler", "build", Some(1)), @r"
[build] llvm <target1>
[build] rustc 0 <target1> -> rustc 1 <target1>
[build] rustc 0 <target1> -> rustc 1 <target1>
");
}

Expand All @@ -1272,12 +1267,11 @@ mod staging {
[build] rustc 0 <target1> -> rustc 1 <target1>
[build] rustc 1 <target1> -> std 1 <target1>
[build] rustc 1 <target1> -> rustc 2 <target1>
[build] rustc 1 <target1> -> rustc 2 <target1>
");
}

fn get_steps(path: &str, kind: &str, stage: Option<u32>) -> String {
let mut args = vec![kind];
let mut args = vec![kind, path];
let stage_str = stage.map(|v| v.to_string()).unwrap_or_default();
if let Some(stage) = stage {
args.push("--stage");
Expand Down