Skip to content

Commit 819462e

Browse files
committed
Split codegen backend check step into two and don't run it with x check compiler
1 parent 1553adf commit 819462e

File tree

3 files changed

+91
-42
lines changed

3 files changed

+91
-42
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 86 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -316,41 +316,31 @@ fn prepare_compiler_for_check(
316316
}
317317
}
318318

319-
/// Checks a single codegen backend.
319+
/// Check the Cranelift codegen backend.
320320
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
321-
pub struct CodegenBackend {
322-
pub build_compiler: Compiler,
323-
pub target: TargetSelection,
324-
pub backend: CodegenBackendKind,
321+
pub struct CraneliftCodegenBackend {
322+
build_compiler: Compiler,
323+
target: TargetSelection,
325324
}
326325

327-
impl Step for CodegenBackend {
326+
impl Step for CraneliftCodegenBackend {
328327
type Output = ();
328+
329329
const ONLY_HOSTS: bool = true;
330330
const DEFAULT: bool = true;
331331

332332
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
333-
run.paths(&["compiler/rustc_codegen_cranelift", "compiler/rustc_codegen_gcc"])
333+
run.alias("rustc_codegen_cranelift").alias("cg_clif")
334334
}
335335

336336
fn make_run(run: RunConfig<'_>) {
337-
// FIXME: only check the backend(s) that were actually selected in run.paths
338337
let build_compiler = prepare_compiler_for_check(run.builder, run.target, Mode::Codegen);
339-
for backend in [CodegenBackendKind::Cranelift, CodegenBackendKind::Gcc] {
340-
run.builder.ensure(CodegenBackend { build_compiler, target: run.target, backend });
341-
}
338+
run.builder.ensure(CraneliftCodegenBackend { build_compiler, target: run.target });
342339
}
343340

344341
fn run(self, builder: &Builder<'_>) {
345-
// FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved
346-
if builder.build.config.vendor && self.backend.is_gcc() {
347-
println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled.");
348-
return;
349-
}
350-
351342
let build_compiler = self.build_compiler;
352343
let target = self.target;
353-
let backend = self.backend;
354344

355345
let mut cargo = builder::Cargo::new(
356346
builder,
@@ -363,31 +353,104 @@ impl Step for CodegenBackend {
363353

364354
cargo
365355
.arg("--manifest-path")
366-
.arg(builder.src.join(format!("compiler/{}/Cargo.toml", backend.crate_name())));
356+
.arg(builder.src.join("compiler/rustc_codegen_cranelift/Cargo.toml"));
367357
rustc_cargo_env(builder, &mut cargo, target);
368358

369359
let _guard = builder.msg(
370360
Kind::Check,
371-
backend.crate_name(),
361+
"rustc_codegen_cranelift",
372362
Mode::Codegen,
373363
self.build_compiler,
374364
target,
375365
);
376366

377-
let stamp = build_stamp::codegen_backend_stamp(builder, build_compiler, target, &backend)
378-
.with_prefix("check");
367+
let stamp = build_stamp::codegen_backend_stamp(
368+
builder,
369+
build_compiler,
370+
target,
371+
&CodegenBackendKind::Cranelift,
372+
)
373+
.with_prefix("check");
379374

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

383378
fn metadata(&self) -> Option<StepMetadata> {
384379
Some(
385-
StepMetadata::check(&self.backend.crate_name(), self.target)
380+
StepMetadata::check("rustc_codegen_cranelift", self.target)
386381
.built_by(self.build_compiler),
387382
)
388383
}
389384
}
390385

386+
/// Check the GCC codegen backend.
387+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
388+
pub struct GccCodegenBackend {
389+
build_compiler: Compiler,
390+
target: TargetSelection,
391+
}
392+
393+
impl Step for GccCodegenBackend {
394+
type Output = ();
395+
396+
const ONLY_HOSTS: bool = true;
397+
const DEFAULT: bool = true;
398+
399+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
400+
run.alias("rustc_codegen_gcc").alias("cg_gcc")
401+
}
402+
403+
fn make_run(run: RunConfig<'_>) {
404+
let build_compiler = prepare_compiler_for_check(run.builder, run.target, Mode::Codegen);
405+
run.builder.ensure(GccCodegenBackend { build_compiler, target: run.target });
406+
}
407+
408+
fn run(self, builder: &Builder<'_>) {
409+
// FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved
410+
if builder.build.config.vendor {
411+
println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled.");
412+
return;
413+
}
414+
415+
let build_compiler = self.build_compiler;
416+
let target = self.target;
417+
418+
let mut cargo = builder::Cargo::new(
419+
builder,
420+
build_compiler,
421+
Mode::Codegen,
422+
SourceType::InTree,
423+
target,
424+
builder.kind,
425+
);
426+
427+
cargo.arg("--manifest-path").arg(builder.src.join("compiler/rustc_codegen_gcc/Cargo.toml"));
428+
rustc_cargo_env(builder, &mut cargo, target);
429+
430+
let _guard = builder.msg(
431+
Kind::Check,
432+
"rustc_codegen_gcc",
433+
Mode::Codegen,
434+
self.build_compiler,
435+
target,
436+
);
437+
438+
let stamp = build_stamp::codegen_backend_stamp(
439+
builder,
440+
build_compiler,
441+
target,
442+
&CodegenBackendKind::Gcc,
443+
)
444+
.with_prefix("check");
445+
446+
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
447+
}
448+
449+
fn metadata(&self) -> Option<StepMetadata> {
450+
Some(StepMetadata::check("rustc_codegen_gcc", self.target).built_by(self.build_compiler))
451+
}
452+
}
453+
391454
macro_rules! tool_check_step {
392455
(
393456
$name:ident {

src/bootstrap/src/core/builder/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,8 @@ impl<'a> Builder<'a> {
10301030
Kind::Check | Kind::Fix => describe!(
10311031
check::Rustc,
10321032
check::Rustdoc,
1033-
check::CodegenBackend,
1033+
check::CraneliftCodegenBackend,
1034+
check::GccCodegenBackend,
10341035
check::Clippy,
10351036
check::Miri,
10361037
check::CargoMiri,

src/bootstrap/src/core/builder/tests.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,11 +1514,7 @@ mod snapshot {
15141514
insta::assert_snapshot!(
15151515
ctx.config("check")
15161516
.path("compiler")
1517-
.render_steps(), @r"
1518-
[check] rustc 0 <host> -> rustc 1 <host>
1519-
[check] rustc 0 <host> -> rustc_codegen_cranelift 1 <host>
1520-
[check] rustc 0 <host> -> rustc_codegen_gcc 1 <host>
1521-
");
1517+
.render_steps(), @"[check] rustc 0 <host> -> rustc 1 <host>");
15221518
}
15231519

15241520
#[test]
@@ -1546,11 +1542,7 @@ mod snapshot {
15461542
ctx.config("check")
15471543
.path("compiler")
15481544
.stage(1)
1549-
.render_steps(), @r"
1550-
[check] rustc 0 <host> -> rustc 1 <host>
1551-
[check] rustc 0 <host> -> rustc_codegen_cranelift 1 <host>
1552-
[check] rustc 0 <host> -> rustc_codegen_gcc 1 <host>
1553-
");
1545+
.render_steps(), @"[check] rustc 0 <host> -> rustc 1 <host>");
15541546
}
15551547

15561548
#[test]
@@ -1565,8 +1557,6 @@ mod snapshot {
15651557
[build] rustc 0 <host> -> rustc 1 <host>
15661558
[build] rustc 1 <host> -> std 1 <host>
15671559
[check] rustc 1 <host> -> rustc 2 <host>
1568-
[check] rustc 1 <host> -> rustc_codegen_cranelift 2 <host>
1569-
[check] rustc 1 <host> -> rustc_codegen_gcc 2 <host>
15701560
");
15711561
}
15721562

@@ -1677,11 +1667,7 @@ mod snapshot {
16771667
ctx.config("check")
16781668
.paths(&["library", "compiler"])
16791669
.args(&args)
1680-
.render_steps(), @r"
1681-
[check] rustc 0 <host> -> rustc 1 <host>
1682-
[check] rustc 0 <host> -> rustc_codegen_cranelift 1 <host>
1683-
[check] rustc 0 <host> -> rustc_codegen_gcc 1 <host>
1684-
");
1670+
.render_steps(), @"[check] rustc 0 <host> -> rustc 1 <host>");
16851671
}
16861672

16871673
#[test]
@@ -1765,7 +1751,6 @@ mod snapshot {
17651751
.render_steps(), @r"
17661752
[check] rustc 0 <host> -> rustc 1 <host>
17671753
[check] rustc 0 <host> -> rustc_codegen_cranelift 1 <host>
1768-
[check] rustc 0 <host> -> rustc_codegen_gcc 1 <host>
17691754
");
17701755
}
17711756

0 commit comments

Comments
 (0)