@@ -540,9 +540,12 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
540540 if let Some ( path) = & module. bytecode {
541541 files. push ( ( OutputType :: Bitcode . extension ( ) , path. as_path ( ) ) ) ;
542542 }
543- if let Some ( ( id, product) ) =
544- copy_cgu_workproduct_to_incr_comp_cache_dir ( sess, & module. name , files. as_slice ( ) )
545- {
543+ if let Some ( ( id, product) ) = copy_cgu_workproduct_to_incr_comp_cache_dir (
544+ sess,
545+ & module. name ,
546+ files. as_slice ( ) ,
547+ & module. links_from_incr_cache ,
548+ ) {
546549 work_products. insert ( id, product) ;
547550 }
548551 }
@@ -934,7 +937,9 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
934937) -> WorkItemResult < B > {
935938 let incr_comp_session_dir = cgcx. incr_comp_session_dir . as_ref ( ) . unwrap ( ) ;
936939
937- let load_from_incr_comp_dir = |output_path : PathBuf , saved_path : & str | {
940+ let mut links_from_incr_cache = Vec :: new ( ) ;
941+
942+ let mut load_from_incr_comp_dir = |output_path : PathBuf , saved_path : & str | {
938943 let source_file = in_incr_comp_dir ( incr_comp_session_dir, saved_path) ;
939944 debug ! (
940945 "copying preexisting module `{}` from {:?} to {}" ,
@@ -943,7 +948,10 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
943948 output_path. display( )
944949 ) ;
945950 match link_or_copy ( & source_file, & output_path) {
946- Ok ( _) => Some ( output_path) ,
951+ Ok ( _) => {
952+ links_from_incr_cache. push ( source_file) ;
953+ Some ( output_path)
954+ }
947955 Err ( error) => {
948956 cgcx. create_dcx ( ) . handle ( ) . emit_err ( errors:: CopyPathBuf {
949957 source_file,
@@ -966,7 +974,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
966974 load_from_incr_comp_dir ( dwarf_obj_out, saved_dwarf_object_file)
967975 } ) ;
968976
969- let load_from_incr_cache = |perform, output_type : OutputType | {
977+ let mut load_from_incr_cache = |perform, output_type : OutputType | {
970978 if perform {
971979 let saved_file = module. source . saved_files . get ( output_type. extension ( ) ) ?;
972980 let output_path = cgcx. output_filenames . temp_path ( output_type, Some ( & module. name ) ) ;
@@ -986,6 +994,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
986994 }
987995
988996 WorkItemResult :: Finished ( CompiledModule {
997+ links_from_incr_cache,
989998 name : module. name ,
990999 kind : ModuleKind :: Regular ,
9911000 object,
0 commit comments