about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-07-03 11:31:13 +0200
committerGitHub <noreply@github.com>2018-07-03 11:31:13 +0200
commit492518fcd5a3a0ce145a0b675d480d6c212d4b03 (patch)
tree0c3486b8c020617213e6bba69fd6f901b404b516 /src/bootstrap
parent6af4397e191d99367aa12b87dc87bf2e565d87a0 (diff)
parent9eda4aabff138add785c6e672d9c67cc612f7503 (diff)
downloadrust-492518fcd5a3a0ce145a0b675d480d6c212d4b03.tar.gz
rust-492518fcd5a3a0ce145a0b675d480d6c212d4b03.zip
Rollup merge of #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
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/compile.rs65
1 files changed, 44 insertions, 21 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 642f22b11ad..aef2df3e278 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -24,7 +24,6 @@ use std::io::prelude::*;
 use std::path::{Path, PathBuf};
 use std::process::{Command, Stdio};
 use std::str;
-use std::cmp::min;
 
 use build_helper::{output, mtime, up_to_date};
 use filetime::FileTime;
@@ -68,6 +67,18 @@ impl Step for Std {
         let target = self.target;
         let compiler = self.compiler;
 
+        if let Some(keep_stage) = builder.config.keep_stage {
+            if keep_stage <= compiler.stage {
+                println!("Warning: Using a potentially old libstd. This may not behave well.");
+                builder.ensure(StdLink {
+                    compiler: compiler,
+                    target_compiler: compiler,
+                    target,
+                });
+                return;
+            }
+        }
+
         builder.ensure(StartupObjects { compiler, target });
 
         if builder.force_use_stage1(compiler, target) {
@@ -351,6 +362,18 @@ impl Step for Test {
         let target = self.target;
         let compiler = self.compiler;
 
+        if let Some(keep_stage) = builder.config.keep_stage {
+            if keep_stage <= compiler.stage {
+                println!("Warning: Using a potentially old libtest. This may not behave well.");
+                builder.ensure(TestLink {
+                    compiler: compiler,
+                    target_compiler: compiler,
+                    target,
+                });
+                return;
+            }
+        }
+
         builder.ensure(Std { compiler, target });
 
         if builder.force_use_stage1(compiler, target) {
@@ -467,6 +490,18 @@ impl Step for Rustc {
         let compiler = self.compiler;
         let target = self.target;
 
+        if let Some(keep_stage) = builder.config.keep_stage {
+            if keep_stage <= compiler.stage {
+                println!("Warning: Using a potentially old librustc. This may not behave well.");
+                builder.ensure(RustcLink {
+                    compiler: compiler,
+                    target_compiler: compiler,
+                    target,
+                });
+                return;
+            }
+        }
+
         builder.ensure(Test { compiler, target });
 
         if builder.force_use_stage1(compiler, target) {
@@ -873,7 +908,7 @@ impl Step for Assemble {
     type Output = Compiler;
 
     fn should_run(run: ShouldRun) -> ShouldRun {
-        run.all_krates("rustc-main")
+        run.never()
     }
 
     /// Prepare a new compiler from the artifacts in `stage`
@@ -915,28 +950,16 @@ impl Step for Assemble {
         // link to these. (FIXME: Is that correct? It seems to be correct most
         // of the time but I think we do link to these for stage2/bin compilers
         // when not performing a full bootstrap).
-        if builder.config.keep_stage.map_or(false, |s| target_compiler.stage <= s) {
-            builder.verbose("skipping compilation of compiler due to --keep-stage");
-            let compiler = build_compiler;
-            for stage in 0..min(target_compiler.stage, builder.config.keep_stage.unwrap()) {
-                let target_compiler = builder.compiler(stage, target_compiler.host);
-                let target = target_compiler.host;
-                builder.ensure(StdLink { compiler, target_compiler, target });
-                builder.ensure(TestLink { compiler, target_compiler, target });
-                builder.ensure(RustcLink { compiler, target_compiler, target });
-            }
-        } else {
-            builder.ensure(Rustc {
+        builder.ensure(Rustc {
+            compiler: build_compiler,
+            target: target_compiler.host,
+        });
+        for &backend in builder.config.rust_codegen_backends.iter() {
+            builder.ensure(CodegenBackend {
                 compiler: build_compiler,
                 target: target_compiler.host,
+                backend,
             });
-            for &backend in builder.config.rust_codegen_backends.iter() {
-                builder.ensure(CodegenBackend {
-                    compiler: build_compiler,
-                    target: target_compiler.host,
-                    backend,
-                });
-            }
         }
 
         let lld_install = if builder.config.lld_enabled {