diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-03-03 20:47:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-03 20:47:12 +0100 |
| commit | a4b61811564307efc7d49fc2ca8c154021f36b1c (patch) | |
| tree | 920da833b4d54bada028dec5a92cc82efffcc5db | |
| parent | 0b9ff83bbba387a9addd40d513743df0e33b9a99 (diff) | |
| parent | cfb475c1d2ca0bf2c717c3750cb01c7435f01d71 (diff) | |
| download | rust-a4b61811564307efc7d49fc2ca8c154021f36b1c.tar.gz rust-a4b61811564307efc7d49fc2ca8c154021f36b1c.zip | |
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
| -rw-r--r-- | src/bootstrap/src/core/build_steps/compile.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/src/core/builder/tests.rs | 47 |
2 files changed, 44 insertions, 9 deletions
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index d645d922ef4..78219500737 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -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, }); @@ -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), }); } diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 0eaa89792bd..1f27002f81c 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -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>()), &[ @@ -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 + } + }, ] ); } |
