@@ -18,7 +18,7 @@ use rustc_errors::{
1818 Diag , DiagArgMap , DiagCtxt , DiagMessage , ErrCode , FatalError , FluentBundle , Level , MultiSpan ,
1919 Style , Suggestions ,
2020} ;
21- use rustc_fs_util:: link_or_copy;
21+ use rustc_fs_util:: { LinkOrCopy , link_or_copy} ;
2222use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
2323use rustc_incremental:: {
2424 copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
@@ -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,11 @@ 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 ( LinkOrCopy :: Copy ) => Some ( output_path) ,
952+ Ok ( LinkOrCopy :: Link ) => {
953+ links_from_incr_cache. push ( source_file) ;
954+ Some ( output_path)
955+ }
947956 Err ( error) => {
948957 cgcx. create_dcx ( ) . handle ( ) . emit_err ( errors:: CopyPathBuf {
949958 source_file,
@@ -966,7 +975,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
966975 load_from_incr_comp_dir ( dwarf_obj_out, saved_dwarf_object_file)
967976 } ) ;
968977
969- let load_from_incr_cache = |perform, output_type : OutputType | {
978+ let mut load_from_incr_cache = |perform, output_type : OutputType | {
970979 if perform {
971980 let saved_file = module. source . saved_files . get ( output_type. extension ( ) ) ?;
972981 let output_path = cgcx. output_filenames . temp_path ( output_type, Some ( & module. name ) ) ;
@@ -986,6 +995,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
986995 }
987996
988997 WorkItemResult :: Finished ( CompiledModule {
998+ links_from_incr_cache,
989999 name : module. name ,
9901000 kind : ModuleKind :: Regular ,
9911001 object,
0 commit comments