@@ -234,10 +234,19 @@ pub fn prepare_session_directory(tcx: TyCtxt) -> Result<bool, ()> {
234
234
let print_file_copy_stats = tcx. sess . opts . debugging_opts . incremental_info ;
235
235
236
236
// 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) {
238
239
debug ! ( "successfully copied data from: {}" ,
239
240
source_directory. display( ) ) ;
240
241
242
+ if !allows_links {
243
+ tcx. sess . warn ( & format ! ( "Hard linking files in the incremental compilation
244
+ cache failed. Copying files instead. Consider moving the cache directory to a
245
+ file system which supports hard linking in session dir `{}`"
246
+ , session_dir. display( ) )
247
+ ) ;
248
+ }
249
+
241
250
tcx. sess . init_incr_comp_session ( session_dir, directory_lock) ;
242
251
return Ok ( true )
243
252
} else {
@@ -357,7 +366,7 @@ pub fn delete_all_session_dir_contents(sess: &Session) -> io::Result<()> {
357
366
fn copy_files ( target_dir : & Path ,
358
367
source_dir : & Path ,
359
368
print_stats_on_success : bool )
360
- -> Result < ( ) , ( ) > {
369
+ -> Result < bool , ( ) > {
361
370
// We acquire a shared lock on the lock file of the directory, so that
362
371
// nobody deletes it out from under us while we are reading from it.
363
372
let lock_file_path = lock_file_path ( source_dir) ;
@@ -409,7 +418,7 @@ fn copy_files(target_dir: &Path,
409
418
println ! ( "incr. comp. session directory: {} files copied" , files_copied) ;
410
419
}
411
420
412
- Ok ( ( ) )
421
+ Ok ( files_linked > 0 || files_copied == 0 )
413
422
}
414
423
415
424
/// Generate unique directory path of the form:
0 commit comments