Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add x.py check --stage 1 #80952

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,11 @@ impl<'a> Builder<'a> {
// For other crates, however, we know that we've already got a standard
// library up and running, so we can use the normal compiler to compile
// build scripts in that situation.
if mode == Mode::Std {
//
// Note that when we're checking the compiler for any stage other than 0,
// we may not have built the MIR for the standard library, only the check metadata.
// If so, we need to use stage 0 for build scripts still.
if mode == Mode::Std || self.kind == Kind::Check {
cargo
.env("RUSTC_SNAPSHOT", &self.initial_rustc)
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
Expand Down
25 changes: 13 additions & 12 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Step for Std {

fn run(self, builder: &Builder<'_>) {
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(
compiler,
Expand All @@ -73,7 +73,7 @@ impl Step for Std {
);
std_cargo(builder, target, compiler.stage, &mut cargo);

builder.info(&format!("Checking std artifacts ({} -> {})", &compiler.host, target));
builder.info(&format!("Checking stage{} std artifacts ({} -> {})", builder.top_stage, &compiler.host, target));
run_cargo(
builder,
cargo,
Expand Down Expand Up @@ -113,8 +113,8 @@ impl Step for Std {
}

builder.info(&format!(
"Checking std test/bench/example targets ({} -> {})",
&compiler.host, target
"Checking stage{} std test/bench/example targets ({} -> {})",
builder.top_stage, &compiler.host, target
));
run_cargo(
builder,
Expand Down Expand Up @@ -152,7 +152,7 @@ impl Step for Rustc {
/// the `compiler` targeting the `target` architecture. The artifacts
/// created will also be linked into the sysroot directory.
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;

builder.ensure(Std { target });
Expand All @@ -169,14 +169,14 @@ impl Step for Rustc {
cargo.arg("--all-targets");
}

// Explicitly pass -p for all compiler krates -- this will force cargo
// Explicitly pass -p for all compiler crates -- this will force cargo
// to also check the tests/benches/examples for these crates, rather
// than just the leaf crate.
for krate in builder.in_tree_crates("rustc-main", Some(target)) {
cargo.arg("-p").arg(krate.name);
}

builder.info(&format!("Checking compiler artifacts ({} -> {})", &compiler.host, target));
builder.info(&format!("Checking stage{} compiler artifacts ({} -> {})", builder.top_stage, &compiler.host, target));
run_cargo(
builder,
cargo,
Expand Down Expand Up @@ -214,7 +214,7 @@ impl Step for CodegenBackend {
}

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 backend = self.backend;

Expand All @@ -233,8 +233,8 @@ impl Step for CodegenBackend {
rustc_cargo_env(builder, &mut cargo, target);

builder.info(&format!(
"Checking {} artifacts ({} -> {})",
backend, &compiler.host.triple, target.triple
"Checking stage{} {} artifacts ({} -> {})",
builder.top_stage, backend, &compiler.host.triple, target.triple
));

run_cargo(
Expand Down Expand Up @@ -269,7 +269,7 @@ macro_rules! tool_check_step {
}

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;

builder.ensure(Rustc { target });
Expand All @@ -290,7 +290,8 @@ macro_rules! tool_check_step {
}

builder.info(&format!(
"Checking {} artifacts ({} -> {})",
"Checking stage{} {} artifacts ({} -> {})",
builder.top_stage,
stringify!($name).to_lowercase(),
&compiler.host.triple,
target.triple
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ struct Build {
configure_args: Option<Vec<String>>,
local_rebuild: Option<bool>,
print_step_timings: Option<bool>,
check_stage: Option<u32>,
doc_stage: Option<u32>,
build_stage: Option<u32>,
test_stage: Option<u32>,
Expand Down Expand Up @@ -674,6 +675,7 @@ impl Config {

// See https://github.com/rust-lang/compiler-team/issues/326
config.stage = match config.cmd {
Subcommand::Check { .. } => flags.stage.or(build.check_stage).unwrap_or(0),
Subcommand::Doc { .. } => flags.stage.or(build.doc_stage).unwrap_or(0),
Subcommand::Build { .. } => flags.stage.or(build.build_stage).unwrap_or(1),
Subcommand::Test { .. } => flags.stage.or(build.test_stage).unwrap_or(1),
Expand All @@ -683,7 +685,6 @@ impl Config {
// These are all bootstrap tools, which don't depend on the compiler.
// The stage we pass shouldn't matter, but use 0 just in case.
Subcommand::Clean { .. }
| Subcommand::Check { .. }
| Subcommand::Clippy { .. }
| Subcommand::Fix { .. }
| Subcommand::Run { .. }
Expand Down
13 changes: 0 additions & 13 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,19 +613,6 @@ Arguments:
}
};

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()
|| matches.opt_str("keep-stage-std").is_some()
{
println!("--keep-stage not supported for x.py check, only one stage available");
process::exit(1);
}
}

Flags {
verbose: matches.opt_count("verbose"),
stage: matches.opt_str("stage").map(|j| j.parse().expect("`stage` should be a number")),
Expand Down