@@ -17,7 +17,7 @@ use rustc_errors::{
1717 Diag , DiagArgMap , DiagCtxt , DiagMessage , ErrCode , FatalError , FluentBundle , Level , MultiSpan ,
1818 Style , Suggestions ,
1919} ;
20- use rustc_fs_util:: link_or_copy;
20+ use rustc_fs_util:: { LinkOrCopy , link_or_copy} ;
2121use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
2222use rustc_incremental:: {
2323 copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
@@ -527,9 +527,12 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
527527 if let Some ( path) = & module. bytecode {
528528 files. push ( ( OutputType :: Bitcode . extension ( ) , path. as_path ( ) ) ) ;
529529 }
530- if let Some ( ( id, product) ) =
531- copy_cgu_workproduct_to_incr_comp_cache_dir ( sess, & module. name , files. as_slice ( ) )
532- {
530+ if let Some ( ( id, product) ) = copy_cgu_workproduct_to_incr_comp_cache_dir (
531+ sess,
532+ & module. name ,
533+ files. as_slice ( ) ,
534+ & module. links_from_incr_cache ,
535+ ) {
533536 work_products. insert ( id, product) ;
534537 }
535538 }
@@ -921,7 +924,9 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
921924) -> WorkItemResult < B > {
922925 let incr_comp_session_dir = cgcx. incr_comp_session_dir . as_ref ( ) . unwrap ( ) ;
923926
924- let load_from_incr_comp_dir = |output_path : PathBuf , saved_path : & str | {
927+ let mut links_from_incr_cache = Vec :: new ( ) ;
928+
929+ let mut load_from_incr_comp_dir = |output_path : PathBuf , saved_path : & str | {
925930 let source_file = in_incr_comp_dir ( incr_comp_session_dir, saved_path) ;
926931 debug ! (
927932 "copying preexisting module `{}` from {:?} to {}" ,
@@ -930,7 +935,11 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
930935 output_path. display( )
931936 ) ;
932937 match link_or_copy ( & source_file, & output_path) {
933- Ok ( _) => Some ( output_path) ,
938+ Ok ( LinkOrCopy :: Copy ) => Some ( output_path) ,
939+ Ok ( LinkOrCopy :: Link ) => {
940+ links_from_incr_cache. push ( source_file) ;
941+ Some ( output_path)
942+ }
934943 Err ( error) => {
935944 cgcx. create_dcx ( ) . handle ( ) . emit_err ( errors:: CopyPathBuf {
936945 source_file,
@@ -953,7 +962,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
953962 load_from_incr_comp_dir ( dwarf_obj_out, saved_dwarf_object_file)
954963 } ) ;
955964
956- let load_from_incr_cache = |perform, output_type : OutputType | {
965+ let mut load_from_incr_cache = |perform, output_type : OutputType | {
957966 if perform {
958967 let saved_file = module. source . saved_files . get ( output_type. extension ( ) ) ?;
959968 let output_path = cgcx. output_filenames . temp_path ( output_type, Some ( & module. name ) ) ;
@@ -973,6 +982,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
973982 }
974983
975984 WorkItemResult :: Finished ( CompiledModule {
985+ links_from_incr_cache,
976986 name : module. name ,
977987 kind : ModuleKind :: Regular ,
978988 object,
0 commit comments