about summary refs log tree commit diff
path: root/compiler/rustc_incremental
diff options
context:
space:
mode:
authorBen Kimock <kimockb@gmail.com>2024-07-28 16:54:14 -0400
committerBen Kimock <kimockb@gmail.com>2025-02-24 19:46:48 -0500
commitcae7c76d509386ea29a90c4001bb8dbc59c79d22 (patch)
tree809697abba06a0f819405dbbeb601ee5b7201f37 /compiler/rustc_incremental
parent9af8985e059071ea2e0566969a4f140eca73fca9 (diff)
downloadrust-cae7c76d509386ea29a90c4001bb8dbc59c79d22.tar.gz
rust-cae7c76d509386ea29a90c4001bb8dbc59c79d22.zip
Avoid no-op unlink+link dances in incr comp
Diffstat (limited to 'compiler/rustc_incremental')
-rw-r--r--compiler/rustc_incremental/src/persist/work_product.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_incremental/src/persist/work_product.rs b/compiler/rustc_incremental/src/persist/work_product.rs
index 048981f0d5c..7b1eb0a82e3 100644
--- a/compiler/rustc_incremental/src/persist/work_product.rs
+++ b/compiler/rustc_incremental/src/persist/work_product.rs
@@ -3,7 +3,7 @@
 //! [work products]: WorkProduct
 
 use std::fs as std_fs;
-use std::path::Path;
+use std::path::{Path, PathBuf};
 
 use rustc_data_structures::unord::UnordMap;
 use rustc_fs_util::link_or_copy;
@@ -20,6 +20,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
     sess: &Session,
     cgu_name: &str,
     files: &[(&'static str, &Path)],
+    known_links: &[PathBuf],
 ) -> Option<(WorkProductId, WorkProduct)> {
     debug!(?cgu_name, ?files);
     sess.opts.incremental.as_ref()?;
@@ -28,6 +29,10 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
     for (ext, path) in files {
         let file_name = format!("{cgu_name}.{ext}");
         let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
+        if known_links.contains(&path_in_incr_dir) {
+            let _ = saved_files.insert(ext.to_string(), file_name);
+            continue;
+        }
         match link_or_copy(path, &path_in_incr_dir) {
             Ok(_) => {
                 let _ = saved_files.insert(ext.to_string(), file_name);