@@ -23,6 +23,7 @@ use std::io::prelude::*;
23
23
use std:: path:: { Path , PathBuf } ;
24
24
use std:: process:: { Command , Stdio } ;
25
25
use std:: str;
26
+ use std:: cmp:: min;
26
27
27
28
use build_helper:: { output, mtime, up_to_date} ;
28
29
use filetime:: FileTime ;
@@ -846,7 +847,18 @@ impl Step for Assemble {
846
847
// link to these. (FIXME: Is that correct? It seems to be correct most
847
848
// of the time but I think we do link to these for stage2/bin compilers
848
849
// 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
+ }
850
862
851
863
let stage = target_compiler. stage ;
852
864
let host = target_compiler. host ;
0 commit comments