Skip to content

Commit 8eddaba

Browse files
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
1 parent a569c24 commit 8eddaba

File tree

3 files changed

+40
-46
lines changed

3 files changed

+40
-46
lines changed

src/bootstrap/compile.rs

+34-42
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,14 @@ impl Step for Std {
6767
let target = self.target;
6868
let compiler = self.compiler;
6969

70-
if let Some(keep_stage) = builder.config.keep_stage {
71-
if keep_stage <= compiler.stage {
72-
println!("Warning: Using a potentially old libstd. This may not behave well.");
73-
builder.ensure(StdLink {
74-
compiler: compiler,
75-
target_compiler: compiler,
76-
target,
77-
});
78-
return;
79-
}
70+
if builder.config.keep_stage.contains(&compiler.stage) {
71+
builder.info("Warning: Using a potentially old libstd. This may not behave well.");
72+
builder.ensure(StdLink {
73+
compiler: compiler,
74+
target_compiler: compiler,
75+
target,
76+
});
77+
return;
8078
}
8179

8280
builder.ensure(StartupObjects { compiler, target });
@@ -362,20 +360,18 @@ impl Step for Test {
362360
let target = self.target;
363361
let compiler = self.compiler;
364362

365-
if let Some(keep_stage) = builder.config.keep_stage {
366-
if keep_stage <= compiler.stage {
367-
println!("Warning: Using a potentially old libtest. This may not behave well.");
368-
builder.ensure(TestLink {
369-
compiler: compiler,
370-
target_compiler: compiler,
371-
target,
372-
});
373-
return;
374-
}
375-
}
376-
377363
builder.ensure(Std { compiler, target });
378364

365+
if builder.config.keep_stage.contains(&compiler.stage) {
366+
builder.info("Warning: Using a potentially old libtest. This may not behave well.");
367+
builder.ensure(TestLink {
368+
compiler: compiler,
369+
target_compiler: compiler,
370+
target,
371+
});
372+
return;
373+
}
374+
379375
if builder.force_use_stage1(compiler, target) {
380376
builder.ensure(Test {
381377
compiler: builder.compiler(1, builder.config.build),
@@ -490,20 +486,18 @@ impl Step for Rustc {
490486
let compiler = self.compiler;
491487
let target = self.target;
492488

493-
if let Some(keep_stage) = builder.config.keep_stage {
494-
if keep_stage <= compiler.stage {
495-
println!("Warning: Using a potentially old librustc. This may not behave well.");
496-
builder.ensure(RustcLink {
497-
compiler: compiler,
498-
target_compiler: compiler,
499-
target,
500-
});
501-
return;
502-
}
503-
}
504-
505489
builder.ensure(Test { compiler, target });
506490

491+
if builder.config.keep_stage.contains(&compiler.stage) {
492+
builder.info("Warning: Using a potentially old librustc. This may not behave well.");
493+
builder.ensure(RustcLink {
494+
compiler: compiler,
495+
target_compiler: compiler,
496+
target,
497+
});
498+
return;
499+
}
500+
507501
if builder.force_use_stage1(compiler, target) {
508502
builder.ensure(Rustc {
509503
compiler: builder.compiler(1, builder.config.build),
@@ -660,14 +654,12 @@ impl Step for CodegenBackend {
660654

661655
builder.ensure(Rustc { compiler, target });
662656

663-
if let Some(keep_stage) = builder.config.keep_stage {
664-
if keep_stage <= compiler.stage {
665-
println!("Warning: Using a potentially old codegen backend. \
666-
This may not behave well.");
667-
// Codegen backends are linked separately from this step today, so we don't do
668-
// anything here.
669-
return;
670-
}
657+
if builder.config.keep_stage.contains(&compiler.stage) {
658+
builder.info("Warning: Using a potentially old codegen backend. \
659+
This may not behave well.");
660+
// Codegen backends are linked separately from this step today, so we don't do
661+
// anything here.
662+
return;
671663
}
672664

673665
if builder.force_use_stage1(compiler, target) {

src/bootstrap/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct Config {
6363

6464
pub on_fail: Option<String>,
6565
pub stage: Option<u32>,
66-
pub keep_stage: Option<u32>,
66+
pub keep_stage: Vec<u32>,
6767
pub src: PathBuf,
6868
pub jobs: Option<u32>,
6969
pub cmd: Subcommand,

src/bootstrap/flags.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct Flags {
3131
pub verbose: usize, // number of -v args; each extra -v after the first is passed to Cargo
3232
pub on_fail: Option<String>,
3333
pub stage: Option<u32>,
34-
pub keep_stage: Option<u32>,
34+
pub keep_stage: Vec<u32>,
3535

3636
pub host: Vec<Interned<String>>,
3737
pub target: Vec<Interned<String>>,
@@ -122,7 +122,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
122122
opts.optopt("", "on-fail", "command to run on failure", "CMD");
123123
opts.optflag("", "dry-run", "dry run; don't build anything");
124124
opts.optopt("", "stage", "stage to build", "N");
125-
opts.optopt("", "keep-stage", "stage to keep without recompiling", "N");
125+
opts.optmulti("", "keep-stage", "stage(s) to keep without recompiling", "N");
126126
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
127127
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
128128
opts.optflag("h", "help", "print this help message");
@@ -402,7 +402,9 @@ Arguments:
402402
dry_run: matches.opt_present("dry-run"),
403403
on_fail: matches.opt_str("on-fail"),
404404
rustc_error_format: matches.opt_str("error-format"),
405-
keep_stage: matches.opt_str("keep-stage").map(|j| j.parse().unwrap()),
405+
keep_stage: matches.opt_strs("keep-stage")
406+
.into_iter().map(|j| j.parse().unwrap())
407+
.collect(),
406408
host: split(matches.opt_strs("host"))
407409
.into_iter()
408410
.map(|x| INTERNER.intern_string(x))

0 commit comments

Comments
 (0)