Skip to content

Commit 59931c6

Browse files
authored
Rollup merge of rust-lang#52006 - Mark-Simulacrum:keep-stage-fix, r=alexcrichton
Change --keep-stage to apply more often Previously, the --keep-stage argument would only function for compilers that were depended on by future stages. For example, if trying to build a stage 1 compiler you could --keep-stage 0 to avoid re-building the stage 0 compiler. However, this is often not what users want in practice. The new implementation essentially skips builds all higher stages of the compiler, so an argument of 1 to keep-stage will skip rebuilds of the libraries, just linking them into the sysroot. This is unlikely to work well in cases where metadata or similar changes have been made, but is likely fine otherwise. This change is somewhat untested, but since it shouldn't have any effect except with --keep-stage, I don't see that as a large problem. r? @alexcrichton cc @nikomatsakis - I believe you wanted this functionality
2 parents 09ba8fb + 9eda4aa commit 59931c6

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

src/bootstrap/compile.rs

+44-21
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use std::io::prelude::*;
2424
use std::path::{Path, PathBuf};
2525
use std::process::{Command, Stdio};
2626
use std::str;
27-
use std::cmp::min;
2827

2928
use build_helper::{output, mtime, up_to_date};
3029
use filetime::FileTime;
@@ -68,6 +67,18 @@ impl Step for Std {
6867
let target = self.target;
6968
let compiler = self.compiler;
7069

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+
}
80+
}
81+
7182
builder.ensure(StartupObjects { compiler, target });
7283

7384
if builder.force_use_stage1(compiler, target) {
@@ -351,6 +362,18 @@ impl Step for Test {
351362
let target = self.target;
352363
let compiler = self.compiler;
353364

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+
354377
builder.ensure(Std { compiler, target });
355378

356379
if builder.force_use_stage1(compiler, target) {
@@ -467,6 +490,18 @@ impl Step for Rustc {
467490
let compiler = self.compiler;
468491
let target = self.target;
469492

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+
470505
builder.ensure(Test { compiler, target });
471506

472507
if builder.force_use_stage1(compiler, target) {
@@ -873,7 +908,7 @@ impl Step for Assemble {
873908
type Output = Compiler;
874909

875910
fn should_run(run: ShouldRun) -> ShouldRun {
876-
run.all_krates("rustc-main")
911+
run.never()
877912
}
878913

879914
/// Prepare a new compiler from the artifacts in `stage`
@@ -915,28 +950,16 @@ impl Step for Assemble {
915950
// link to these. (FIXME: Is that correct? It seems to be correct most
916951
// of the time but I think we do link to these for stage2/bin compilers
917952
// when not performing a full bootstrap).
918-
if builder.config.keep_stage.map_or(false, |s| target_compiler.stage <= s) {
919-
builder.verbose("skipping compilation of compiler due to --keep-stage");
920-
let compiler = build_compiler;
921-
for stage in 0..min(target_compiler.stage, builder.config.keep_stage.unwrap()) {
922-
let target_compiler = builder.compiler(stage, target_compiler.host);
923-
let target = target_compiler.host;
924-
builder.ensure(StdLink { compiler, target_compiler, target });
925-
builder.ensure(TestLink { compiler, target_compiler, target });
926-
builder.ensure(RustcLink { compiler, target_compiler, target });
927-
}
928-
} else {
929-
builder.ensure(Rustc {
953+
builder.ensure(Rustc {
954+
compiler: build_compiler,
955+
target: target_compiler.host,
956+
});
957+
for &backend in builder.config.rust_codegen_backends.iter() {
958+
builder.ensure(CodegenBackend {
930959
compiler: build_compiler,
931960
target: target_compiler.host,
961+
backend,
932962
});
933-
for &backend in builder.config.rust_codegen_backends.iter() {
934-
builder.ensure(CodegenBackend {
935-
compiler: build_compiler,
936-
target: target_compiler.host,
937-
backend,
938-
});
939-
}
940963
}
941964

942965
let lld_install = if builder.config.lld_enabled {

0 commit comments

Comments
 (0)