about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2020-06-13 10:29:56 -0700
committerEric Huss <eric@huss.org>2020-06-13 10:29:56 -0700
commit0687b78d56b93d28ceeaa05e794849757d7341a4 (patch)
treeabcb5945396ed154503058b279527afff54535c7
parentf4fbb93113aa4f0a0cd08e74afb35381bbfbc7f0 (diff)
downloadrust-0687b78d56b93d28ceeaa05e794849757d7341a4.tar.gz
rust-0687b78d56b93d28ceeaa05e794849757d7341a4.zip
Speed up bootstrap a little.
-rw-r--r--src/bootstrap/flags.rs7
-rw-r--r--src/bootstrap/lib.rs2
-rw-r--r--src/bootstrap/metadata.rs65
-rw-r--r--src/bootstrap/test.rs4
4 files changed, 33 insertions, 45 deletions
diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs
index cfaa43f3970..03b7028b2fa 100644
--- a/src/bootstrap/flags.rs
+++ b/src/bootstrap/flags.rs
@@ -10,12 +10,10 @@ use std::process;
 use getopts::Options;
 
 use crate::builder::Builder;
+use crate::cache::{Interned, INTERNER};
 use crate::config::Config;
-use crate::metadata;
 use crate::{Build, DocTests};
 
-use crate::cache::{Interned, INTERNER};
-
 /// Deserialized version of all flags for this compile.
 pub struct Flags {
     pub verbose: usize, // number of -v args; each extra -v after the first is passed to Cargo
@@ -444,8 +442,7 @@ Arguments:
         // All subcommands except `clean` can have an optional "Available paths" section
         if matches.opt_present("verbose") {
             let config = Config::parse(&["build".to_string()]);
-            let mut build = Build::new(config);
-            metadata::build(&mut build);
+            let build = Build::new(config);
 
             let maybe_rules_help = Builder::get_help(&build, subcommand.as_str());
             extra_help.push_str(maybe_rules_help.unwrap_or_default().as_str());
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 8d8a036caef..a125b49fc01 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -271,7 +271,7 @@ struct Crate {
 
 impl Crate {
     fn is_local(&self, build: &Build) -> bool {
-        self.path.starts_with(&build.config.src) && !self.path.to_string_lossy().ends_with("_shim")
+        self.path.starts_with(&build.config.src)
     }
 
     fn local_path(&self, build: &Build) -> PathBuf {
diff --git a/src/bootstrap/metadata.rs b/src/bootstrap/metadata.rs
index 292aa3b1e24..185f0ddb831 100644
--- a/src/bootstrap/metadata.rs
+++ b/src/bootstrap/metadata.rs
@@ -35,49 +35,24 @@ struct ResolveNode {
 }
 
 pub fn build(build: &mut Build) {
-    let mut resolves = Vec::new();
-    build_krate(&build.std_features(), build, &mut resolves, "src/libstd");
-    build_krate("", build, &mut resolves, "src/libtest");
-    build_krate(&build.rustc_features(), build, &mut resolves, "src/rustc");
-
-    let mut id2name = HashMap::with_capacity(build.crates.len());
-    for (name, krate) in build.crates.iter() {
-        id2name.insert(krate.id.clone(), name.clone());
-    }
-
-    for node in resolves {
-        let name = match id2name.get(&node.id) {
-            Some(name) => name,
-            None => continue,
-        };
-
-        let krate = build.crates.get_mut(name).unwrap();
-        for dep in node.dependencies.iter() {
-            let dep = match id2name.get(dep) {
-                Some(dep) => dep,
-                None => continue,
-            };
-            krate.deps.insert(*dep);
-        }
-    }
-}
-
-fn build_krate(features: &str, build: &mut Build, resolves: &mut Vec<ResolveNode>, krate: &str) {
     // Run `cargo metadata` to figure out what crates we're testing.
-    //
-    // Down below we're going to call `cargo test`, but to test the right set
-    // of packages we're going to have to know what `-p` arguments to pass it
-    // to know what crates to test. Here we run `cargo metadata` to learn about
-    // the dependency graph and what `-p` arguments there are.
+    let features: Vec<_> = build
+        .std_features()
+        .split_whitespace()
+        .map(|f| format!("test/{}", f))
+        .chain(build.rustc_features().split_whitespace().map(|f| format!("rustc-main/{}", f)))
+        .collect();
     let mut cargo = Command::new(&build.initial_cargo);
     cargo
         .arg("metadata")
         .arg("--format-version")
         .arg("1")
         .arg("--features")
-        .arg(features)
+        .arg(features.join(","))
+        .arg("-Zpackage-features")
         .arg("--manifest-path")
-        .arg(build.src.join(krate).join("Cargo.toml"));
+        .arg(build.src.join("Cargo.toml"))
+        .env("RUSTC_BOOTSTRAP", "1");
     let output = output(&mut cargo);
     let output: Output = serde_json::from_str(&output).unwrap();
     for package in output.packages {
@@ -88,5 +63,23 @@ fn build_krate(features: &str, build: &mut Build, resolves: &mut Vec<ResolveNode
             build.crates.insert(name, Crate { name, id: package.id, deps: HashSet::new(), path });
         }
     }
-    resolves.extend(output.resolve.nodes);
+
+    let id2name: HashMap<_, _> =
+        build.crates.iter().map(|(name, krate)| (krate.id.clone(), name.clone())).collect();
+
+    for node in output.resolve.nodes {
+        let name = match id2name.get(&node.id) {
+            Some(name) => name,
+            None => continue,
+        };
+
+        let krate = build.crates.get_mut(name).unwrap();
+        for dep in node.dependencies.iter() {
+            let dep = match id2name.get(dep) {
+                Some(dep) => dep,
+                None => continue,
+            };
+            krate.deps.insert(*dep);
+        }
+    }
 }
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 163132f5634..8659acf1cc5 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1654,9 +1654,7 @@ impl Step for Crate {
     fn should_run(mut run: ShouldRun<'_>) -> ShouldRun<'_> {
         let builder = run.builder;
         for krate in run.builder.in_tree_crates("test") {
-            if !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) {
-                run = run.path(krate.local_path(&builder).to_str().unwrap());
-            }
+            run = run.path(krate.local_path(&builder).to_str().unwrap());
         }
         run
     }