Skip to content

Commit df8102f

Browse files
committed
Auto merge of #142002 - onur-ozkan:follow-ups2, r=jieyouxu
redesign stage 0 std follow-ups part2 Fixes three bugs: 1. `x check` fails when run on rustdoc without `download-rustc` enabled. (1st commit) 2. `x check` fails when run on the compiler with `download-rustc` enabled. (2nd commit) 3. `x test library` fails with `download-rustc` enabled. (3rd commit) Fixes #142018 (case 1) Fixes #141983 (case 3)
2 parents 61413ae + 7af12a1 commit df8102f

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ pub struct Std {
2828
/// passing `Builder::kind` to cargo invocations would run clippy on the entire compiler and library,
2929
/// which is not useful if we only want to lint a few crates with specific rules.
3030
override_build_kind: Option<Kind>,
31+
/// Never use this from outside calls. It is intended for internal use only within `check::Std::make_run`
32+
/// and `check::Std::run`.
33+
custom_stage: Option<u32>,
3134
}
3235

3336
impl Std {
3437
const CRATE_OR_DEPS: &[&str] = &["sysroot", "coretests", "alloctests"];
3538

3639
pub fn new(target: TargetSelection) -> Self {
37-
Self { target, crates: vec![], override_build_kind: None }
40+
Self { target, crates: vec![], override_build_kind: None, custom_stage: None }
3841
}
3942

4043
pub fn build_kind(mut self, kind: Option<Kind>) -> Self {
@@ -48,34 +51,35 @@ impl Step for Std {
4851
const DEFAULT: bool = true;
4952

5053
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
51-
let builder = run.builder;
52-
let stage = if builder.config.is_explicit_stage() || builder.top_stage >= 1 {
53-
builder.top_stage
54-
} else {
55-
1
56-
};
57-
5854
let mut run = run;
5955
for c in Std::CRATE_OR_DEPS {
6056
run = run.crate_or_deps(c);
6157
}
6258

63-
run.path("library").default_condition(stage != 0)
59+
run.path("library")
6460
}
6561

6662
fn make_run(run: RunConfig<'_>) {
6763
let crates = std_crates_for_run_make(&run);
68-
run.builder.ensure(Std { target: run.target, crates, override_build_kind: None });
64+
65+
let stage = if run.builder.config.is_explicit_stage() || run.builder.top_stage >= 1 {
66+
run.builder.top_stage
67+
} else {
68+
1
69+
};
70+
71+
run.builder.ensure(Std {
72+
target: run.target,
73+
crates,
74+
override_build_kind: None,
75+
custom_stage: Some(stage),
76+
});
6977
}
7078

7179
fn run(self, builder: &Builder<'_>) {
7280
builder.require_submodule("library/stdarch", None);
7381

74-
let stage = if builder.config.is_explicit_stage() || builder.top_stage >= 1 {
75-
builder.top_stage
76-
} else {
77-
1
78-
};
82+
let stage = self.custom_stage.unwrap_or(builder.top_stage);
7983

8084
let target = self.target;
8185
let compiler = builder.compiler(stage, builder.config.build);

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,16 +2707,6 @@ impl Step for Crate {
27072707
.arg(builder.src.join("library/sysroot/Cargo.toml"));
27082708
} else {
27092709
compile::std_cargo(builder, target, compiler.stage, &mut cargo);
2710-
// `std_cargo` actually does the wrong thing: it passes `--sysroot build/host/stage2`,
2711-
// but we want to use the force-recompile std we just built in `build/host/stage2-test-sysroot`.
2712-
// Override it.
2713-
if builder.download_rustc() && compiler.stage > 0 {
2714-
let sysroot = builder
2715-
.out
2716-
.join(compiler.host)
2717-
.join(format!("stage{}-test-sysroot", compiler.stage));
2718-
cargo.env("RUSTC_SYSROOT", sysroot);
2719-
}
27202710
}
27212711
}
27222712
Mode::Rustc => {

src/bootstrap/src/core/builder/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,6 @@ impl<'a> Builder<'a> {
945945
clippy::CI,
946946
),
947947
Kind::Check | Kind::Fix => describe!(
948-
check::Std,
949948
check::Rustc,
950949
check::Rustdoc,
951950
check::CodegenBackend,
@@ -961,6 +960,13 @@ impl<'a> Builder<'a> {
961960
check::Compiletest,
962961
check::FeaturesStatusDump,
963962
check::CoverageDump,
963+
// This has special staging logic, it may run on stage 1 while others run on stage 0.
964+
// It takes quite some time to build stage 1, so put this at the end.
965+
//
966+
// FIXME: This also helps bootstrap to not interfere with stage 0 builds. We should probably fix
967+
// that issue somewhere else, but we still want to keep `check::Std` at the end so that the
968+
// quicker steps run before this.
969+
check::Std,
964970
),
965971
Kind::Test => describe!(
966972
crate::core::build_steps::toolstate::ToolStateCheck,

0 commit comments

Comments
 (0)