Skip to content

Commit 3be02fc

Browse files
committedMar 9, 2017
rustbuild: Use copies instead of hard links
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!
1 parent 3087a1f commit 3be02fc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
 

‎src/bootstrap/util.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ use std::path::{Path, PathBuf};
2020
use std::process::Command;
2121
use std::time::Instant;
2222

23+
use filetime::{self, FileTime};
24+
2325
/// Returns the `name` as the filename of a static library for `target`.
2426
pub fn staticlib(name: &str, target: &str) -> String {
2527
if target.contains("windows") {
@@ -38,12 +40,18 @@ pub fn copy(src: &Path, dst: &Path) {
3840

3941
// Attempt to "easy copy" by creating a hard link (symlinks don't work on
4042
// windows), but if that fails just fall back to a slow `copy` operation.
41-
let res = fs::hard_link(src, dst);
42-
let res = res.or_else(|_| fs::copy(src, dst).map(|_| ()));
43+
// let res = fs::hard_link(src, dst);
44+
let res = fs::copy(src, dst);
4345
if let Err(e) = res {
4446
panic!("failed to copy `{}` to `{}`: {}", src.display(),
4547
dst.display(), e)
4648
}
49+
let metadata = t!(src.metadata());
50+
t!(fs::set_permissions(dst, metadata.permissions()));
51+
let atime = FileTime::from_last_access_time(&metadata);
52+
let mtime = FileTime::from_last_modification_time(&metadata);
53+
t!(filetime::set_file_times(dst, atime, mtime));
54+
4755
}
4856

4957
/// Copies the `src` directory recursively to `dst`. Both are assumed to exist

‎src/stage0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# released on `$date`
1414

1515
rustc: beta-2017-02-01
16-
cargo: bfee18f73287687c543bda8c35e4e33808792715
16+
cargo: 407edef22e894266eb562618cba5ca9757051946

0 commit comments

Comments
 (0)
Please sign in to comment.