Skip to content

Add bootstrap check snapshot tests #143316

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

Merged
merged 8 commits into from
Jul 3, 2025
Merged
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
26 changes: 25 additions & 1 deletion src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::core::build_steps::compile::{
};
use crate::core::build_steps::tool::{COMPILETEST_ALLOW_FEATURES, SourceType, prepare_tool_cargo};
use crate::core::builder::{
self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, crate_description,
self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata, crate_description,
};
use crate::core::config::TargetSelection;
use crate::utils::build_stamp::{self, BuildStamp};
Expand Down Expand Up @@ -167,6 +167,10 @@ impl Step for Std {
let _guard = builder.msg_check("library test/bench/example targets", target, Some(stage));
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::check("std", self.target))
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -258,6 +262,10 @@ impl Step for Rustc {
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
add_to_sysroot(builder, &libdir, &hostdir, &stamp);
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::check("rustc", self.target))
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -315,6 +323,10 @@ impl Step for CodegenBackend {

run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::check(self.backend, self.target))
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -373,6 +385,10 @@ impl Step for RustAnalyzer {
let _guard = builder.msg_check("rust-analyzer artifacts", target, None);
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::check("rust-analyzer", self.target))
}
}

/// Compiletest is implicitly "checked" when it gets built in order to run tests,
Expand Down Expand Up @@ -432,6 +448,10 @@ impl Step for Compiletest {
let _guard = builder.msg_check("compiletest artifacts", self.target, None);
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::check("compiletest", self.target))
}
}

macro_rules! tool_check_step {
Expand Down Expand Up @@ -467,6 +487,10 @@ macro_rules! tool_check_step {
let Self { target } = self;
run_tool_check_step(builder, target, stringify!($name), $path);
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::check(stringify!($name), self.target))
}
}
}
}
Expand Down
12 changes: 2 additions & 10 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,7 @@ impl Step for Std {
}

fn metadata(&self) -> Option<StepMetadata> {
Some(
StepMetadata::build("std", self.target)
.built_by(self.compiler)
.stage(self.compiler.stage),
)
Some(StepMetadata::build("std", self.target).built_by(self.compiler))
}
}

Expand Down Expand Up @@ -1186,11 +1182,7 @@ impl Step for Rustc {
}

fn metadata(&self) -> Option<StepMetadata> {
Some(
StepMetadata::build("rustc", self.target)
.built_by(self.build_compiler)
.stage(self.build_compiler.stage + 1),
)
Some(StepMetadata::build("rustc", self.target).built_by(self.build_compiler))
}
}

Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,6 @@ macro_rules! tool_extended {
Some(
StepMetadata::build($tool_name, self.target)
.built_by(self.compiler.with_stage(self.compiler.stage.saturating_sub(1)))
.stage(self.compiler.stage)
)
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ impl StepMetadata {
Self::new(name, target, Kind::Build)
}

pub fn check(name: &'static str, target: TargetSelection) -> Self {
Self::new(name, target, Kind::Check)
}

pub fn doc(name: &'static str, target: TargetSelection) -> Self {
Self::new(name, target, Kind::Doc)
}
Expand All @@ -178,6 +182,14 @@ impl StepMetadata {
self.stage = Some(stage);
self
}

pub fn get_stage(&self) -> Option<u32> {
self.stage.or(self
.built_by
// For std, its stage corresponds to the stage of the compiler that builds it.
// For everything else, a stage N things gets built by a stage N-1 compiler.
.map(|compiler| if self.name == "std" { compiler.stage } else { compiler.stage + 1 }))
}
}

pub struct RunConfig<'a> {
Expand Down
Loading
Loading