@@ -234,10 +234,19 @@ 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 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+
241250 tcx. sess . init_incr_comp_session ( session_dir, directory_lock) ;
242251 return Ok ( true )
243252 } else {
@@ -357,7 +366,7 @@ pub fn delete_all_session_dir_contents(sess: &Session) -> io::Result<()> {
357366fn copy_files ( target_dir : & Path ,
358367 source_dir : & Path ,
359368 print_stats_on_success : bool )
360- -> Result < ( ) , ( ) > {
369+ -> Result < bool , ( ) > {
361370 // We acquire a shared lock on the lock file of the directory, so that
362371 // nobody deletes it out from under us while we are reading from it.
363372 let lock_file_path = lock_file_path ( source_dir) ;
@@ -409,7 +418,7 @@ fn copy_files(target_dir: &Path,
409418 println ! ( "incr. comp. session directory: {} files copied" , files_copied) ;
410419 }
411420
412- Ok ( ( ) )
421+ Ok ( files_linked > 0 || files_copied == 0 )
413422}
414423
415424/// Generate unique directory path of the form:
0 commit comments