Auto merge of #146076 - Kobzol:bootstrap-compiletest, r=jieyouxu

Consolidate staging for compiletest steps in bootstrap

This PR finishes the initial pass of refactorings that fixed up staging of various bootstrap steps after the stage0 redesign. Now the *real* refactorings can begin =D

It fixes the unnecessary stage2 build of cargo for run-make tests (https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/run-make.20cargo.20staging/with/536662651), and also consolidates staging of messages printed by bootstrap for test steps (`Testing stageN...` etc.).

r? `@jieyouxu`
This commit is contained in:
bors 2025-09-02 19:32:29 +00:00
commit 51ff895062
3 changed files with 279 additions and 222 deletions

View file

@ -96,7 +96,7 @@ impl Step for CrateBootstrap {
);
let crate_name = path.rsplit_once('/').unwrap().1;
run_cargo_test(cargo, &[], &[], crate_name, bootstrap_host, builder, Mode::ToolBootstrap);
run_cargo_test(cargo, &[], &[], crate_name, bootstrap_host, builder);
}
fn metadata(&self) -> Option<StepMetadata> {
@ -153,15 +153,7 @@ You can skip linkcheck with --skip src/tools/linkchecker"
SourceType::InTree,
&[],
);
run_cargo_test(
cargo,
&[],
&[],
"linkchecker self tests",
bootstrap_host,
builder,
Mode::ToolBootstrap,
);
run_cargo_test(cargo, &[], &[], "linkchecker self tests", bootstrap_host, builder);
if builder.doc_tests == DocTests::No {
return;
@ -174,7 +166,7 @@ You can skip linkcheck with --skip src/tools/linkchecker"
let linkchecker = builder.tool_cmd(Tool::Linkchecker);
// Run the linkchecker.
let _guard = builder.msg(Kind::Test, "Linkcheck", None, compiler, bootstrap_host);
let _guard = builder.msg_test("Linkcheck", bootstrap_host, 1);
let _time = helpers::timeit(builder);
linkchecker.delay_failure().arg(builder.out.join(host).join("doc")).run(builder);
}
@ -482,7 +474,7 @@ impl Step for RustAnalyzer {
cargo.env("SKIP_SLOW_TESTS", "1");
cargo.add_rustc_lib_path(builder);
run_cargo_test(cargo, &[], &[], "rust-analyzer", host, builder, Mode::ToolRustc);
run_cargo_test(cargo, &[], &[], "rust-analyzer", host, builder);
}
fn metadata(&self) -> Option<StepMetadata> {
@ -540,7 +532,7 @@ impl Step for Rustfmt {
cargo.add_rustc_lib_path(builder);
run_cargo_test(cargo, &[], &[], "rustfmt", target, builder, Mode::ToolRustc);
run_cargo_test(cargo, &[], &[], "rustfmt", target, builder);
}
fn metadata(&self) -> Option<StepMetadata> {
@ -679,8 +671,7 @@ impl Step for Miri {
cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg());
{
let _guard =
builder.msg(Kind::Test, "miri", Mode::ToolRustc, miri.build_compiler, target);
let _guard = builder.msg_test("miri", target, target_compiler.stage);
let _time = helpers::timeit(builder);
cargo.run(builder);
}
@ -696,13 +687,8 @@ impl Step for Miri {
cargo.args(["tests/pass", "tests/panic"]);
{
let _guard = builder.msg(
Kind::Test,
"miri (mir-opt-level 4)",
Mode::ToolRustc,
miri.build_compiler,
target,
);
let _guard =
builder.msg_test("miri (mir-opt-level 4)", target, target_compiler.stage);
let _time = helpers::timeit(builder);
cargo.run(builder);
}
@ -772,8 +758,7 @@ impl Step for CargoMiri {
// Finally, run everything.
let mut cargo = BootstrapCommand::from(cargo);
{
let _guard =
builder.msg(Kind::Test, "cargo-miri", Mode::ToolRustc, (host, stage), target);
let _guard = builder.msg_test("cargo-miri", target, stage);
let _time = helpers::timeit(builder);
cargo.run(builder);
}
@ -833,7 +818,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
cargo.env("TEST_RUSTC", builder.rustc(compiler));
cargo.allow_features(COMPILETEST_ALLOW_FEATURES);
run_cargo_test(cargo, &[], &[], "compiletest self test", host, builder, Mode::ToolStd);
run_cargo_test(cargo, &[], &[], "compiletest self test", host, builder);
}
}
@ -916,7 +901,7 @@ impl Step for Clippy {
cargo.add_rustc_lib_path(builder);
let cargo = prepare_cargo_test(cargo, &[], &[], target, builder);
let _guard = builder.msg(Kind::Test, "clippy", Mode::ToolRustc, build_compiler, target);
let _guard = builder.msg_test("clippy", target, target_compiler.stage);
// Clippy reports errors if it blessed the outputs
if cargo.allow_failure().run(builder) {
@ -1046,8 +1031,7 @@ impl Step for RustdocJSStd {
self.target,
DocumentationFormat::Html,
));
let _guard =
builder.msg(Kind::Test, "rustdoc-js-std", None, self.build_compiler, self.target);
let _guard = builder.msg_test("rustdoc-js-std", self.target, self.build_compiler.stage);
command.run(builder);
}
@ -1079,7 +1063,7 @@ impl Step for RustdocJSNotStd {
fn run(self, builder: &Builder<'_>) {
builder.ensure(Compiletest {
compiler: self.compiler,
test_compiler: self.compiler,
target: self.target,
mode: "rustdoc-js",
suite: "rustdoc-js",
@ -1200,7 +1184,7 @@ impl Step for RustdocGUI {
}
let _time = helpers::timeit(builder);
let _guard = builder.msg_test("rustdoc-gui", (self.target, self.test_compiler.stage));
let _guard = builder.msg_test("rustdoc-gui", self.target, self.test_compiler.stage);
try_run_tests(builder, &mut cmd, true);
}
@ -1359,15 +1343,7 @@ impl Step for CrateRunMakeSupport {
&[],
);
cargo.allow_features("test");
run_cargo_test(
cargo,
&[],
&[],
"run-make-support self test",
host,
builder,
Mode::ToolBootstrap,
);
run_cargo_test(cargo, &[], &[], "run-make-support self test", host, builder);
}
}
@ -1404,15 +1380,7 @@ impl Step for CrateBuildHelper {
&[],
);
cargo.allow_features("test");
run_cargo_test(
cargo,
&[],
&[],
"build_helper self test",
host,
builder,
Mode::ToolBootstrap,
);
run_cargo_test(cargo, &[], &[], "build_helper self test", host, builder);
}
}
@ -1437,8 +1405,8 @@ macro_rules! test {
$( #[$attr] )*
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct $name {
pub compiler: Compiler,
pub target: TargetSelection,
test_compiler: Compiler,
target: TargetSelection,
}
impl Step for $name {
@ -1456,14 +1424,14 @@ macro_rules! test {
}
fn make_run(run: RunConfig<'_>) {
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
let test_compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
run.builder.ensure($name { compiler, target: run.target });
run.builder.ensure($name { test_compiler, target: run.target });
}
fn run(self, builder: &Builder<'_>) {
builder.ensure(Compiletest {
compiler: self.compiler,
test_compiler: self.test_compiler,
target: self.target,
mode: $mode,
suite: $suite,
@ -1476,12 +1444,6 @@ macro_rules! test {
}),
})
}
fn metadata(&self) -> Option<StepMetadata> {
Some(
StepMetadata::test(stringify!($name), self.target)
)
}
}
};
}
@ -1650,7 +1612,7 @@ impl Step for Coverage {
// Like other compiletest suite test steps, delegate to an internal
// compiletest task to actually run the tests.
builder.ensure(Compiletest {
compiler,
test_compiler: compiler,
target,
mode,
suite: Self::SUITE,
@ -1691,7 +1653,7 @@ impl Step for MirOpt {
fn run(self, builder: &Builder<'_>) {
let run = |target| {
builder.ensure(Compiletest {
compiler: self.compiler,
test_compiler: self.compiler,
target,
mode: "mir-opt",
suite: "mir-opt",
@ -1726,9 +1688,15 @@ impl Step for MirOpt {
}
}
/// Executes the `compiletest` tool to run a suite of tests.
///
/// Compiles all tests with `test_compiler` for `target` with the specified
/// compiletest `mode` and `suite` arguments. For example `mode` can be
/// "mir-opt" and `suite` can be something like "debuginfo".
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
struct Compiletest {
compiler: Compiler,
/// The compiler that we're testing.
test_compiler: Compiler,
target: TargetSelection,
mode: &'static str,
suite: &'static str,
@ -1743,11 +1711,6 @@ impl Step for Compiletest {
run.never()
}
/// Executes the `compiletest` tool to run a suite of tests.
///
/// Compiles all tests with `compiler` for `target` with the specified
/// compiletest `mode` and `suite` arguments. For example `mode` can be
/// "run-pass" or `suite` can be something like `debuginfo`.
fn run(self, builder: &Builder<'_>) {
if builder.doc_tests == DocTests::Only {
return;
@ -1762,7 +1725,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
crate::exit!(1);
}
let mut compiler = self.compiler;
let mut test_compiler = self.test_compiler;
let target = self.target;
let mode = self.mode;
let suite = self.suite;
@ -1782,30 +1745,30 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
// NOTE: Only stage 1 is special cased because we need the rustc_private artifacts to match the
// running compiler in stage 2 when plugins run.
let query_compiler;
let (stage, stage_id) = if suite == "ui-fulldeps" && compiler.stage == 1 {
let (stage, stage_id) = if suite == "ui-fulldeps" && test_compiler.stage == 1 {
// Even when using the stage 0 compiler, we also need to provide the stage 1 compiler
// so that compiletest can query it for target information.
query_compiler = Some(compiler);
query_compiler = Some(test_compiler);
// At stage 0 (stage - 1) we are using the stage0 compiler. Using `self.target` can lead
// finding an incorrect compiler path on cross-targets, as the stage 0 is always equal to
// `build.build` in the configuration.
let build = builder.build.host_target;
compiler = builder.compiler(compiler.stage - 1, build);
let test_stage = compiler.stage + 1;
test_compiler = builder.compiler(test_compiler.stage - 1, build);
let test_stage = test_compiler.stage + 1;
(test_stage, format!("stage{test_stage}-{build}"))
} else {
query_compiler = None;
let stage = compiler.stage;
let stage = test_compiler.stage;
(stage, format!("stage{stage}-{target}"))
};
if suite.ends_with("fulldeps") {
builder.ensure(compile::Rustc::new(compiler, target));
builder.ensure(compile::Rustc::new(test_compiler, target));
}
if suite == "debuginfo" {
builder.ensure(dist::DebuggerScripts {
sysroot: builder.sysroot(compiler).to_path_buf(),
sysroot: builder.sysroot(test_compiler).to_path_buf(),
target,
});
}
@ -1815,20 +1778,22 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
// ensure that `libproc_macro` is available on the host.
if suite == "mir-opt" {
builder.ensure(compile::Std::new(compiler, compiler.host).is_for_mir_opt_tests(true));
builder.ensure(
compile::Std::new(test_compiler, test_compiler.host).is_for_mir_opt_tests(true),
);
} else {
builder.std(compiler, compiler.host);
builder.std(test_compiler, test_compiler.host);
}
let mut cmd = builder.tool_cmd(Tool::Compiletest);
if suite == "mir-opt" {
builder.ensure(compile::Std::new(compiler, target).is_for_mir_opt_tests(true));
builder.ensure(compile::Std::new(test_compiler, target).is_for_mir_opt_tests(true));
} else {
builder.std(compiler, target);
builder.std(test_compiler, target);
}
builder.ensure(RemoteCopyLibs { build_compiler: compiler, target });
builder.ensure(RemoteCopyLibs { build_compiler: test_compiler, target });
// compiletest currently has... a lot of arguments, so let's just pass all
// of them!
@ -1836,9 +1801,9 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--stage").arg(stage.to_string());
cmd.arg("--stage-id").arg(stage_id);
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
cmd.arg("--run-lib-path").arg(builder.sysroot_target_libdir(compiler, target));
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(test_compiler));
cmd.arg("--run-lib-path").arg(builder.sysroot_target_libdir(test_compiler, target));
cmd.arg("--rustc-path").arg(builder.rustc(test_compiler));
if let Some(query_compiler) = query_compiler {
cmd.arg("--query-rustc-path").arg(builder.rustc(query_compiler));
}
@ -1851,18 +1816,23 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
let is_rustdoc = suite == "rustdoc-ui" || suite == "rustdoc-js";
if mode == "run-make" {
let cargo_path = if builder.top_stage == 0 {
let cargo_path = if test_compiler.stage == 0 {
// If we're using `--stage 0`, we should provide the bootstrap cargo.
builder.initial_cargo.clone()
} else {
builder.ensure(tool::Cargo::from_build_compiler(compiler, compiler.host)).tool_path
builder
.ensure(tool::Cargo::from_build_compiler(
builder.compiler(test_compiler.stage - 1, test_compiler.host),
test_compiler.host,
))
.tool_path
};
cmd.arg("--cargo-path").arg(cargo_path);
// We need to pass the compiler that was used to compile run-make-support,
// because we have to use the same compiler to compile rmake.rs recipes.
let stage0_rustc_path = builder.compiler(0, compiler.host);
let stage0_rustc_path = builder.compiler(0, test_compiler.host);
cmd.arg("--stage0-rustc-path").arg(builder.rustc(stage0_rustc_path));
}
@ -1874,12 +1844,12 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
|| mode == "rustdoc-json"
|| suite == "coverage-run-rustdoc"
{
cmd.arg("--rustdoc-path").arg(builder.rustdoc_for_compiler(compiler));
cmd.arg("--rustdoc-path").arg(builder.rustdoc_for_compiler(test_compiler));
}
if mode == "rustdoc-json" {
// Use the stage0 compiler for jsondocck
let json_compiler = compiler.with_stage(0);
let json_compiler = builder.compiler(0, builder.host_target);
cmd.arg("--jsondocck-path")
.arg(builder.ensure(tool::JsonDocCk { compiler: json_compiler, target }).tool_path);
cmd.arg("--jsondoclint-path").arg(
@ -1899,14 +1869,16 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
// directory immediately under the root build directory, and the test-suite-specific build
// directory.
cmd.arg("--build-root").arg(&builder.out);
cmd.arg("--build-test-suite-root").arg(testdir(builder, compiler.host).join(suite));
cmd.arg("--build-test-suite-root").arg(testdir(builder, test_compiler.host).join(suite));
// When top stage is 0, that means that we're testing an externally provided compiler.
// In that case we need to use its specific sysroot for tests to pass.
// Note: DO NOT check if test_compiler.stage is 0, because the test compiler can be stage 0
// even if the top stage is 1 (when we run the ui-fulldeps suite).
let sysroot = if builder.top_stage == 0 {
builder.initial_sysroot.clone()
} else {
builder.sysroot(compiler)
builder.sysroot(test_compiler)
};
cmd.arg("--sysroot-base").arg(sysroot);
@ -1914,11 +1886,15 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--suite").arg(suite);
cmd.arg("--mode").arg(mode);
cmd.arg("--target").arg(target.rustc_target_arg());
cmd.arg("--host").arg(&*compiler.host.triple);
cmd.arg("--host").arg(&*test_compiler.host.triple);
cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.host_target));
if let Some(codegen_backend) = builder.config.cmd.test_codegen_backend() {
if !builder.config.enabled_codegen_backends(compiler.host).contains(codegen_backend) {
if !builder
.config
.enabled_codegen_backends(test_compiler.host)
.contains(codegen_backend)
{
eprintln!(
"\
ERROR: No configured backend named `{name}`
@ -1937,7 +1913,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
// Tells compiletest which codegen backend to use.
// It is used to e.g. ignore tests that don't support that codegen backend.
cmd.arg("--default-codegen-backend")
.arg(builder.config.default_codegen_backend(compiler.host).name());
.arg(builder.config.default_codegen_backend(test_compiler.host).name());
}
if builder.build.config.llvm_enzyme {
@ -2017,7 +1993,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
if let Some(linker) = builder.linker(target) {
cmd.arg("--target-linker").arg(linker);
}
if let Some(linker) = builder.linker(compiler.host) {
if let Some(linker) = builder.linker(test_compiler.host) {
cmd.arg("--host-linker").arg(linker);
}
}
@ -2028,16 +2004,18 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
}
let mut hostflags = flags.clone();
hostflags.extend(linker_flags(builder, compiler.host, LldThreads::No));
hostflags.extend(linker_flags(builder, test_compiler.host, LldThreads::No));
let mut targetflags = flags;
// Provide `rust_test_helpers` for both host and target.
if suite == "ui" || suite == "incremental" {
builder.ensure(TestHelpers { target: compiler.host });
builder.ensure(TestHelpers { target: test_compiler.host });
builder.ensure(TestHelpers { target });
hostflags
.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
hostflags.push(format!(
"-Lnative={}",
builder.test_helpers_out(test_compiler.host).display()
));
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
}
@ -2122,7 +2100,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
let mut llvm_components_passed = false;
let mut copts_passed = false;
if builder.config.llvm_enabled(compiler.host) {
if builder.config.llvm_enabled(test_compiler.host) {
let llvm::LlvmResult { host_llvm_config, .. } =
builder.ensure(llvm::Llvm { target: builder.config.host_target });
if !builder.config.dry_run() {
@ -2322,19 +2300,16 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
mode: mode.into(),
compare_mode: None,
target: self.target.triple.to_string(),
host: self.compiler.host.triple.to_string(),
stage: self.compiler.stage,
host: self.test_compiler.host.triple.to_string(),
stage: self.test_compiler.stage,
},
builder,
);
let _group = builder.msg(
Kind::Test,
format!("compiletest suite={suite} mode={mode}"),
// FIXME: compiletest sometimes behaves as ToolStd, we could expose that difference here
Mode::ToolBootstrap,
compiler,
let _group = builder.msg_test(
format!("with compiletest suite={suite} mode={mode}"),
target,
test_compiler.stage,
);
try_run_tests(builder, &mut cmd, false);
@ -2348,20 +2323,27 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
mode: mode.into(),
compare_mode: Some(compare_mode.into()),
target: self.target.triple.to_string(),
host: self.compiler.host.triple.to_string(),
stage: self.compiler.stage,
host: self.test_compiler.host.triple.to_string(),
stage: self.test_compiler.stage,
},
builder,
);
builder.info(&format!(
"Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
suite, mode, compare_mode, &compiler.host, target
suite, mode, compare_mode, &test_compiler.host, target
));
let _time = helpers::timeit(builder);
try_run_tests(builder, &mut cmd, false);
}
}
fn metadata(&self) -> Option<StepMetadata> {
Some(
StepMetadata::test(&format!("compiletest-{}", self.suite), self.target)
.stage(self.test_compiler.stage),
)
}
}
/// Runs the documentation tests for a book in `src/doc` using the `rustdoc` of `test_compiler`.
@ -2471,12 +2453,10 @@ impl BookTest {
}
builder.add_rust_test_threads(&mut rustbook_cmd);
let _guard = builder.msg(
Kind::Test,
let _guard = builder.msg_test(
format_args!("mdbook {}", self.path.display()),
None,
test_compiler,
test_compiler.host,
test_compiler.stage,
);
let _time = helpers::timeit(builder);
let toolstate = if rustbook_cmd.delay_failure().run(builder) {
@ -2494,12 +2474,10 @@ impl BookTest {
builder.std(test_compiler, host);
let _guard = builder.msg(
Kind::Test,
let _guard = builder.msg_test(
format!("book {}", self.name),
None,
(test_compiler.host, test_compiler.stage - 1),
host,
test_compiler.host,
test_compiler.stage,
);
// Do a breadth-first traversal of the `src/doc` directory and just run
@ -2642,13 +2620,7 @@ impl Step for ErrorIndex {
let mut tool = tool::ErrorIndex::command(builder, self.compilers);
tool.arg("markdown").arg(&output);
let guard = builder.msg(
Kind::Test,
"error-index",
None,
self.compilers.build_compiler(),
target_compiler.host,
);
let guard = builder.msg_test("error-index", target_compiler.host, target_compiler.stage);
let _time = helpers::timeit(builder);
tool.run_capture(builder);
drop(guard);
@ -2744,14 +2716,12 @@ fn run_cargo_test<'a>(
description: impl Into<Option<&'a str>>,
target: TargetSelection,
builder: &Builder<'_>,
mode: impl Into<Option<Mode>>,
) -> bool {
let mode = mode.into();
let compiler = cargo.compiler();
let mut cargo = prepare_cargo_test(cargo, libtest_args, crates, target, builder);
let _time = helpers::timeit(builder);
let _group =
description.into().and_then(|what| builder.msg(Kind::Test, what, mode, compiler, target));
description.into().and_then(|what| builder.msg_test(what, target, compiler.stage + 1));
#[cfg(feature = "build-metrics")]
builder.metrics.begin_test_suite(
@ -2978,15 +2948,7 @@ impl Step for Crate {
crates.push("alloctests".to_owned());
}
run_cargo_test(
cargo,
&[],
&crates,
&*crate_description(&self.crates),
target,
builder,
mode,
);
run_cargo_test(cargo, &[], &crates, &*crate_description(&self.crates), target, builder);
}
}
@ -3080,15 +3042,7 @@ impl Step for CrateRustdoc {
dylib_path.insert(0, PathBuf::from(&*libdir));
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
run_cargo_test(
cargo,
&[],
&["rustdoc:0.0.0".to_string()],
"rustdoc",
target,
builder,
Mode::ToolRustc,
);
run_cargo_test(cargo, &[], &["rustdoc:0.0.0".to_string()], "rustdoc", target, builder);
}
}
@ -3147,7 +3101,6 @@ impl Step for CrateRustdocJsonTypes {
"rustdoc-json-types",
target,
builder,
Mode::ToolTarget,
);
}
}
@ -3246,9 +3199,6 @@ impl Step for Distcheck {
.map(|args| args.split(" ").map(|s| s.to_string()).collect::<Vec<String>>())
.unwrap_or_default();
// FIXME: unpack the source tarballs into a directory outside the source checkout, to
// ensure that it cannot access any local state
// Also ensure that it doesn't use download-ci-llvm
command("tar")
.arg("-xf")
.arg(plain_src_tarball.tarball())
@ -3308,8 +3258,6 @@ impl Step for Bootstrap {
fn run(self, builder: &Builder<'_>) {
let host = builder.config.host_target;
let build_compiler = builder.compiler(0, host);
let _guard =
builder.msg(Kind::Test, "bootstrap", Mode::ToolBootstrap, build_compiler, host);
// Some tests require cargo submodule to be present.
builder.build.require_submodule("src/tools/cargo", None);
@ -3348,7 +3296,7 @@ impl Step for Bootstrap {
// bootstrap tests are racy on directory creation so just run them one at a time.
// Since there's not many this shouldn't be a problem.
run_cargo_test(cargo, &["--test-threads=1"], &[], None, host, builder, Mode::ToolBootstrap);
run_cargo_test(cargo, &["--test-threads=1"], &[], None, host, builder);
}
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@ -3408,7 +3356,11 @@ impl Step for TierCheck {
cargo.arg("--verbose");
}
let _guard = builder.msg_test("platform support check", self.test_compiler);
let _guard = builder.msg_test(
"platform support check",
self.test_compiler.host,
self.test_compiler.stage,
);
BootstrapCommand::from(cargo).delay_failure().run(builder);
}
@ -3487,9 +3439,8 @@ impl Step for RustInstaller {
&[],
);
let _guard =
builder.msg(Kind::Test, "rust-installer", None, build_compiler, bootstrap_host);
run_cargo_test(cargo, &[], &[], None, bootstrap_host, builder, Mode::ToolBootstrap);
let _guard = builder.msg_test("rust-installer", bootstrap_host, 1);
run_cargo_test(cargo, &[], &[], None, bootstrap_host, builder);
// We currently don't support running the test.sh script outside linux(?) environments.
// Eventually this should likely migrate to #[test]s in rust-installer proper rather than a
@ -3660,7 +3611,11 @@ impl Step for CodegenCranelift {
// Avoid incremental cache issues when changing rustc
cargo.env("CARGO_BUILD_INCREMENTAL", "false");
let _guard = builder.msg_test("rustc_codegen_cranelift", target_compiler);
let _guard = builder.msg_test(
"rustc_codegen_cranelift",
target_compiler.host,
target_compiler.stage,
);
// FIXME handle vendoring for source tarballs before removing the --skip-test below
let download_dir = builder.out.join("cg_clif_download");
@ -3755,7 +3710,11 @@ impl Step for CodegenGCC {
.extra_rust_args(&["-Csymbol-mangling-version=v0", "-Cpanic=abort"]),
);
let _guard = builder.msg_test("rustc_codegen_gcc", compilers.build_compiler());
let _guard = builder.msg_test(
"rustc_codegen_gcc",
compilers.target(),
compilers.target_compiler().stage,
);
let mut cargo = builder::Cargo::new(
builder,
@ -3860,7 +3819,7 @@ impl Step for TestFloatParse {
);
cargo_test.allow_features(TEST_FLOAT_PARSE_ALLOW_FEATURES);
run_cargo_test(cargo_test, &[], &[], "test-float-parse", target, builder, Mode::ToolStd);
run_cargo_test(cargo_test, &[], &[], "test-float-parse", target, builder);
// Run the actual parse tests.
let mut cargo_run = tool::prepare_tool_cargo(

View file

@ -2062,20 +2062,23 @@ mod snapshot {
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 0 <host> -> Compiletest 1 <host>
[test] Ui <host>
[test] Crashes <host>
[test] compiletest-ui 1 <host>
[test] compiletest-crashes 1 <host>
[build] rustc 0 <host> -> CoverageDump 1 <host>
[test] compiletest-coverage 1 <host>
[test] compiletest-coverage 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[test] CodegenLlvm <host>
[test] CodegenUnits <host>
[test] AssemblyLlvm <host>
[test] Incremental <host>
[test] Debuginfo <host>
[test] UiFullDeps <host>
[test] compiletest-mir-opt 1 <host>
[test] compiletest-codegen-llvm 1 <host>
[test] compiletest-codegen-units 1 <host>
[test] compiletest-assembly-llvm 1 <host>
[test] compiletest-incremental 1 <host>
[test] compiletest-debuginfo 1 <host>
[test] compiletest-ui-fulldeps 1 <host>
[build] rustdoc 1 <host>
[test] Rustdoc <host>
[test] CoverageRunRustdoc <host>
[test] Pretty <host>
[test] compiletest-rustdoc 1 <host>
[test] compiletest-coverage-run-rustdoc 1 <host>
[test] compiletest-pretty 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 0 <host> -> std 0 <host>
[test] rustc 0 <host> -> CrateLibrustc 1 <host>
@ -2113,16 +2116,107 @@ mod snapshot {
[test] rustc 0 <host> -> rust-analyzer 1 <host>
[build] rustc 0 <host> -> RustdocTheme 1 <host>
[test] rustdoc-theme 1 <host>
[test] RustdocUi <host>
[test] compiletest-rustdoc-ui 1 <host>
[build] rustc 0 <host> -> JsonDocCk 1 <host>
[build] rustc 0 <host> -> JsonDocLint 1 <host>
[test] RustdocJson <host>
[test] compiletest-rustdoc-json 1 <host>
[doc] rustc 0 <host> -> rustc 1 <host>
[build] rustc 0 <host> -> HtmlChecker 1 <host>
[test] html-check <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 0 <host> -> cargo 1 <host>
[test] compiletest-run-make 1 <host>
");
}
#[test]
fn test_compiletest_suites_stage1() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("test")
.args(&["ui", "ui-fulldeps", "run-make", "rustdoc", "rustdoc-gui", "incremental"])
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 0 <host> -> Compiletest 1 <host>
[test] compiletest-ui 1 <host>
[test] compiletest-ui-fulldeps 1 <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 0 <host> -> cargo 1 <host>
[build] rustdoc 1 <host>
[test] compiletest-run-make 1 <host>
[test] compiletest-rustdoc 1 <host>
[build] rustc 0 <host> -> RustdocGUITest 1 <host>
[test] rustdoc-gui 1 <host>
[test] compiletest-incremental 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
");
}
#[test]
fn test_compiletest_suites_stage2() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("test")
.args(&["ui", "ui-fulldeps", "run-make", "rustdoc", "rustdoc-gui", "incremental"])
.stage(2)
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> Compiletest 1 <host>
[test] compiletest-ui 2 <host>
[build] rustc 2 <host> -> rustc 3 <host>
[test] compiletest-ui-fulldeps 2 <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 1 <host> -> cargo 2 <host>
[test] RunMake <host>
[build] rustdoc 2 <host>
[test] compiletest-run-make 2 <host>
[test] compiletest-rustdoc 2 <host>
[build] rustc 0 <host> -> RustdocGUITest 1 <host>
[test] rustdoc-gui 2 <host>
[test] compiletest-incremental 2 <host>
[build] rustdoc 1 <host>
");
}
#[test]
fn test_compiletest_suites_stage2_cross() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("test")
.hosts(&[TEST_TRIPLE_1])
.targets(&[TEST_TRIPLE_1])
.args(&["ui", "ui-fulldeps", "run-make", "rustdoc", "rustdoc-gui", "incremental"])
.stage(2)
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> Compiletest 1 <host>
[build] rustc 1 <host> -> std 1 <target1>
[build] rustc 2 <host> -> std 2 <target1>
[test] compiletest-ui 2 <target1>
[build] llvm <target1>
[build] rustc 2 <host> -> rustc 3 <target1>
[test] compiletest-ui-fulldeps 2 <target1>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 1 <host> -> cargo 2 <host>
[build] rustdoc 2 <host>
[test] compiletest-run-make 2 <target1>
[test] compiletest-rustdoc 2 <target1>
[build] rustc 0 <host> -> RustdocGUITest 1 <host>
[test] rustdoc-gui 2 <target1>
[test] compiletest-incremental 2 <target1>
[build] rustc 1 <host> -> rustc 2 <target1>
[build] rustdoc 1 <host>
[build] rustc 2 <target1> -> std 2 <target1>
[build] rustdoc 2 <target1>
");
}
@ -2142,21 +2236,24 @@ mod snapshot {
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> Compiletest 1 <host>
[test] Ui <host>
[test] Crashes <host>
[test] compiletest-ui 2 <host>
[test] compiletest-crashes 2 <host>
[build] rustc 0 <host> -> CoverageDump 1 <host>
[test] compiletest-coverage 2 <host>
[test] compiletest-coverage 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[test] CodegenLlvm <host>
[test] CodegenUnits <host>
[test] AssemblyLlvm <host>
[test] Incremental <host>
[test] Debuginfo <host>
[test] compiletest-mir-opt 2 <host>
[test] compiletest-codegen-llvm 2 <host>
[test] compiletest-codegen-units 2 <host>
[test] compiletest-assembly-llvm 2 <host>
[test] compiletest-incremental 2 <host>
[test] compiletest-debuginfo 2 <host>
[build] rustc 2 <host> -> rustc 3 <host>
[test] UiFullDeps <host>
[test] compiletest-ui-fulldeps 2 <host>
[build] rustdoc 2 <host>
[test] Rustdoc <host>
[test] CoverageRunRustdoc <host>
[test] Pretty <host>
[test] compiletest-rustdoc 2 <host>
[test] compiletest-coverage-run-rustdoc 2 <host>
[test] compiletest-pretty 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustdoc 1 <host>
@ -2196,16 +2293,16 @@ mod snapshot {
[test] rustc 1 <host> -> lint-docs 2 <host>
[build] rustc 0 <host> -> RustdocTheme 1 <host>
[test] rustdoc-theme 2 <host>
[test] RustdocUi <host>
[test] compiletest-rustdoc-ui 2 <host>
[build] rustc 0 <host> -> JsonDocCk 1 <host>
[build] rustc 0 <host> -> JsonDocLint 1 <host>
[test] RustdocJson <host>
[test] compiletest-rustdoc-json 2 <host>
[doc] rustc 1 <host> -> rustc 2 <host>
[build] rustc 0 <host> -> HtmlChecker 1 <host>
[test] html-check <host>
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
[build] rustc 2 <host> -> cargo 3 <host>
[test] RunMake <host>
[build] rustc 1 <host> -> cargo 2 <host>
[test] compiletest-run-make 2 <host>
");
}
@ -2249,7 +2346,7 @@ mod snapshot {
let steps = ctx.config("test").args(&["--skip", "src/tools/tidy"]).get_steps();
let host = TargetSelection::from_user(&host_target());
steps.assert_contains(StepMetadata::test("RustdocUi", host));
steps.assert_contains(StepMetadata::test("compiletest-rustdoc-ui", host).stage(1));
steps.assert_not_contains(test::Tidy);
}

View file

@ -426,22 +426,22 @@ forward! {
download_rustc() -> bool,
}
/// A mostly temporary helper struct before we can migrate everything in bootstrap to use
/// the concept of a build compiler.
struct HostAndStage {
host: TargetSelection,
/// An alternative way of specifying what target and stage is involved in some bootstrap activity.
/// Ideally using a `Compiler` directly should be preferred.
struct TargetAndStage {
target: TargetSelection,
stage: u32,
}
impl From<(TargetSelection, u32)> for HostAndStage {
fn from((host, stage): (TargetSelection, u32)) -> Self {
Self { host, stage }
impl From<(TargetSelection, u32)> for TargetAndStage {
fn from((target, stage): (TargetSelection, u32)) -> Self {
Self { target, stage }
}
}
impl From<Compiler> for HostAndStage {
impl From<Compiler> for TargetAndStage {
fn from(compiler: Compiler) -> Self {
Self { host: compiler.host, stage: compiler.stage }
Self { target: compiler.host, stage: compiler.stage }
}
}
@ -1109,11 +1109,12 @@ impl Build {
/// Return a `Group` guard for a [`Step`] that:
/// - Performs `action`
/// - If the action is `Kind::Test`, use [`Build::msg_test`] instead.
/// - On `what`
/// - Where `what` possibly corresponds to a `mode`
/// - `action` is performed using the given build compiler (`host_and_stage`).
/// - Since some steps do not use the concept of a build compiler yet, it is also possible
/// to pass the host and stage explicitly.
/// - `action` is performed with/on the given compiler (`target_and_stage`).
/// - Since for some steps it is not possible to pass a single compiler here, it is also
/// possible to pass the host and stage explicitly.
/// - With a given `target`.
///
/// [`Step`]: crate::core::builder::Step
@ -1124,13 +1125,19 @@ impl Build {
action: impl Into<Kind>,
what: impl Display,
mode: impl Into<Option<Mode>>,
host_and_stage: impl Into<HostAndStage>,
target_and_stage: impl Into<TargetAndStage>,
target: impl Into<Option<TargetSelection>>,
) -> Option<gha::Group> {
let host_and_stage = host_and_stage.into();
let target_and_stage = target_and_stage.into();
let action = action.into();
assert!(
action != Kind::Test,
"Please use `Build::msg_test` instead of `Build::msg(Kind::Test)`"
);
let actual_stage = match mode.into() {
// Std has the same stage as the compiler that builds it
Some(Mode::Std) => host_and_stage.stage,
Some(Mode::Std) => target_and_stage.stage,
// Other things have stage corresponding to their build compiler + 1
Some(
Mode::Rustc
@ -1140,18 +1147,18 @@ impl Build {
| Mode::ToolStd
| Mode::ToolRustc,
)
| None => host_and_stage.stage + 1,
| None => target_and_stage.stage + 1,
};
let action = action.into().description();
let action = action.description();
let what = what.to_string();
let msg = |fmt| {
let space = if !what.is_empty() { " " } else { "" };
format!("{action} stage{actual_stage} {what}{space}{fmt}")
};
let msg = if let Some(target) = target.into() {
let build_stage = host_and_stage.stage;
let host = host_and_stage.host;
let build_stage = target_and_stage.stage;
let host = target_and_stage.target;
if host == target {
msg(format_args!("(stage{build_stage} -> stage{actual_stage}, {target})"))
} else {
@ -1163,10 +1170,9 @@ impl Build {
self.group(&msg)
}
/// Return a `Group` guard for a [`Step`] that tests `what` with the given `stage` and `target`
/// (determined by `host_and_stage`).
/// Use this instead of [`Build::msg`] when there is no clear `build_compiler` to be
/// determined.
/// Return a `Group` guard for a [`Step`] that tests `what` with the given `stage` and `target`.
/// Use this instead of [`Build::msg`] for test steps, because for them it is not always clear
/// what exactly is a build compiler.
///
/// [`Step`]: crate::core::builder::Step
#[must_use = "Groups should not be dropped until the Step finishes running"]
@ -1174,11 +1180,11 @@ impl Build {
fn msg_test(
&self,
what: impl Display,
host_and_stage: impl Into<HostAndStage>,
target: TargetSelection,
stage: u32,
) -> Option<gha::Group> {
let HostAndStage { host, stage } = host_and_stage.into();
let action = Kind::Test.description();
let msg = format!("{action} stage{stage} {what} ({host})");
let msg = format!("{action} stage{stage} {what} ({target})");
self.group(&msg)
}
@ -2109,11 +2115,6 @@ impl Compiler {
self.forced_compiler = forced_compiler;
}
pub fn with_stage(mut self, stage: u32) -> Compiler {
self.stage = stage;
self
}
/// Returns `true` if this is a snapshot compiler for `build`'s configuration
pub fn is_snapshot(&self, build: &Build) -> bool {
self.stage == 0 && self.host == build.host_target