Change keep-stage to only affect the passed stage

The best way to build a stage 2 rustc is now probably
  ./x.py build --stage 2 src/rustc # once
  ./x.py build --stage 2 --keep-stage 1 src/rustc
This commit is contained in:
Mark Rousskov 2018-07-14 10:58:10 -06:00
parent a569c249c2
commit 8eddabaafd
3 changed files with 40 additions and 46 deletions

View File

@ -67,9 +67,8 @@ impl Step for Std {
let target = self.target; let target = self.target;
let compiler = self.compiler; let compiler = self.compiler;
if let Some(keep_stage) = builder.config.keep_stage { if builder.config.keep_stage.contains(&compiler.stage) {
if keep_stage <= compiler.stage { builder.info("Warning: Using a potentially old libstd. This may not behave well.");
println!("Warning: Using a potentially old libstd. This may not behave well.");
builder.ensure(StdLink { builder.ensure(StdLink {
compiler: compiler, compiler: compiler,
target_compiler: compiler, target_compiler: compiler,
@ -77,7 +76,6 @@ impl Step for Std {
}); });
return; return;
} }
}
builder.ensure(StartupObjects { compiler, target }); builder.ensure(StartupObjects { compiler, target });
@ -362,9 +360,10 @@ impl Step for Test {
let target = self.target; let target = self.target;
let compiler = self.compiler; let compiler = self.compiler;
if let Some(keep_stage) = builder.config.keep_stage { builder.ensure(Std { compiler, target });
if keep_stage <= compiler.stage {
println!("Warning: Using a potentially old libtest. This may not behave well."); if builder.config.keep_stage.contains(&compiler.stage) {
builder.info("Warning: Using a potentially old libtest. This may not behave well.");
builder.ensure(TestLink { builder.ensure(TestLink {
compiler: compiler, compiler: compiler,
target_compiler: compiler, target_compiler: compiler,
@ -372,9 +371,6 @@ impl Step for Test {
}); });
return; return;
} }
}
builder.ensure(Std { compiler, target });
if builder.force_use_stage1(compiler, target) { if builder.force_use_stage1(compiler, target) {
builder.ensure(Test { builder.ensure(Test {
@ -490,9 +486,10 @@ impl Step for Rustc {
let compiler = self.compiler; let compiler = self.compiler;
let target = self.target; let target = self.target;
if let Some(keep_stage) = builder.config.keep_stage { builder.ensure(Test { compiler, target });
if keep_stage <= compiler.stage {
println!("Warning: Using a potentially old librustc. This may not behave well."); if builder.config.keep_stage.contains(&compiler.stage) {
builder.info("Warning: Using a potentially old librustc. This may not behave well.");
builder.ensure(RustcLink { builder.ensure(RustcLink {
compiler: compiler, compiler: compiler,
target_compiler: compiler, target_compiler: compiler,
@ -500,9 +497,6 @@ impl Step for Rustc {
}); });
return; return;
} }
}
builder.ensure(Test { compiler, target });
if builder.force_use_stage1(compiler, target) { if builder.force_use_stage1(compiler, target) {
builder.ensure(Rustc { builder.ensure(Rustc {
@ -660,15 +654,13 @@ impl Step for CodegenBackend {
builder.ensure(Rustc { compiler, target }); builder.ensure(Rustc { compiler, target });
if let Some(keep_stage) = builder.config.keep_stage { if builder.config.keep_stage.contains(&compiler.stage) {
if keep_stage <= compiler.stage { builder.info("Warning: Using a potentially old codegen backend. \
println!("Warning: Using a potentially old codegen backend. \
This may not behave well."); This may not behave well.");
// Codegen backends are linked separately from this step today, so we don't do // Codegen backends are linked separately from this step today, so we don't do
// anything here. // anything here.
return; return;
} }
}
if builder.force_use_stage1(compiler, target) { if builder.force_use_stage1(compiler, target) {
builder.ensure(CodegenBackend { builder.ensure(CodegenBackend {

View File

@ -63,7 +63,7 @@ pub struct Config {
pub on_fail: Option<String>, pub on_fail: Option<String>,
pub stage: Option<u32>, pub stage: Option<u32>,
pub keep_stage: Option<u32>, pub keep_stage: Vec<u32>,
pub src: PathBuf, pub src: PathBuf,
pub jobs: Option<u32>, pub jobs: Option<u32>,
pub cmd: Subcommand, pub cmd: Subcommand,

View File

@ -31,7 +31,7 @@ pub struct Flags {
pub verbose: usize, // number of -v args; each extra -v after the first is passed to Cargo pub verbose: usize, // number of -v args; each extra -v after the first is passed to Cargo
pub on_fail: Option<String>, pub on_fail: Option<String>,
pub stage: Option<u32>, pub stage: Option<u32>,
pub keep_stage: Option<u32>, pub keep_stage: Vec<u32>,
pub host: Vec<Interned<String>>, pub host: Vec<Interned<String>>,
pub target: Vec<Interned<String>>, pub target: Vec<Interned<String>>,
@ -122,7 +122,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
opts.optopt("", "on-fail", "command to run on failure", "CMD"); opts.optopt("", "on-fail", "command to run on failure", "CMD");
opts.optflag("", "dry-run", "dry run; don't build anything"); opts.optflag("", "dry-run", "dry run; don't build anything");
opts.optopt("", "stage", "stage to build", "N"); opts.optopt("", "stage", "stage to build", "N");
opts.optopt("", "keep-stage", "stage to keep without recompiling", "N"); opts.optmulti("", "keep-stage", "stage(s) to keep without recompiling", "N");
opts.optopt("", "src", "path to the root of the rust checkout", "DIR"); opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS"); opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
opts.optflag("h", "help", "print this help message"); opts.optflag("h", "help", "print this help message");
@ -402,7 +402,9 @@ Arguments:
dry_run: matches.opt_present("dry-run"), dry_run: matches.opt_present("dry-run"),
on_fail: matches.opt_str("on-fail"), on_fail: matches.opt_str("on-fail"),
rustc_error_format: matches.opt_str("error-format"), rustc_error_format: matches.opt_str("error-format"),
keep_stage: matches.opt_str("keep-stage").map(|j| j.parse().unwrap()), keep_stage: matches.opt_strs("keep-stage")
.into_iter().map(|j| j.parse().unwrap())
.collect(),
host: split(matches.opt_strs("host")) host: split(matches.opt_strs("host"))
.into_iter() .into_iter()
.map(|x| INTERNER.intern_string(x)) .map(|x| INTERNER.intern_string(x))