Support non-stage0 check

This commit is contained in:
Mark Rousskov 2021-01-15 21:43:23 -05:00
parent fcbd305ee9
commit 8b702e02c0
2 changed files with 23 additions and 13 deletions

View File

@ -73,7 +73,7 @@ fn make_run(run: RunConfig<'_>) {
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
let target = self.target; let target = self.target;
let compiler = builder.compiler(0, builder.config.build); let compiler = builder.compiler(builder.top_stage, builder.config.build);
let mut cargo = builder.cargo( let mut cargo = builder.cargo(
compiler, compiler,
@ -94,9 +94,13 @@ fn run(self, builder: &Builder<'_>) {
true, true,
); );
let libdir = builder.sysroot_libdir(compiler, target); // We skip populating the sysroot in non-zero stage because that'll lead
let hostdir = builder.sysroot_libdir(compiler, compiler.host); // to rlib/rmeta conflicts if std gets built during this session.
add_to_sysroot(&builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target)); if compiler.stage == 0 {
let libdir = builder.sysroot_libdir(compiler, target);
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
add_to_sysroot(&builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
}
// Then run cargo again, once we've put the rmeta files for the library // Then run cargo again, once we've put the rmeta files for the library
// crates into the sysroot. This is needed because e.g., core's tests // crates into the sysroot. This is needed because e.g., core's tests
@ -163,10 +167,20 @@ fn make_run(run: RunConfig<'_>) {
/// the `compiler` targeting the `target` architecture. The artifacts /// the `compiler` targeting the `target` architecture. The artifacts
/// created will also be linked into the sysroot directory. /// created will also be linked into the sysroot directory.
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
let compiler = builder.compiler(0, builder.config.build); let compiler = builder.compiler(builder.top_stage, builder.config.build);
let target = self.target; let target = self.target;
builder.ensure(Std { target }); if compiler.stage != 0 {
// If we're not in stage 0, then we won't have a std from the beta
// compiler around. That means we need to make sure there's one in
// the sysroot for the compiler to find. Otherwise, we're going to
// fail when building crates that need to generate code (e.g., build
// scripts and their dependencies).
builder.ensure(crate::compile::Std { target: compiler.host, compiler });
builder.ensure(crate::compile::Std { target, compiler });
} else {
builder.ensure(Std { target });
}
let mut cargo = builder.cargo( let mut cargo = builder.cargo(
compiler, compiler,
@ -225,7 +239,7 @@ fn make_run(run: RunConfig<'_>) {
} }
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
let compiler = builder.compiler(0, builder.config.build); let compiler = builder.compiler(builder.top_stage, builder.config.build);
let target = self.target; let target = self.target;
let backend = self.backend; let backend = self.backend;
@ -280,7 +294,7 @@ fn make_run(run: RunConfig<'_>) {
} }
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
let compiler = builder.compiler(0, builder.config.build); let compiler = builder.compiler(builder.top_stage, builder.config.build);
let target = self.target; let target = self.target;
builder.ensure(Rustc { target }); builder.ensure(Rustc { target });

View File

@ -614,14 +614,10 @@ pub fn parse(args: &[String]) -> Flags {
}; };
if let Subcommand::Check { .. } = &cmd { if let Subcommand::Check { .. } = &cmd {
if matches.opt_str("stage").is_some() {
println!("--stage not supported for x.py check, always treated as stage 0");
process::exit(1);
}
if matches.opt_str("keep-stage").is_some() if matches.opt_str("keep-stage").is_some()
|| matches.opt_str("keep-stage-std").is_some() || matches.opt_str("keep-stage-std").is_some()
{ {
println!("--keep-stage not supported for x.py check, only one stage available"); println!("--keep-stage not yet supported for x.py check");
process::exit(1); process::exit(1);
} }
} }