@@ -18,7 +18,7 @@ use rustc_errors::{
18
18
Diag , DiagArgMap , DiagCtxt , DiagMessage , ErrCode , FatalError , FluentBundle , Level , MultiSpan ,
19
19
Style , Suggestions ,
20
20
} ;
21
- use rustc_fs_util:: link_or_copy;
21
+ use rustc_fs_util:: { LinkOrCopy , link_or_copy} ;
22
22
use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
23
23
use rustc_incremental:: {
24
24
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(
540
540
if let Some ( path) = & module. bytecode {
541
541
files. push ( ( OutputType :: Bitcode . extension ( ) , path. as_path ( ) ) ) ;
542
542
}
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
+ ) {
546
549
work_products. insert ( id, product) ;
547
550
}
548
551
}
@@ -934,7 +937,9 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
934
937
) -> WorkItemResult < B > {
935
938
let incr_comp_session_dir = cgcx. incr_comp_session_dir . as_ref ( ) . unwrap ( ) ;
936
939
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 | {
938
943
let source_file = in_incr_comp_dir ( incr_comp_session_dir, saved_path) ;
939
944
debug ! (
940
945
"copying preexisting module `{}` from {:?} to {}" ,
@@ -943,7 +948,11 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
943
948
output_path. display( )
944
949
) ;
945
950
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
+ }
947
956
Err ( error) => {
948
957
cgcx. create_dcx ( ) . handle ( ) . emit_err ( errors:: CopyPathBuf {
949
958
source_file,
@@ -966,7 +975,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
966
975
load_from_incr_comp_dir ( dwarf_obj_out, saved_dwarf_object_file)
967
976
} ) ;
968
977
969
- let load_from_incr_cache = |perform, output_type : OutputType | {
978
+ let mut load_from_incr_cache = |perform, output_type : OutputType | {
970
979
if perform {
971
980
let saved_file = module. source . saved_files . get ( output_type. extension ( ) ) ?;
972
981
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>(
986
995
}
987
996
988
997
WorkItemResult :: Finished ( CompiledModule {
998
+ links_from_incr_cache,
989
999
name : module. name ,
990
1000
kind : ModuleKind :: Regular ,
991
1001
object,
0 commit comments