Fix --skip-std-check-if-no-download-rustc

Since https://github.com/rust-lang/rust/pull/143048, we now explicitly set the build compiler for `check::Std`, which caused it to be built before we checked `--skip-std-check-if-no-download-rustc`. So I moved the check earlier to `make_run`, which resolves it.

I also added a regression test for this. Sadly we can't really test for the positive case easily (when download-ci-rustc is enabled), but we can test the negative cases, where it is disabled.
This commit is contained in:
Jakub Beránek 2025-07-09 22:25:03 +02:00
parent 558d25371f
commit 3e675f4c50
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
2 changed files with 31 additions and 7 deletions

View file

@ -47,6 +47,13 @@ impl Step for Std {
}
fn make_run(run: RunConfig<'_>) {
if !run.builder.download_rustc() && run.builder.config.skip_std_check_if_no_download_rustc {
eprintln!(
"WARNING: `--skip-std-check-if-no-download-rustc` flag was passed and `rust.download-rustc` is not available. Skipping."
);
return;
}
let crates = std_crates_for_run_make(&run);
run.builder.ensure(Std {
build_compiler: prepare_compiler_for_check(run.builder, run.target, Mode::Std),
@ -56,13 +63,6 @@ impl Step for Std {
}
fn run(self, builder: &Builder<'_>) {
if !builder.download_rustc() && builder.config.skip_std_check_if_no_download_rustc {
eprintln!(
"WARNING: `--skip-std-check-if-no-download-rustc` flag was passed and `rust.download-rustc` is not available. Skipping."
);
return;
}
let build_compiler = self.build_compiler;
let stage = build_compiler.stage;
let target = self.target;

View file

@ -1439,6 +1439,30 @@ mod snapshot {
");
}
/// Make sure that we don't check library when download-rustc is disabled
/// when `--skip-std-check-if-no-download-rustc` was passed.
#[test]
fn check_library_skip_without_download_rustc() {
let ctx = TestCtx::new();
let args = ["--set", "rust.download-rustc=false", "--skip-std-check-if-no-download-rustc"];
insta::assert_snapshot!(
ctx.config("check")
.paths(&["library"])
.args(&args)
.render_steps(), @"");
insta::assert_snapshot!(
ctx.config("check")
.paths(&["library", "compiler"])
.args(&args)
.render_steps(), @r"
[build] llvm <host>
[check] rustc 0 <host> -> rustc 1 <host>
[check] rustc 0 <host> -> cranelift 1 <host>
[check] rustc 0 <host> -> gcc 1 <host>
");
}
#[test]
fn check_miri_no_explicit_stage() {
let ctx = TestCtx::new();