Skip to content

Commit 2aafc40

Browse files
committed
Don't trigger an LLVM build from check builds using the stage 0 compiler
1 parent 3014e79 commit 2aafc40

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,8 +1387,10 @@ pub fn rustc_cargo_env(
13871387
let building_is_expensive =
13881388
crate::core::build_steps::llvm::prebuilt_llvm_config(builder, target, false)
13891389
.should_build();
1390-
// `top_stage == stage` might be false for `check --stage 1`, if we are building the stage 1 compiler
1391-
let can_skip_build = builder.kind == Kind::Check && builder.top_stage == build_stage;
1390+
1391+
// If we are doing a check build using the pre-built stage 0 compiler,
1392+
// there should be no need to build LLVM.
1393+
let can_skip_build = builder.kind == Kind::Check && build_stage == 0;
13921394
let should_skip_build = building_is_expensive && can_skip_build;
13931395
if !should_skip_build {
13941396
rustc_llvm_env(builder, cargo, target)

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

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,46 @@ fn any_debug() {
630630
assert_eq!(x.downcast_ref::<MyStruct>(), Some(&MyStruct { x: 7 }));
631631
}
632632

633+
#[test]
634+
fn test_check_compiler_doesnt_build_llvm() {
635+
// Checking the stage 1 compiler uses the bootstrap compiler, and therefore
636+
// should not need to build LLVM.
637+
{
638+
let config = configure_with_args(
639+
&["check", "compiler", "--stage=1"],
640+
&[TEST_TRIPLE_1],
641+
&[TEST_TRIPLE_1],
642+
);
643+
let mut cache = run_build(&config.paths.clone(), config);
644+
645+
assert!(!cache.contains::<llvm::Llvm>());
646+
}
647+
648+
// Checking the stage 1 library uses the stage 1 compiler, so it will need LLVM.
649+
{
650+
let config = configure_with_args(
651+
&["check", "library", "--stage=1"],
652+
&[TEST_TRIPLE_1],
653+
&[TEST_TRIPLE_1],
654+
);
655+
let mut cache = run_build(&config.paths.clone(), config);
656+
657+
assert!(cache.contains::<llvm::Llvm>());
658+
}
659+
660+
// Checking the stage 2 compiler uses the stage 1 compiler, so it will need LLVM.
661+
{
662+
let config = configure_with_args(
663+
&["check", "compiler", "--stage=2"],
664+
&[TEST_TRIPLE_1],
665+
&[TEST_TRIPLE_1],
666+
);
667+
let mut cache = run_build(&config.paths.clone(), config);
668+
669+
assert!(cache.contains::<llvm::Llvm>());
670+
}
671+
}
672+
633673
/// These tests use insta for snapshot testing.
634674
/// See bootstrap's README on how to bless the snapshots.
635675
mod snapshot {
@@ -1294,7 +1334,6 @@ mod snapshot {
12941334
ctx.config("check")
12951335
.path("compiler")
12961336
.render_steps(), @r"
1297-
[build] llvm <host>
12981337
[check] rustc 0 <host> -> rustc 1 <host>
12991338
[check] rustc 0 <host> -> cranelift 1 <host>
13001339
[check] rustc 0 <host> -> gcc 1 <host>
@@ -1324,7 +1363,6 @@ mod snapshot {
13241363
.path("compiler")
13251364
.stage(1)
13261365
.render_steps(), @r"
1327-
[build] llvm <host>
13281366
[check] rustc 0 <host> -> rustc 1 <host>
13291367
[check] rustc 0 <host> -> cranelift 1 <host>
13301368
[check] rustc 0 <host> -> gcc 1 <host>
@@ -1360,6 +1398,7 @@ mod snapshot {
13601398
[build] rustc 0 <host> -> rustc 1 <host>
13611399
[build] rustc 1 <host> -> std 1 <host>
13621400
[build] rustc 1 <host> -> std 1 <target1>
1401+
[build] llvm <target1>
13631402
[check] rustc 1 <host> -> rustc 2 <target1>
13641403
[check] rustc 1 <host> -> Rustdoc 2 <target1>
13651404
[check] rustc 1 <host> -> cranelift 2 <target1>
@@ -1456,7 +1495,6 @@ mod snapshot {
14561495
.paths(&["library", "compiler"])
14571496
.args(&args)
14581497
.render_steps(), @r"
1459-
[build] llvm <host>
14601498
[check] rustc 0 <host> -> rustc 1 <host>
14611499
[check] rustc 0 <host> -> cranelift 1 <host>
14621500
[check] rustc 0 <host> -> gcc 1 <host>
@@ -1470,7 +1508,6 @@ mod snapshot {
14701508
ctx.config("check")
14711509
.path("miri")
14721510
.render_steps(), @r"
1473-
[build] llvm <host>
14741511
[check] rustc 0 <host> -> rustc 1 <host>
14751512
[check] rustc 0 <host> -> Miri 1 <host>
14761513
");
@@ -1491,7 +1528,6 @@ mod snapshot {
14911528
.path("miri")
14921529
.stage(1)
14931530
.render_steps(), @r"
1494-
[build] llvm <host>
14951531
[check] rustc 0 <host> -> rustc 1 <host>
14961532
[check] rustc 0 <host> -> Miri 1 <host>
14971533
");
@@ -1544,7 +1580,6 @@ mod snapshot {
15441580
ctx.config("check")
15451581
.path("rustc_codegen_cranelift")
15461582
.render_steps(), @r"
1547-
[build] llvm <host>
15481583
[check] rustc 0 <host> -> rustc 1 <host>
15491584
[check] rustc 0 <host> -> cranelift 1 <host>
15501585
[check] rustc 0 <host> -> gcc 1 <host>
@@ -1558,7 +1593,6 @@ mod snapshot {
15581593
ctx.config("check")
15591594
.path("rust-analyzer")
15601595
.render_steps(), @r"
1561-
[build] llvm <host>
15621596
[check] rustc 0 <host> -> rustc 1 <host>
15631597
[check] rustc 0 <host> -> rust-analyzer 1 <host>
15641598
");

0 commit comments

Comments
 (0)