about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-02-24 16:06:15 +0000
committerbors <bors@rust-lang.org>2017-02-24 16:06:15 +0000
commit08230775a026c955873ba557e624b7f665661f37 (patch)
tree615753c55e92641acdf969bb0f6aedcffb6cafe2 /src
parent9f082d21113a51221d6ee17ff81215e4b325a7be (diff)
parent0c4c6fdb6cdd35a0e1f729f40de10ee4e6324432 (diff)
downloadrust-08230775a026c955873ba557e624b7f665661f37.tar.gz
rust-08230775a026c955873ba557e624b7f665661f37.zip
Auto merge of #39892 - petrochenkov:rt, r=alexcrichton
Fix test caching on Windows/GNU

Addresses https://github.com/rust-lang/rust/issues/36385#issuecomment-277131231

Previously the sysroot directory was purged on every build and mingw startup objects were rebuilt unconditionally and always triggered test reruns.
Now mingw startup objects are built in the native directory and then copied into the sysroot directory. They are also rebuilt only when necessary, so test caching works.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/compile.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 00904bc776a..cea8b133666 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -21,7 +21,7 @@ use std::fs::{self, File};
 use std::path::{Path, PathBuf};
 use std::process::Command;
 
-use build_helper::{output, mtime};
+use build_helper::{output, mtime, up_to_date};
 use filetime::FileTime;
 
 use util::{exe, libdir, is_dylib, copy};
@@ -132,21 +132,29 @@ pub fn build_startup_objects(build: &Build, for_compiler: &Compiler, target: &st
 
     let compiler = Compiler::new(0, &build.config.build);
     let compiler_path = build.compiler_path(&compiler);
-    let into = build.sysroot_libdir(for_compiler, target);
-    t!(fs::create_dir_all(&into));
-
-    for file in t!(fs::read_dir(build.src.join("src/rtstartup"))) {
-        let file = t!(file);
-        let mut cmd = Command::new(&compiler_path);
-        build.run(cmd.env("RUSTC_BOOTSTRAP", "1")
-                     .arg("--target").arg(target)
-                     .arg("--emit=obj")
-                     .arg("--out-dir").arg(&into)
-                     .arg(file.path()));
+    let src_dir = &build.src.join("src/rtstartup");
+    let dst_dir = &build.native_dir(target).join("rtstartup");
+    let sysroot_dir = &build.sysroot_libdir(for_compiler, target);
+    t!(fs::create_dir_all(dst_dir));
+    t!(fs::create_dir_all(sysroot_dir));
+
+    for file in &["rsbegin", "rsend"] {
+        let src_file = &src_dir.join(file.to_string() + ".rs");
+        let dst_file = &dst_dir.join(file.to_string() + ".o");
+        if !up_to_date(src_file, dst_file) {
+            let mut cmd = Command::new(&compiler_path);
+            build.run(cmd.env("RUSTC_BOOTSTRAP", "1")
+                        .arg("--target").arg(target)
+                        .arg("--emit=obj")
+                        .arg("--out-dir").arg(dst_dir)
+                        .arg(src_file));
+        }
+
+        copy(dst_file, &sysroot_dir.join(file.to_string() + ".o"));
     }
 
     for obj in ["crt2.o", "dllcrt2.o"].iter() {
-        copy(&compiler_file(build.cc(target), obj), &into.join(obj));
+        copy(&compiler_file(build.cc(target), obj), &sysroot_dir.join(obj));
     }
 }