Skip to content

Commit a4b6181

Browse files
authored
Rollup merge of #137882 - onur-ozkan:remove-extra-compiler-stage, r=Kobzol
do not build additional stage on compiler paths When calling `x build compiler (or rustc) --stage N` bootstrap builds stage N+1 compiler, which is clearly not what we requested. This doesn't happen when running `x build --stage N` without explicitly targeting the compiler. The changes applied fix this issue. r? ghost
2 parents 0b9ff83 + cfb475c commit a4b6181

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,9 @@ impl Step for Rustc {
994994
fn make_run(run: RunConfig<'_>) {
995995
let crates = run.cargo_crates_in_set();
996996
run.builder.ensure(Rustc {
997-
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
997+
compiler: run
998+
.builder
999+
.compiler(run.builder.top_stage.saturating_sub(1), run.build_triple()),
9981000
target: run.target,
9991001
crates,
10001002
});
@@ -1911,7 +1913,7 @@ impl Step for Assemble {
19111913

19121914
fn make_run(run: RunConfig<'_>) {
19131915
run.builder.ensure(Assemble {
1914-
target_compiler: run.builder.compiler(run.builder.top_stage + 1, run.target),
1916+
target_compiler: run.builder.compiler(run.builder.top_stage, run.target),
19151917
});
19161918
}
19171919

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

+40-7
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,20 @@ mod dist {
653653
&["compiler/rustc".into(), "library".into()],
654654
);
655655

656+
assert_eq!(builder.config.stage, 2);
657+
658+
// `compile::Rustc` includes one-stage-off compiler information as the target compiler
659+
// artifacts get copied from there to the target stage sysroot.
660+
// For example, `stage2/bin/rustc` gets copied from the `stage1-rustc` build directory.
661+
assert_eq!(
662+
first(builder.cache.all::<compile::Rustc>()),
663+
&[
664+
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0),
665+
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1),
666+
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1),
667+
]
668+
);
669+
656670
assert_eq!(
657671
first(builder.cache.all::<compile::Std>()),
658672
&[
@@ -664,15 +678,34 @@ mod dist {
664678
std!(TEST_TRIPLE_1 => TEST_TRIPLE_3, stage = 2),
665679
]
666680
);
667-
assert_eq!(builder.cache.all::<compile::Assemble>().len(), 5);
681+
668682
assert_eq!(
669-
first(builder.cache.all::<compile::Rustc>()),
683+
first(builder.cache.all::<compile::Assemble>()),
670684
&[
671-
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0),
672-
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1),
673-
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2),
674-
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1),
675-
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 2),
685+
compile::Assemble {
686+
target_compiler: Compiler {
687+
host: TargetSelection::from_user(TEST_TRIPLE_1),
688+
stage: 0
689+
}
690+
},
691+
compile::Assemble {
692+
target_compiler: Compiler {
693+
host: TargetSelection::from_user(TEST_TRIPLE_1),
694+
stage: 1
695+
}
696+
},
697+
compile::Assemble {
698+
target_compiler: Compiler {
699+
host: TargetSelection::from_user(TEST_TRIPLE_1),
700+
stage: 2
701+
}
702+
},
703+
compile::Assemble {
704+
target_compiler: Compiler {
705+
host: TargetSelection::from_user(TEST_TRIPLE_2),
706+
stage: 2
707+
}
708+
},
676709
]
677710
);
678711
}

0 commit comments

Comments
 (0)