diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index 1e08e8547dc72..4a110b733e14d 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -314,41 +314,31 @@ pub fn prepare_compiler_for_check( } } -/// Checks a single codegen backend. +/// Check the Cranelift codegen backend. #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct CodegenBackend { - pub build_compiler: Compiler, - pub target: TargetSelection, - pub backend: CodegenBackendKind, +pub struct CraneliftCodegenBackend { + build_compiler: Compiler, + target: TargetSelection, } -impl Step for CodegenBackend { +impl Step for CraneliftCodegenBackend { type Output = (); + const IS_HOST: bool = true; const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.paths(&["compiler/rustc_codegen_cranelift", "compiler/rustc_codegen_gcc"]) + run.alias("rustc_codegen_cranelift").alias("cg_clif") } fn make_run(run: RunConfig<'_>) { - // FIXME: only check the backend(s) that were actually selected in run.paths let build_compiler = prepare_compiler_for_check(run.builder, run.target, Mode::Codegen); - for backend in [CodegenBackendKind::Cranelift, CodegenBackendKind::Gcc] { - run.builder.ensure(CodegenBackend { build_compiler, target: run.target, backend }); - } + run.builder.ensure(CraneliftCodegenBackend { build_compiler, target: run.target }); } fn run(self, builder: &Builder<'_>) { - // FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved - if builder.build.config.vendor && self.backend.is_gcc() { - println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled."); - return; - } - let build_compiler = self.build_compiler; let target = self.target; - let backend = self.backend; let mut cargo = builder::Cargo::new( builder, @@ -361,31 +351,104 @@ impl Step for CodegenBackend { cargo .arg("--manifest-path") - .arg(builder.src.join(format!("compiler/{}/Cargo.toml", backend.crate_name()))); + .arg(builder.src.join("compiler/rustc_codegen_cranelift/Cargo.toml")); rustc_cargo_env(builder, &mut cargo, target); let _guard = builder.msg( Kind::Check, - backend.crate_name(), + "rustc_codegen_cranelift", Mode::Codegen, self.build_compiler, target, ); - let stamp = build_stamp::codegen_backend_stamp(builder, build_compiler, target, &backend) - .with_prefix("check"); + let stamp = build_stamp::codegen_backend_stamp( + builder, + build_compiler, + target, + &CodegenBackendKind::Cranelift, + ) + .with_prefix("check"); run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false); } fn metadata(&self) -> Option { Some( - StepMetadata::check(&self.backend.crate_name(), self.target) + StepMetadata::check("rustc_codegen_cranelift", self.target) .built_by(self.build_compiler), ) } } +/// Check the GCC codegen backend. +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct GccCodegenBackend { + build_compiler: Compiler, + target: TargetSelection, +} + +impl Step for GccCodegenBackend { + type Output = (); + + const IS_HOST: bool = true; + const DEFAULT: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.alias("rustc_codegen_gcc").alias("cg_gcc") + } + + fn make_run(run: RunConfig<'_>) { + let build_compiler = prepare_compiler_for_check(run.builder, run.target, Mode::Codegen); + run.builder.ensure(GccCodegenBackend { build_compiler, target: run.target }); + } + + fn run(self, builder: &Builder<'_>) { + // FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved + if builder.build.config.vendor { + println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled."); + return; + } + + let build_compiler = self.build_compiler; + let target = self.target; + + let mut cargo = builder::Cargo::new( + builder, + build_compiler, + Mode::Codegen, + SourceType::InTree, + target, + builder.kind, + ); + + cargo.arg("--manifest-path").arg(builder.src.join("compiler/rustc_codegen_gcc/Cargo.toml")); + rustc_cargo_env(builder, &mut cargo, target); + + let _guard = builder.msg( + Kind::Check, + "rustc_codegen_gcc", + Mode::Codegen, + self.build_compiler, + target, + ); + + let stamp = build_stamp::codegen_backend_stamp( + builder, + build_compiler, + target, + &CodegenBackendKind::Gcc, + ) + .with_prefix("check"); + + run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false); + } + + fn metadata(&self) -> Option { + Some(StepMetadata::check("rustc_codegen_gcc", self.target).built_by(self.build_compiler)) + } +} + macro_rules! tool_check_step { ( $name:ident { diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 6226c81a3fdb7..2b521debd84d1 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1042,7 +1042,8 @@ impl<'a> Builder<'a> { Kind::Check | Kind::Fix => describe!( check::Rustc, check::Rustdoc, - check::CodegenBackend, + check::CraneliftCodegenBackend, + check::GccCodegenBackend, check::Clippy, check::Miri, check::CargoMiri, diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 9ba57542549b5..a9398a654e956 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1514,12 +1514,7 @@ mod snapshot { insta::assert_snapshot!( ctx.config("check") .path("compiler") - .render_steps(), @r" - [check] rustc 0 -> rustc 1 (73 crates) - [check] rustc 0 -> rustc 1 - [check] rustc 0 -> rustc_codegen_cranelift 1 - [check] rustc 0 -> rustc_codegen_gcc 1 - "); + .render_steps(), @"[check] rustc 0 -> rustc 1 (73 crates)"); } #[test] @@ -1545,12 +1540,7 @@ mod snapshot { ctx.config("check") .path("compiler") .stage(1) - .render_steps(), @r" - [check] rustc 0 -> rustc 1 (73 crates) - [check] rustc 0 -> rustc 1 - [check] rustc 0 -> rustc_codegen_cranelift 1 - [check] rustc 0 -> rustc_codegen_gcc 1 - "); + .render_steps(), @"[check] rustc 0 -> rustc 1 (73 crates)"); } #[test] @@ -1565,9 +1555,6 @@ mod snapshot { [build] rustc 0 -> rustc 1 [build] rustc 1 -> std 1 [check] rustc 1 -> rustc 2 (73 crates) - [check] rustc 1 -> rustc 2 - [check] rustc 1 -> rustc_codegen_cranelift 2 - [check] rustc 1 -> rustc_codegen_gcc 2 "); } @@ -1679,12 +1666,7 @@ mod snapshot { ctx.config("check") .paths(&["library", "compiler"]) .args(&args) - .render_steps(), @r" - [check] rustc 0 -> rustc 1 (73 crates) - [check] rustc 0 -> rustc 1 - [check] rustc 0 -> rustc_codegen_cranelift 1 - [check] rustc 0 -> rustc_codegen_gcc 1 - "); + .render_steps(), @"[check] rustc 0 -> rustc 1 (73 crates)"); } #[test] @@ -1768,7 +1750,6 @@ mod snapshot { .render_steps(), @r" [check] rustc 0 -> rustc 1 [check] rustc 0 -> rustc_codegen_cranelift 1 - [check] rustc 0 -> rustc_codegen_gcc 1 "); } @@ -2068,130 +2049,6 @@ mod snapshot { [doc] rustc 1 -> reference (book) 2 "); } - - #[test] - fn clippy_ci() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("ci") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> clippy-driver 1 - [build] rustc 0 -> cargo-clippy 1 - [clippy] rustc 1 -> bootstrap 2 - [clippy] rustc 1 -> std 1 - [clippy] rustc 1 -> rustc 2 - [check] rustc 1 -> rustc 2 - [clippy] rustc 1 -> rustc_codegen_gcc 2 - "); - } - - #[test] - fn clippy_compiler_stage1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("compiler") - .render_steps(), @r" - [build] llvm - [clippy] rustc 0 -> rustc 1 - "); - } - - #[test] - fn clippy_compiler_stage2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("compiler") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> clippy-driver 1 - [build] rustc 0 -> cargo-clippy 1 - [clippy] rustc 1 -> rustc 2 - "); - } - - #[test] - fn clippy_std_stage1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("std") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> clippy-driver 1 - [build] rustc 0 -> cargo-clippy 1 - [clippy] rustc 1 -> std 1 - "); - } - - #[test] - fn clippy_std_stage2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("std") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> clippy-driver 2 - [build] rustc 1 -> cargo-clippy 2 - [clippy] rustc 2 -> std 2 - "); - } - - #[test] - fn clippy_miri_stage1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("miri") - .stage(1) - .render_steps(), @r" - [build] llvm - [check] rustc 0 -> rustc 1 - [clippy] rustc 0 -> miri 1 - "); - } - - #[test] - fn clippy_miri_stage2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("miri") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [check] rustc 1 -> rustc 2 - [build] rustc 0 -> clippy-driver 1 - [build] rustc 0 -> cargo-clippy 1 - [clippy] rustc 1 -> miri 2 - "); - } - - #[test] - fn clippy_bootstrap() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("bootstrap") - .render_steps(), @"[clippy] rustc 0 -> bootstrap 1 "); - } } struct ExecutedSteps {