about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoshua Nelson <github@jyn.dev>2022-05-10 10:58:52 -0500
committerGitHub <noreply@github.com>2022-05-10 10:58:52 -0500
commit89e0c29489ee6375927e86eaf5e5a8080dc8f24e (patch)
tree0f9346727c0c61836bc193297d5ad0b2958ac1e0
parenteead58e75bb3a1d9f00b5a988704328fed6bb2c9 (diff)
downloadrust-89e0c29489ee6375927e86eaf5e5a8080dc8f24e.tar.gz
rust-89e0c29489ee6375927e86eaf5e5a8080dc8f24e.zip
Revert "Make "Assemble stage1 compiler" orders of magnitude faster"
-rw-r--r--src/bootstrap/lib.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index b2279bc8b56..5d32b4f801a 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -1497,14 +1497,20 @@ impl Build {
         let dst = dstdir.join(src.file_name().unwrap());
         self.verbose_than(1, &format!("Install {:?} to {:?}", src, dst));
         t!(fs::create_dir_all(dstdir));
+        drop(fs::remove_file(&dst));
         {
             if !src.exists() {
                 panic!("Error: File \"{}\" not found!", src.display());
             }
-            self.copy(src, &dst);
+            let metadata = t!(src.symlink_metadata());
+            if let Err(e) = fs::copy(&src, &dst) {
+                panic!("failed to copy `{}` to `{}`: {}", src.display(), dst.display(), e)
+            }
+            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));
         }
-        // NOTE: when using hard-links, this will also update the permissions on the original file.
-        // We never use permissions that are more restrictive than the original, so this shouldn't cause any issues.
         chmod(&dst, perms);
     }