Skip to content

Commit 9fb8d0d

Browse files
committed
Remove custom_stage override from check::Std and make 1 be the default check stage for it
1 parent 0b2bf9c commit 9fb8d0d

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<'_>) {
@@ -68,40 +58,20 @@ impl Step for Std {
6858

6959
builder.require_submodule("library/stdarch", None);
7060

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

9565
let mut cargo = builder::Cargo::new(
9666
builder,
97-
compiler,
67+
build_compiler,
9868
Mode::Std,
9969
SourceType::InTree,
10070
target,
10171
Kind::Check,
10272
);
10373

104-
std_cargo(builder, target, compiler.stage, &mut cargo);
74+
std_cargo(builder, target, build_compiler.stage, &mut cargo);
10575
if matches!(builder.config.cmd, Subcommand::Fix) {
10676
// By default, cargo tries to fix all targets. Tell it not to fix tests until we've added `test` to the sysroot.
10777
cargo.arg("--lib");
@@ -117,16 +87,9 @@ impl Step for Std {
11787
Some(stage),
11888
);
11989

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

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

13295
// don't check test dependencies if we haven't built libtest
@@ -142,21 +105,14 @@ impl Step for Std {
142105
// Currently only the "libtest" tree of crates does this.
143106
let mut cargo = builder::Cargo::new(
144107
builder,
145-
compiler,
108+
build_compiler,
146109
Mode::Std,
147110
SourceType::InTree,
148111
target,
149112
Kind::Check,
150113
);
151114

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

161117
// Explicitly pass -p for all dependencies krates -- this will force cargo
162118
// to also check the tests/benches/examples for these crates, rather
@@ -165,7 +121,8 @@ impl Step for Std {
165121
cargo.arg("-p").arg(krate);
166122
}
167123

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

0 commit comments

Comments
 (0)