Skip to content

Commit 50e5599

Browse files
committed
Remove custom_stage override from check::Std and make 1 be the default check stage for it
1 parent 0aa4ef9 commit 50e5599

File tree

1 file changed

+11
-54
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+11
-54
lines changed

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

Lines changed: 11 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@ pub struct Std {
2020
///
2121
/// [`compile::Rustc`]: crate::core::build_steps::compile::Rustc
2222
crates: Vec<String>,
23-
/// Never use this from outside calls. It is intended for internal use only within `check::Std::make_run`
24-
/// and `check::Std::run`.
25-
custom_stage: Option<u32>,
2623
}
2724

2825
impl Std {
2926
const CRATE_OR_DEPS: &[&str] = &["sysroot", "coretests", "alloctests"];
3027

3128
pub fn new(target: TargetSelection) -> Self {
32-
Self { target, crates: vec![], custom_stage: None }
29+
Self { target, crates: vec![] }
3330
}
3431
}
3532

@@ -48,14 +45,7 @@ impl Step for Std {
4845

4946
fn make_run(run: RunConfig<'_>) {
5047
let crates = std_crates_for_run_make(&run);
51-
52-
let stage = if run.builder.config.is_explicit_stage() || run.builder.top_stage >= 1 {
53-
run.builder.top_stage
54-
} else {
55-
1
56-
};
57-
58-
run.builder.ensure(Std { target: run.target, crates, custom_stage: Some(stage) });
48+
run.builder.ensure(Std { target: run.target, crates });
5949
}
6050

6151
fn run(self, builder: &Builder<'_>) {
@@ -66,40 +56,20 @@ impl Step for Std {
6656
return;
6757
}
6858

69-
let stage = self.custom_stage.unwrap_or(builder.top_stage);
70-
59+
let stage = builder.top_stage;
7160
let target = self.target;
72-
let compiler = builder.compiler(stage, builder.config.host_target);
73-
74-
if stage == 0 {
75-
let mut is_explicitly_called =
76-
builder.paths.iter().any(|p| p.starts_with("library") || p.starts_with("std"));
77-
78-
if !is_explicitly_called {
79-
for c in Std::CRATE_OR_DEPS {
80-
is_explicitly_called = builder.paths.iter().any(|p| p.starts_with(c));
81-
}
82-
}
83-
84-
if is_explicitly_called {
85-
eprintln!("WARNING: stage 0 std is precompiled and does nothing during `x check`.");
86-
}
87-
88-
// Reuse the stage0 libstd
89-
builder.std(compiler, target);
90-
return;
91-
}
61+
let build_compiler = builder.compiler(stage, builder.config.host_target);
9262

9363
let mut cargo = builder::Cargo::new(
9464
builder,
95-
compiler,
65+
build_compiler,
9666
Mode::Std,
9767
SourceType::InTree,
9868
target,
9969
Kind::Check,
10070
);
10171

102-
std_cargo(builder, target, compiler.stage, &mut cargo);
72+
std_cargo(builder, target, build_compiler.stage, &mut cargo);
10373
if matches!(builder.config.cmd, Subcommand::Fix) {
10474
// By default, cargo tries to fix all targets. Tell it not to fix tests until we've added `test` to the sysroot.
10575
cargo.arg("--lib");
@@ -115,16 +85,9 @@ impl Step for Std {
11585
Some(stage),
11686
);
11787

118-
let stamp = build_stamp::libstd_stamp(builder, compiler, target).with_prefix("check");
88+
let stamp = build_stamp::libstd_stamp(builder, build_compiler, target).with_prefix("check");
11989
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
12090

121-
// We skip populating the sysroot in non-zero stage because that'll lead
122-
// to rlib/rmeta conflicts if std gets built during this session.
123-
if compiler.stage == 0 {
124-
let libdir = builder.sysroot_target_libdir(compiler, target);
125-
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
126-
add_to_sysroot(builder, &libdir, &hostdir, &stamp);
127-
}
12891
drop(_guard);
12992

13093
// don't check test dependencies if we haven't built libtest
@@ -140,21 +103,14 @@ impl Step for Std {
140103
// Currently only the "libtest" tree of crates does this.
141104
let mut cargo = builder::Cargo::new(
142105
builder,
143-
compiler,
106+
build_compiler,
144107
Mode::Std,
145108
SourceType::InTree,
146109
target,
147110
Kind::Check,
148111
);
149112

150-
// If we're not in stage 0, tests and examples will fail to compile
151-
// from `core` definitions being loaded from two different `libcore`
152-
// .rmeta and .rlib files.
153-
if compiler.stage == 0 {
154-
cargo.arg("--all-targets");
155-
}
156-
157-
std_cargo(builder, target, compiler.stage, &mut cargo);
113+
std_cargo(builder, target, build_compiler.stage, &mut cargo);
158114

159115
// Explicitly pass -p for all dependencies krates -- this will force cargo
160116
// to also check the tests/benches/examples for these crates, rather
@@ -163,7 +119,8 @@ impl Step for Std {
163119
cargo.arg("-p").arg(krate);
164120
}
165121

166-
let stamp = build_stamp::libstd_stamp(builder, compiler, target).with_prefix("check-test");
122+
let stamp =
123+
build_stamp::libstd_stamp(builder, build_compiler, target).with_prefix("check-test");
167124
let _guard = builder.msg_check("library test/bench/example targets", target, Some(stage));
168125
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
169126
}

0 commit comments

Comments
 (0)