]> git.lizzy.rs Git - rust.git/commitdiff
rustbuild: Use copies instead of hard links
authorAlex Crichton <alex@alexcrichton.com>
Sat, 4 Feb 2017 01:12:58 +0000 (17:12 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 9 Mar 2017 15:00:13 +0000 (07:00 -0800)
The original motivation for hard links was to speed up the various stages of
rustbuild, but in the end this is causing problems on Windows (#39504).

This commit tweaks the build system to use copies instead of hard links
unconditionally to ensure that the files accessed by Windows are always
disjoint.

Locally this added .3s to a noop build, so it shouldn't be too much of a
regression hopefully!

src/bootstrap/util.rs
src/stage0.txt

index 520514f5fc95a77871ad6db413d9b30e5ad56fd8..fc63655d79b6c3b414cd2e4404dc6bfe2883b621 100644 (file)
@@ -20,6 +20,8 @@
 use std::process::Command;
 use std::time::Instant;
 
+use filetime::{self, FileTime};
+
 /// Returns the `name` as the filename of a static library for `target`.
 pub fn staticlib(name: &str, target: &str) -> String {
     if target.contains("windows") {
@@ -38,12 +40,18 @@ pub fn copy(src: &Path, dst: &Path) {
 
     // Attempt to "easy copy" by creating a hard link (symlinks don't work on
     // windows), but if that fails just fall back to a slow `copy` operation.
-    let res = fs::hard_link(src, dst);
-    let res = res.or_else(|_| fs::copy(src, dst).map(|_| ()));
+    // let res = fs::hard_link(src, dst);
+    let res = fs::copy(src, dst);
     if let Err(e) = res {
         panic!("failed to copy `{}` to `{}`: {}", src.display(),
                dst.display(), e)
     }
+    let metadata = t!(src.metadata());
+    t!(fs::set_permissions(dst, metadata.permissions()));
+    let atime = FileTime::from_last_access_time(&metadata);
+    let mtime = FileTime::from_last_modification_time(&metadata);
+    t!(filetime::set_file_times(dst, atime, mtime));
+
 }
 
 /// Copies the `src` directory recursively to `dst`. Both are assumed to exist
index cda9a5a96432b9e308c9add87f2a1f0b216a07cd..772029ab0c253fc571578706b069de4057765555 100644 (file)
@@ -13,4 +13,4 @@
 # released on `$date`
 
 rustc: beta-2017-02-01
-cargo: bfee18f73287687c543bda8c35e4e33808792715
+cargo: 407edef22e894266eb562618cba5ca9757051946