Skip to content

Commit bb09c39

Browse files
committed
Auto merge of #52360 - Mark-Simulacrum:fix-keep-stage-for-cg-backends, r=alexcrichton
Do not attempt to recompile codegen backend(s) with --keep-stage Previously we'd attempt to recompile them and that would fail since we've essentially not built the entire compiler yet, or we're faking that fact. This commit should make us ignore the codegen backend build as well. Unlike the other compile steps, there is no CodegenBackendLink step that we run here, because that is done later as a part of assembling the final compiler and as an explicit function call. r? @alexcrichton I think this may fix or at least assist with #52174. cc @RalfJung @tinco -- if you can test this patch locally that'd be amazing; I don't want to recompile for the next couple hours to test it locally. I don't think it can make the situation worse, and in fact, if I've interpreted the cause of the failure correctly then this will fix your problem.
2 parents cc903c6 + 8eddaba commit bb09c39

File tree

3 files changed

+42
-38
lines changed

3 files changed

+42
-38
lines changed

src/bootstrap/compile.rs

Lines changed: 36 additions & 34 deletions
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,6 +654,14 @@ impl Step for CodegenBackend {
660654

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

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;
663+
}
664+
663665
if builder.force_use_stage1(compiler, target) {
664666
builder.ensure(CodegenBackend {
665667
compiler: builder.compiler(1, builder.config.build),

src/bootstrap/config.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 3 deletions
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)