From 5e3aaab2f67abfc9f92f9d1a59ed62ea71cdab5e Mon Sep 17 00:00:00 2001 From: "Pweaver (Paul Weaver)" Date: Wed, 28 Sep 2016 22:08:44 -0400 Subject: [PATCH 1/2] #36680 add warning when compliation cache fails to hard link --- src/librustc_incremental/persist/fs.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index 2d28afeaebf..14e4f421961 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -234,10 +234,19 @@ pub fn prepare_session_directory(tcx: TyCtxt) -> Result { let print_file_copy_stats = tcx.sess.opts.debugging_opts.incremental_info; // Try copying over all files from the source directory - if copy_files(&session_dir, &source_directory, print_file_copy_stats).is_ok() { + if let Ok(allows_links) = copy_files(&session_dir, &source_directory, + print_file_copy_stats) { debug!("successfully copied data from: {}", source_directory.display()); + if !allows_links { + tcx.sess.warn(&format!("Hard linking files in the incremental compilation + cache failed. Copying files instead. Consider moving the cache directory to a + file system which supports hard linking in session dir `{}`" + , session_dir.display()) + ); + } + tcx.sess.init_incr_comp_session(session_dir, directory_lock); return Ok(true) } else { @@ -357,7 +366,7 @@ pub fn delete_all_session_dir_contents(sess: &Session) -> io::Result<()> { fn copy_files(target_dir: &Path, source_dir: &Path, print_stats_on_success: bool) - -> Result<(), ()> { + -> Result { // We acquire a shared lock on the lock file of the directory, so that // nobody deletes it out from under us while we are reading from it. let lock_file_path = lock_file_path(source_dir); @@ -409,7 +418,7 @@ fn copy_files(target_dir: &Path, println!("incr. comp. session directory: {} files copied", files_copied); } - Ok(()) + Ok(files_linked > 0 || files_copied == 0) } /// Generate unique directory path of the form: From 7cf90d0a1d133b41b06c09272b6f645c142e7ade Mon Sep 17 00:00:00 2001 From: "Pweaver (Paul Weaver)" Date: Mon, 3 Oct 2016 15:18:27 -0400 Subject: [PATCH 2/2] fixes multi-line string whitespace in librustc_incremental/persist/fs.rs --- src/librustc_incremental/persist/fs.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index 14e4f421961..1beb906c596 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -240,10 +240,12 @@ pub fn prepare_session_directory(tcx: TyCtxt) -> Result { source_directory.display()); if !allows_links { - tcx.sess.warn(&format!("Hard linking files in the incremental compilation - cache failed. Copying files instead. Consider moving the cache directory to a - file system which supports hard linking in session dir `{}`" - , session_dir.display()) + tcx.sess.warn(&format!("Hard linking files in the incremental \ + compilation cache failed. Copying files \ + instead. Consider moving the cache \ + directory to a file system which supports \ + hard linking in session dir `{}`", + session_dir.display()) ); }