Skip to content

Commit

Permalink
Unrolled build for rust-lang#137882
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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
  • Loading branch information
rust-timer authored Mar 4, 2025
2 parents 2010bba + cfb475c commit c384b7f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,9 @@ impl Step for Rustc {
fn make_run(run: RunConfig<'_>) {
let crates = run.cargo_crates_in_set();
run.builder.ensure(Rustc {
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
compiler: run
.builder
.compiler(run.builder.top_stage.saturating_sub(1), run.build_triple()),
target: run.target,
crates,
});
Expand Down Expand Up @@ -1911,7 +1913,7 @@ impl Step for Assemble {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Assemble {
target_compiler: run.builder.compiler(run.builder.top_stage + 1, run.target),
target_compiler: run.builder.compiler(run.builder.top_stage, run.target),
});
}

Expand Down
47 changes: 40 additions & 7 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,20 @@ mod dist {
&["compiler/rustc".into(), "library".into()],
);

assert_eq!(builder.config.stage, 2);

// `compile::Rustc` includes one-stage-off compiler information as the target compiler
// artifacts get copied from there to the target stage sysroot.
// For example, `stage2/bin/rustc` gets copied from the `stage1-rustc` build directory.
assert_eq!(
first(builder.cache.all::<compile::Rustc>()),
&[
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0),
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1),
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1),
]
);

assert_eq!(
first(builder.cache.all::<compile::Std>()),
&[
Expand All @@ -664,15 +678,34 @@ mod dist {
std!(TEST_TRIPLE_1 => TEST_TRIPLE_3, stage = 2),
]
);
assert_eq!(builder.cache.all::<compile::Assemble>().len(), 5);

assert_eq!(
first(builder.cache.all::<compile::Rustc>()),
first(builder.cache.all::<compile::Assemble>()),
&[
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0),
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1),
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2),
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1),
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 2),
compile::Assemble {
target_compiler: Compiler {
host: TargetSelection::from_user(TEST_TRIPLE_1),
stage: 0
}
},
compile::Assemble {
target_compiler: Compiler {
host: TargetSelection::from_user(TEST_TRIPLE_1),
stage: 1
}
},
compile::Assemble {
target_compiler: Compiler {
host: TargetSelection::from_user(TEST_TRIPLE_1),
stage: 2
}
},
compile::Assemble {
target_compiler: Compiler {
host: TargetSelection::from_user(TEST_TRIPLE_2),
stage: 2
}
},
]
);
}
Expand Down

0 comments on commit c384b7f

Please sign in to comment.