Skip to content

Commit 568f4c7

Browse files
Implement keep-stage support
1 parent 38510fe commit 568f4c7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/bootstrap/compile.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::io::prelude::*;
2323
use std::path::{Path, PathBuf};
2424
use std::process::{Command, Stdio};
2525
use std::str;
26+
use std::cmp::min;
2627

2728
use build_helper::{output, mtime, up_to_date};
2829
use filetime::FileTime;
@@ -846,7 +847,18 @@ impl Step for Assemble {
846847
// link to these. (FIXME: Is that correct? It seems to be correct most
847848
// of the time but I think we do link to these for stage2/bin compilers
848849
// when not performing a full bootstrap).
849-
builder.ensure(Rustc { compiler: build_compiler, target: target_compiler.host });
850+
if builder.build.flags.keep_stage.map_or(false, |s| target_compiler.stage <= s) {
851+
builder.verbose("skipping compilation of compiler due to --keep-stage");
852+
let compiler = build_compiler;
853+
for stage in 0..min(target_compiler.stage, builder.flags.keep_stage.unwrap()) {
854+
let target_compiler = builder.compiler(stage, target_compiler.host);
855+
builder.ensure(StdLink { compiler, target_compiler, target: target_compiler.host });
856+
builder.ensure(TestLink { compiler, target_compiler, target: target_compiler.host });
857+
builder.ensure(RustcLink { compiler, target_compiler, target: target_compiler.host });
858+
}
859+
} else {
860+
builder.ensure(Rustc { compiler: build_compiler, target: target_compiler.host });
861+
}
850862

851863
let stage = target_compiler.stage;
852864
let host = target_compiler.host;

0 commit comments

Comments
 (0)