Skip to content

#36680 add warning when compliation cache fails to hard link #36821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/librustc_incremental/persist/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,19 @@ pub fn prepare_session_directory(tcx: TyCtxt) -> Result<bool, ()> {
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 `{}`"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have a string that spans multiple lines, you can place a \ at the end of the line. That will (iirc) cause the parser to ignore the leading whitespace in the next line:

// This...
let s = "123
         456"
// ... is equivalent to this:
let s = "123\n         456"
// while this:
let s = "123\
         456"
// is equivalent to this:
let s = "123456"

Copy link
Member

@michaelwoerister michaelwoerister Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above call would then become the following:

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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more idiomatic to place the comma at the end of previous line.

);
}

tcx.sess.init_incr_comp_session(session_dir, directory_lock);
return Ok(true)
} else {
Expand Down Expand Up @@ -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<bool, ()> {
// 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);
Expand Down Expand Up @@ -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:
Expand Down