Skip to content

Commit 9c31d76

Browse files
authored
Auto merge of #36821 - pweaver:master, r=michaelwoerister
#36821 I am just starting to learn rust. Feedback would be appreciated.
2 parents 7a26aec + 7cf90d0 commit 9c31d76

File tree

1 file changed

+14
-3
lines changed
  • src/librustc_incremental/persist

1 file changed

+14
-3
lines changed

src/librustc_incremental/persist/fs.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,21 @@ pub fn prepare_session_directory(tcx: TyCtxt) -> Result<bool, ()> {
234234
let print_file_copy_stats = tcx.sess.opts.debugging_opts.incremental_info;
235235

236236
// Try copying over all files from the source directory
237-
if copy_files(&session_dir, &source_directory, print_file_copy_stats).is_ok() {
237+
if let Ok(allows_links) = copy_files(&session_dir, &source_directory,
238+
print_file_copy_stats) {
238239
debug!("successfully copied data from: {}",
239240
source_directory.display());
240241

242+
if !allows_links {
243+
tcx.sess.warn(&format!("Hard linking files in the incremental \
244+
compilation cache failed. Copying files \
245+
instead. Consider moving the cache \
246+
directory to a file system which supports \
247+
hard linking in session dir `{}`",
248+
session_dir.display())
249+
);
250+
}
251+
241252
tcx.sess.init_incr_comp_session(session_dir, directory_lock);
242253
return Ok(true)
243254
} else {
@@ -357,7 +368,7 @@ pub fn delete_all_session_dir_contents(sess: &Session) -> io::Result<()> {
357368
fn copy_files(target_dir: &Path,
358369
source_dir: &Path,
359370
print_stats_on_success: bool)
360-
-> Result<(), ()> {
371+
-> Result<bool, ()> {
361372
// We acquire a shared lock on the lock file of the directory, so that
362373
// nobody deletes it out from under us while we are reading from it.
363374
let lock_file_path = lock_file_path(source_dir);
@@ -409,7 +420,7 @@ fn copy_files(target_dir: &Path,
409420
println!("incr. comp. session directory: {} files copied", files_copied);
410421
}
411422

412-
Ok(())
423+
Ok(files_linked > 0 || files_copied == 0)
413424
}
414425

415426
/// Generate unique directory path of the form:

0 commit comments

Comments
 (0)