diff options
| author | bors <bors@rust-lang.org> | 2022-05-10 03:11:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-10 03:11:05 +0000 |
| commit | 87fd70c107b23fe08336a12a20a0f5e85561d499 (patch) | |
| tree | 997f3eb1fa15a33db5dd604227aa031dca1a94ec | |
| parent | 362010d6be0e551fa35c6e0488abb18686b2add4 (diff) | |
| parent | 5f4b174de28e5a07c9924d69af2c018048676956 (diff) | |
| download | rust-87fd70c107b23fe08336a12a20a0f5e85561d499.tar.gz rust-87fd70c107b23fe08336a12a20a0f5e85561d499.zip | |
Auto merge of #96803 - jyn514:faster-assemble, r=Mark-Simulacrum
Make "Assemble stage1 compiler" orders of magnitude faster
This used to take upwards of 5 seconds for me locally. I found that the culprit was copying the downloaded LLVM shared object:
```
[22:28:03] Install "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so" to "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-14-rust-1.62.0-nightly.so"
[22:28:09] c Sysroot { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) } }
```
It turned out that `install()` used full copies unconditionally. Change it to try using a hard-link before falling back to copying.
| -rw-r--r-- | src/bootstrap/lib.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 5d32b4f801a..b2279bc8b56 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1497,20 +1497,14 @@ 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()); } - 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)); + self.copy(src, &dst); } + // 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); } |
