]> git.lizzy.rs Git - rust.git/commitdiff
Change keep-stage to only affect the passed stage
authorMark Rousskov <mark.simulacrum@gmail.com>
Sat, 14 Jul 2018 16:58:10 +0000 (10:58 -0600)
committerMark Rousskov <mark.simulacrum@gmail.com>
Sat, 14 Jul 2018 17:00:09 +0000 (11:00 -0600)
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

src/bootstrap/compile.rs
src/bootstrap/config.rs
src/bootstrap/flags.rs

index 8cfd85590169841c815c5cb8010c5b4d755d17fc..04e8e133b03a11ffca2991a1eb639524b413cc41 100644 (file)
@@ -67,16 +67,14 @@ fn run(self, builder: &Builder) {
         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;
-            }
+        if builder.config.keep_stage.contains(&compiler.stage) {
+            builder.info("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 });
@@ -362,20 +360,18 @@ fn run(self, builder: &Builder) {
         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.config.keep_stage.contains(&compiler.stage) {
+            builder.info("Warning: Using a potentially old libtest. This may not behave well.");
+            builder.ensure(TestLink {
+                compiler: compiler,
+                target_compiler: compiler,
+                target,
+            });
+            return;
+        }
+
         if builder.force_use_stage1(compiler, target) {
             builder.ensure(Test {
                 compiler: builder.compiler(1, builder.config.build),
@@ -490,20 +486,18 @@ fn run(self, builder: &Builder) {
         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.config.keep_stage.contains(&compiler.stage) {
+            builder.info("Warning: Using a potentially old librustc. This may not behave well.");
+            builder.ensure(RustcLink {
+                compiler: compiler,
+                target_compiler: compiler,
+                target,
+            });
+            return;
+        }
+
         if builder.force_use_stage1(compiler, target) {
             builder.ensure(Rustc {
                 compiler: builder.compiler(1, builder.config.build),
@@ -660,14 +654,12 @@ fn run(self, builder: &Builder) {
 
         builder.ensure(Rustc { compiler, target });
 
-        if let Some(keep_stage) = builder.config.keep_stage {
-            if keep_stage <= compiler.stage {
-                println!("Warning: Using a potentially old codegen backend. \
-                    This may not behave well.");
-                // Codegen backends are linked separately from this step today, so we don't do
-                // anything here.
-                return;
-            }
+        if builder.config.keep_stage.contains(&compiler.stage) {
+            builder.info("Warning: Using a potentially old codegen backend. \
+                This may not behave well.");
+            // Codegen backends are linked separately from this step today, so we don't do
+            // anything here.
+            return;
         }
 
         if builder.force_use_stage1(compiler, target) {
index 420ae1f349c3ed3a3d0d1d841eaf76166f46d160..0a8a5c87d0da1a4b1a90cbd5aad26b634f02ae34 100644 (file)
@@ -63,7 +63,7 @@ pub struct Config {
 
     pub on_fail: Option<String>,
     pub stage: Option<u32>,
-    pub keep_stage: Option<u32>,
+    pub keep_stage: Vec<u32>,
     pub src: PathBuf,
     pub jobs: Option<u32>,
     pub cmd: Subcommand,
index e5dceccdf8b9e557b659d99aed8532ec3686682f..6a013053e580c78f8a26f1b6e105c7960073b65f 100644 (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 on_fail: Option<String>,
     pub stage: Option<u32>,
-    pub keep_stage: Option<u32>,
+    pub keep_stage: Vec<u32>,
 
     pub host: Vec<Interned<String>>,
     pub target: Vec<Interned<String>>,
@@ -122,7 +122,7 @@ pub fn parse(args: &[String]) -> Flags {
         opts.optopt("", "on-fail", "command to run on failure", "CMD");
         opts.optflag("", "dry-run", "dry run; don't build anything");
         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("j", "jobs", "number of jobs to run in parallel", "JOBS");
         opts.optflag("h", "help", "print this help message");
@@ -402,7 +402,9 @@ pub fn parse(args: &[String]) -> Flags {
             dry_run: matches.opt_present("dry-run"),
             on_fail: matches.opt_str("on-fail"),
             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"))
                 .into_iter()
                 .map(|x| INTERNER.intern_string(x))