Skip to content

Commit 8b702e0

Browse files
Support non-stage0 check
1 parent fcbd305 commit 8b702e0

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/bootstrap/check.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl Step for Std {
7373

7474
fn run(self, builder: &Builder<'_>) {
7575
let target = self.target;
76-
let compiler = builder.compiler(0, builder.config.build);
76+
let compiler = builder.compiler(builder.top_stage, builder.config.build);
7777

7878
let mut cargo = builder.cargo(
7979
compiler,
@@ -94,9 +94,13 @@ impl Step for Std {
9494
true,
9595
);
9696

97-
let libdir = builder.sysroot_libdir(compiler, target);
98-
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
99-
add_to_sysroot(&builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
97+
// We skip populating the sysroot in non-zero stage because that'll lead
98+
// to rlib/rmeta conflicts if std gets built during this session.
99+
if compiler.stage == 0 {
100+
let libdir = builder.sysroot_libdir(compiler, target);
101+
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
102+
add_to_sysroot(&builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
103+
}
100104

101105
// Then run cargo again, once we've put the rmeta files for the library
102106
// crates into the sysroot. This is needed because e.g., core's tests
@@ -163,10 +167,20 @@ impl Step for Rustc {
163167
/// the `compiler` targeting the `target` architecture. The artifacts
164168
/// created will also be linked into the sysroot directory.
165169
fn run(self, builder: &Builder<'_>) {
166-
let compiler = builder.compiler(0, builder.config.build);
170+
let compiler = builder.compiler(builder.top_stage, builder.config.build);
167171
let target = self.target;
168172

169-
builder.ensure(Std { target });
173+
if compiler.stage != 0 {
174+
// If we're not in stage 0, then we won't have a std from the beta
175+
// compiler around. That means we need to make sure there's one in
176+
// the sysroot for the compiler to find. Otherwise, we're going to
177+
// fail when building crates that need to generate code (e.g., build
178+
// scripts and their dependencies).
179+
builder.ensure(crate::compile::Std { target: compiler.host, compiler });
180+
builder.ensure(crate::compile::Std { target, compiler });
181+
} else {
182+
builder.ensure(Std { target });
183+
}
170184

171185
let mut cargo = builder.cargo(
172186
compiler,
@@ -225,7 +239,7 @@ impl Step for CodegenBackend {
225239
}
226240

227241
fn run(self, builder: &Builder<'_>) {
228-
let compiler = builder.compiler(0, builder.config.build);
242+
let compiler = builder.compiler(builder.top_stage, builder.config.build);
229243
let target = self.target;
230244
let backend = self.backend;
231245

@@ -280,7 +294,7 @@ macro_rules! tool_check_step {
280294
}
281295

282296
fn run(self, builder: &Builder<'_>) {
283-
let compiler = builder.compiler(0, builder.config.build);
297+
let compiler = builder.compiler(builder.top_stage, builder.config.build);
284298
let target = self.target;
285299

286300
builder.ensure(Rustc { target });

src/bootstrap/flags.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,10 @@ Arguments:
614614
};
615615

616616
if let Subcommand::Check { .. } = &cmd {
617-
if matches.opt_str("stage").is_some() {
618-
println!("--stage not supported for x.py check, always treated as stage 0");
619-
process::exit(1);
620-
}
621617
if matches.opt_str("keep-stage").is_some()
622618
|| matches.opt_str("keep-stage-std").is_some()
623619
{
624-
println!("--keep-stage not supported for x.py check, only one stage available");
620+
println!("--keep-stage not yet supported for x.py check");
625621
process::exit(1);
626622
}
627623
}

0 commit comments

Comments
 (0)