about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/bootstrap/builder.rs4
-rw-r--r--src/bootstrap/cache.rs28
-rw-r--r--src/bootstrap/check.rs12
-rw-r--r--src/bootstrap/compile.rs9
-rw-r--r--src/bootstrap/dist.rs12
-rw-r--r--src/bootstrap/doc.rs11
-rw-r--r--src/bootstrap/install.rs1
-rw-r--r--src/bootstrap/lib.rs1
-rw-r--r--src/bootstrap/native.rs3
-rw-r--r--src/bootstrap/tool.rs6
10 files changed, 67 insertions, 20 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 5d7400ab9ae..72736c76111 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -56,6 +56,9 @@ pub trait Step<'a>: Serialize + Sized {
     /// somewhat harder.
     type Output: Serialize + Deserialize<'a> + 'a;
 
+    /// This type, but with a 'static bound. Used for caching the step.
+    type Id: 'static;
+
     const DEFAULT: bool = false;
 
     /// Run this rule for all hosts without cross compiling.
@@ -190,6 +193,7 @@ impl<'a> Builder<'a> {
             target: &'a str,
         }
         impl<'a> Step<'a> for Libdir<'a> {
+            type Id = Libdir<'static>;
             type Output = PathBuf;
             fn run(self, builder: &Builder) -> PathBuf {
                 let compiler = self.compiler;
diff --git a/src/bootstrap/cache.rs b/src/bootstrap/cache.rs
index bc69c6fcffd..475e3abfd40 100644
--- a/src/bootstrap/cache.rs
+++ b/src/bootstrap/cache.rs
@@ -10,10 +10,11 @@
 
 use serde_json;
 use serde::{Serialize, Deserialize};
+use std::any::TypeId;
+use builder::Step;
 
 use std::fmt;
 use std::mem;
-use std::intrinsics;
 use std::collections::HashMap;
 use std::cell::RefCell;
 
@@ -29,31 +30,20 @@ use std::cell::RefCell;
 pub struct Cache(RefCell<HashMap<Key, Box<str>>>);
 
 fn to_json<T: Serialize>(element: &T) -> String {
-    let type_id = unsafe {
-        intrinsics::type_name::<T>()
-    };
-
-    t!(serde_json::to_string(&(type_id, element)))
+    t!(serde_json::to_string(element))
 }
 
 fn from_json<'a, O: Deserialize<'a>>(data: &'a str) -> O {
-    let type_id = unsafe {
-        intrinsics::type_name::<O>()
-    };
-
-    let (de_type_id, element): (&'a str, O)  = t!(serde_json::from_str(data));
-
-    assert_eq!(type_id, de_type_id);
-
-    element
+    t!(serde_json::from_str(data))
 }
 
 #[derive(Clone, PartialEq, Eq, Hash)]
-pub struct Key(String);
+pub struct Key(TypeId, String);
 
 impl fmt::Debug for Key {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-        fmt.write_str(&self.0)
+        fmt.write_str(&format!("{:?}; ", self.0))?;
+        fmt.write_str(&self.1)
     }
 }
 
@@ -62,8 +52,8 @@ impl Cache {
         Cache(RefCell::new(HashMap::new()))
     }
 
-    pub fn to_key<K: Serialize>(key: &K) -> Key {
-        Key(to_json(key))
+    pub fn to_key<'a, K: Step<'a>>(key: &K) -> Key {
+        Key(TypeId::of::<K::Id>(), to_json(key))
     }
 
     /// Puts a value into the cache. Will panic if called more than once with
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index acb50b5b83d..8adfed44f01 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -99,6 +99,7 @@ pub struct Linkcheck<'a> {
 }
 
 impl<'a> Step<'a> for Linkcheck<'a> {
+    type Id = Linkcheck<'static>;
     type Output = ();
     const ONLY_HOSTS: bool = true;
     const DEFAULT: bool = true;
@@ -148,6 +149,7 @@ pub struct Cargotest<'a> {
 }
 
 impl<'a> Step<'a> for Cargotest<'a> {
+    type Id = Cargotest<'static>;
     type Output = ();
     const ONLY_HOSTS: bool = true;
 
@@ -198,6 +200,7 @@ pub struct Cargo<'a> {
 }
 
 impl<'a> Step<'a> for Cargo<'a> {
+    type Id = Cargo<'static>;
     type Output = ();
     const ONLY_HOSTS: bool = true;
 
@@ -307,6 +310,7 @@ pub struct Tidy<'a> {
 }
 
 impl<'a> Step<'a> for Tidy<'a> {
+    type Id = Tidy<'static>;
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -509,6 +513,7 @@ static COMPILETESTS: &[Test] = &[
 ];
 
 impl<'a> Step<'a> for Compiletest<'a> {
+    type Id = Compiletest<'static>;
     type Output = ();
     const DEFAULT: bool = true;
 
@@ -775,6 +780,7 @@ pub struct Docs<'a> {
 //     .host(true)
 //     .run(move |s| check::docs(build, &s.compiler()));
 impl<'a> Step<'a> for Docs<'a> {
+    type Id = Docs<'static>;
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -840,6 +846,7 @@ pub struct ErrorIndex<'a> {
 }
 
 impl<'a> Step<'a> for ErrorIndex<'a> {
+    type Id = ErrorIndex<'static>;
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -935,6 +942,7 @@ pub struct KrateLibrustc<'a> {
 }
 
 impl<'a> Step<'a> for KrateLibrustc<'a> {
+    type Id = KrateLibrustc<'static>;
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -1045,6 +1053,7 @@ pub struct Krate<'a> {
 }
 
 impl<'a> Step<'a> for Krate<'a> {
+    type Id = Krate<'static>;
     type Output = ();
     const DEFAULT: bool = true;
 
@@ -1311,6 +1320,7 @@ pub struct RemoteCopyLibs<'a> {
 }
 
 impl<'a> Step<'a> for RemoteCopyLibs<'a> {
+    type Id = RemoteCopyLibs<'static>;
     type Output = ();
 
     fn run(self, builder: &Builder) {
@@ -1362,6 +1372,7 @@ impl<'a> Step<'a> for RemoteCopyLibs<'a> {
 pub struct Distcheck;
 
 impl<'a> Step<'a> for Distcheck {
+    type Id = Distcheck;
     type Output = ();
 
     /// Run "distcheck", a 'make check' from a tarball
@@ -1429,6 +1440,7 @@ impl<'a> Step<'a> for Distcheck {
 pub struct Bootstrap;
 
 impl<'a> Step<'a> for Bootstrap {
+    type Id = Bootstrap;
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index db2912e7e27..ec08bb9db2b 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -147,6 +147,7 @@ pub struct Std<'a> {
 }
 
 impl<'a> Step<'a> for Std<'a> {
+    type Id = Std<'static>;
     type Output = ();
     const DEFAULT: bool = true;
 
@@ -268,6 +269,7 @@ struct StdLink<'a> {
 }
 
 impl<'a> Step<'a> for StdLink<'a> {
+    type Id = StdLink<'static>;
     type Output = ();
 
     /// Link all libstd rlibs/dylibs into the sysroot location.
@@ -337,6 +339,7 @@ pub struct StartupObjects<'a> {
 }
 
 impl<'a> Step<'a> for StartupObjects<'a> {
+    type Id = StartupObjects<'static>;
     type Output = ();
 
     fn should_run(_builder: &Builder, path: &Path) -> bool {
@@ -403,6 +406,7 @@ pub struct Test<'a> {
 }
 
 impl<'a> Step<'a> for Test<'a> {
+    type Id = Test<'static>;
     type Output = ();
     const DEFAULT: bool = true;
 
@@ -485,6 +489,7 @@ pub struct TestLink<'a> {
 }
 
 impl<'a> Step<'a> for TestLink<'a> {
+    type Id = TestLink<'static>;
     type Output = ();
 
     /// Same as `std_link`, only for libtest
@@ -519,6 +524,7 @@ pub struct Rustc<'a> {
 }
 
 impl<'a> Step<'a> for Rustc<'a> {
+    type Id = Rustc<'static>;
     type Output = ();
     const ONLY_HOSTS: bool = true;
     const DEFAULT: bool = true;
@@ -668,6 +674,7 @@ struct RustcLink<'a> {
 }
 
 impl<'a> Step<'a> for RustcLink<'a> {
+    type Id = RustcLink<'static>;
     type Output = ();
 
     /// Same as `std_link`, only for librustc
@@ -720,6 +727,7 @@ pub struct Sysroot<'a> {
 }
 
 impl<'a> Step<'a> for Sysroot<'a> {
+    type Id = Sysroot<'static>;
     type Output = PathBuf;
 
     /// Returns the sysroot for the `compiler` specified that *this build system
@@ -766,6 +774,7 @@ pub struct Assemble<'a> {
 }
 
 impl<'a> Step<'a> for Assemble<'a> {
+    type Id = Assemble<'static>;
     type Output = Compiler<'a>;
 
     /// Prepare a new compiler from the artifacts in `stage`
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index c5d09869b2b..f19536e2f49 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -78,6 +78,7 @@ pub struct Docs<'a> {
 }
 
 impl<'a> Step<'a> for Docs<'a> {
+    type Id = Docs<'static>;
     type Output = Option<PathBuf>;
     const DEFAULT: bool = true;
     const ONLY_BUILD_TARGETS: bool = true;
@@ -287,6 +288,7 @@ pub struct Mingw<'a> {
 }
 
 impl<'a> Step<'a> for Mingw<'a> {
+    type Id = Mingw<'static>;
     type Output = Option<PathBuf>;
     const DEFAULT: bool = true;
     const ONLY_BUILD_TARGETS: bool = true;
@@ -355,6 +357,7 @@ pub struct Rustc<'a> {
 }
 
 impl<'a> Step<'a> for Rustc<'a> {
+    type Id = Rustc<'static>;
     type Output = PathBuf;
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -495,6 +498,7 @@ pub struct DebuggerScripts<'a> {
 }
 
 impl<'a> Step<'a> for DebuggerScripts<'a> {
+    type Id = DebuggerScripts<'static>;
     type Output = ();
 
     fn should_run(_builder: &Builder, path: &Path) -> bool {
@@ -567,6 +571,7 @@ pub struct Std<'a> {
 }
 
 impl<'a> Step<'a> for Std<'a> {
+    type Id = Std<'static>;
     type Output = Option<PathBuf>;
     const DEFAULT: bool = true;
     const ONLY_BUILD_TARGETS: bool = true;
@@ -647,6 +652,7 @@ pub struct Analysis<'a> {
 }
 
 impl<'a> Step<'a> for Analysis<'a> {
+    type Id = Analysis<'static>;
     type Output = Option<PathBuf>;
     const DEFAULT: bool = true;
     const ONLY_BUILD_TARGETS: bool = true;
@@ -767,6 +773,7 @@ fn copy_src_dirs(build: &Build, src_dirs: &[&str], exclude_dirs: &[&str], dst_di
 pub struct Src;
 
 impl<'a> Step<'a> for Src {
+    type Id = Src;
     /// The output path of the src installer tarball
     type Output = PathBuf;
     const DEFAULT: bool = true;
@@ -864,6 +871,7 @@ const CARGO_VENDOR_VERSION: &str = "0.1.4";
 pub struct PlainSourceTarball;
 
 impl<'a> Step<'a> for PlainSourceTarball {
+    type Id = PlainSourceTarball;
     /// Produces the location of the tarball generated
     type Output = PathBuf;
     const DEFAULT: bool = true;
@@ -1018,6 +1026,7 @@ pub struct Cargo<'a> {
 }
 
 impl<'a> Step<'a> for Cargo<'a> {
+    type Id = Cargo<'static>;
     type Output = PathBuf;
     const ONLY_BUILD_TARGETS: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -1114,6 +1123,7 @@ pub struct Rls<'a> {
 }
 
 impl<'a> Step<'a> for Rls<'a> {
+    type Id = Rls<'static>;
     type Output = PathBuf;
     const ONLY_BUILD_TARGETS: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -1207,6 +1217,7 @@ pub struct Extended<'a> {
 }
 
 impl<'a> Step<'a> for Extended<'a> {
+    type Id = Extended<'static>;
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_BUILD_TARGETS: bool = true;
@@ -1613,6 +1624,7 @@ fn add_env(build: &Build, cmd: &mut Command, target: &str) {
 pub struct HashSign;
 
 impl<'a> Step<'a> for HashSign {
+    type Id = HashSign;
     type Output = ();
     const ONLY_BUILD_TARGETS: bool = true;
     const ONLY_HOSTS: bool = true;
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
index d12f93f7f6d..56715d284a6 100644
--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -40,6 +40,7 @@ macro_rules! book {
         }
 
         impl<'a> Step<'a> for $name<'a> {
+            type Id = $name<'static>;
             type Output = ();
             const DEFAULT: bool = true;
 
@@ -99,6 +100,7 @@ pub struct Rustbook<'a> {
 }
 
 impl<'a> Step<'a> for Rustbook<'a> {
+    type Id = Rustbook<'static>;
     type Output = ();
 
     /// Invoke `rustbook` for `target` for the doc book `name`.
@@ -134,6 +136,7 @@ pub struct UnstableBook<'a> {
 }
 
 impl<'a> Step<'a> for UnstableBook<'a> {
+    type Id = UnstableBook<'static>;
     type Output = ();
     const DEFAULT: bool = true;
 
@@ -172,6 +175,7 @@ pub struct RustbookSrc<'a> {
 }
 
 impl<'a> Step<'a> for RustbookSrc<'a> {
+    type Id = UnstableBook<'static>;
     type Output = ();
 
     /// Invoke `rustbook` for `target` for the doc book `name` from the `src` path.
@@ -220,6 +224,7 @@ pub struct TheBook<'a> {
 }
 
 impl<'a> Step<'a> for TheBook<'a> {
+    type Id = TheBook<'static>;
     type Output = ();
 
     fn should_run(_builder: &Builder, path: &Path) -> bool {
@@ -341,6 +346,7 @@ pub struct Standalone<'a> {
 }
 
 impl<'a> Step<'a> for Standalone<'a> {
+    type Id = Standalone<'static>;
     type Output = ();
     const DEFAULT: bool = true;
 
@@ -448,6 +454,7 @@ pub struct Std<'a> {
 }
 
 impl<'a> Step<'a> for Std<'a> {
+    type Id = Std<'static>;
     type Output = ();
     const DEFAULT: bool = true;
 
@@ -559,6 +566,7 @@ pub struct Test<'a> {
 }
 
 impl<'a> Step<'a> for Test<'a> {
+    type Id = Test<'static>;
     type Output = ();
     const DEFAULT: bool = true;
 
@@ -646,6 +654,7 @@ pub struct Rustc<'a> {
 }
 
 impl<'a> Step<'a> for Rustc<'a> {
+    type Id = Rustc<'static>;
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -746,6 +755,7 @@ pub struct ErrorIndex<'a> {
 }
 
 impl<'a> Step<'a> for ErrorIndex<'a> {
+    type Id = ErrorIndex<'static>;
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -808,6 +818,7 @@ pub struct UnstableBookGen<'a> {
 }
 
 impl<'a> Step<'a> for UnstableBookGen<'a> {
+    type Id = UnstableBookGen<'static>;
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
index 4ceeb3e6793..a7d36bfa70c 100644
--- a/src/bootstrap/install.rs
+++ b/src/bootstrap/install.rs
@@ -135,6 +135,7 @@ macro_rules! install {
         }
 
         impl<'a> Step<'a> for $name<'a> {
+            type Id = $name<'static>;
             type Output = ();
             const DEFAULT: bool = true;
             const ONLY_BUILD_TARGETS: bool = true;
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index d7f1570ba80..68465604db6 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -116,7 +116,6 @@
 #![deny(warnings)]
 #![allow(stable_features)]
 #![feature(associated_consts)]
-#![feature(core_intrinsics)]
 
 #[macro_use]
 extern crate build_helper;
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 06af4ceac12..d8dc9f76702 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -51,6 +51,7 @@ pub struct Llvm<'a> {
 }
 
 impl<'a> Step<'a> for Llvm<'a> {
+    type Id = Llvm<'static>;
     type Output = ();
     const ONLY_HOSTS: bool = true;
 
@@ -250,6 +251,7 @@ pub struct TestHelpers<'a> {
 }
 
 impl<'a> Step<'a> for TestHelpers<'a> {
+    type Id = TestHelpers<'static>;
     type Output = ();
 
     fn should_run(_builder: &Builder, path: &Path) -> bool {
@@ -310,6 +312,7 @@ pub struct Openssl<'a> {
 }
 
 impl<'a> Step<'a> for Openssl<'a> {
+    type Id = Openssl<'static>;
     type Output = ();
 
     fn should_run(_builder: &Builder, _path: &Path) -> bool {
diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
index 63404bcf500..27785506eae 100644
--- a/src/bootstrap/tool.rs
+++ b/src/bootstrap/tool.rs
@@ -52,6 +52,7 @@ pub struct CleanTools<'a> {
 }
 
 impl<'a> Step<'a> for CleanTools<'a> {
+    type Id = CleanTools<'static>;
     type Output = ();
 
     /// Build a tool in `src/tools`
@@ -86,6 +87,7 @@ pub struct ToolBuild<'a> {
 }
 
 impl<'a> Step<'a> for ToolBuild<'a> {
+    type Id = ToolBuild<'static>;
     type Output = PathBuf;
 
     /// Build a tool in `src/tools`
@@ -172,6 +174,7 @@ macro_rules! tool {
         }
 
         impl<'a> Step<'a> for $name<'a> {
+            type Id = $name<'static>;
             type Output = PathBuf;
 
             fn should_run(_builder: &Builder, path: &Path) -> bool {
@@ -258,6 +261,7 @@ pub struct RemoteTestServer<'a> {
 }
 
 impl<'a> Step<'a> for RemoteTestServer<'a> {
+    type Id = RemoteTestServer<'static>;
     type Output = PathBuf;
 
     fn should_run(_builder: &Builder, path: &Path) -> bool {
@@ -302,6 +306,7 @@ pub struct Cargo<'a> {
 }
 
 impl<'a> Step<'a> for Cargo<'a> {
+    type Id = Cargo<'static>;
     type Output = PathBuf;
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
@@ -359,6 +364,7 @@ pub struct Rls<'a> {
 }
 
 impl<'a> Step<'a> for Rls<'a> {
+    type Id = Rls<'static>;
     type Output = PathBuf;
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;