Skip to content

Commit 9ee00b7

Browse files
committed
update std uplifting algorithm
Signed-off-by: onur-ozkan <[email protected]>
1 parent 8ac271c commit 9ee00b7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

+14-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,20 @@ impl Step for Std {
185185

186186
let mut target_deps = builder.ensure(StartupObjects { compiler, target });
187187

188-
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
189-
if compiler_to_use != compiler {
188+
let mut compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
189+
190+
// We only need to build std twice; therefore,
191+
// - If stage 2 std is built, the artifacts are fully up to date. For the next stages, uplift the artifacts instead of compiling std again.
192+
// - If `--build-std-on-stage0` was used it means std was already built on stage 0. So, if stage 1 is built, that means std is fully up to date.
193+
// For the next stages, uplift the artifacts instead of compiling std again.
194+
if (compiler.stage > 2 || builder.config.build_std_on_stage0) && compiler_to_use != compiler
195+
{
196+
// If stage 2 std was built (not uplifted), uplift the artifacts from stage 2.
197+
// (This is necessary; without this, they will be uplifted from stage 1).
198+
if !builder.config.build_std_on_stage0 && compiler.stage > 2 {
199+
compiler_to_use.stage = 2;
200+
}
201+
190202
builder.ensure(Std::new(compiler_to_use, target));
191203
let msg = if compiler_to_use.host == target {
192204
format!(

0 commit comments

Comments
 (0)