@@ -20,6 +20,7 @@ use rustc_errors::{
20
20
Style ,
21
21
} ;
22
22
use rustc_fs_util:: link_or_copy;
23
+ use rustc_fs_util:: LinkOrCopy ;
23
24
use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
24
25
use rustc_incremental:: {
25
26
copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
@@ -548,9 +549,12 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
548
549
if let Some ( path) = & module. bytecode {
549
550
files. push ( ( OutputType :: Bitcode . extension ( ) , path. as_path ( ) ) ) ;
550
551
}
551
- if let Some ( ( id, product) ) =
552
- copy_cgu_workproduct_to_incr_comp_cache_dir ( sess, & module. name , files. as_slice ( ) )
553
- {
552
+ if let Some ( ( id, product) ) = copy_cgu_workproduct_to_incr_comp_cache_dir (
553
+ sess,
554
+ & module. name ,
555
+ files. as_slice ( ) ,
556
+ & module. links_from_incr_cache ,
557
+ ) {
554
558
work_products. insert ( id, product) ;
555
559
}
556
560
}
@@ -942,7 +946,9 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
942
946
) -> WorkItemResult < B > {
943
947
let incr_comp_session_dir = cgcx. incr_comp_session_dir . as_ref ( ) . unwrap ( ) ;
944
948
945
- let load_from_incr_comp_dir = |output_path : PathBuf , saved_path : & str | {
949
+ let mut links_from_incr_cache = Vec :: new ( ) ;
950
+
951
+ let mut load_from_incr_comp_dir = |output_path : PathBuf , saved_path : & str | {
946
952
let source_file = in_incr_comp_dir ( incr_comp_session_dir, saved_path) ;
947
953
debug ! (
948
954
"copying preexisting module `{}` from {:?} to {}" ,
@@ -951,7 +957,11 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
951
957
output_path. display( )
952
958
) ;
953
959
match link_or_copy ( & source_file, & output_path) {
954
- Ok ( _) => Some ( output_path) ,
960
+ Ok ( LinkOrCopy :: Copy ) => Some ( output_path) ,
961
+ Ok ( LinkOrCopy :: Link ) => {
962
+ links_from_incr_cache. push ( source_file) ;
963
+ Some ( output_path)
964
+ }
955
965
Err ( error) => {
956
966
cgcx. create_dcx ( ) . handle ( ) . emit_err ( errors:: CopyPathBuf {
957
967
source_file,
@@ -974,7 +984,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
974
984
load_from_incr_comp_dir ( dwarf_obj_out, saved_dwarf_object_file)
975
985
} ) ;
976
986
977
- let load_from_incr_cache = |perform, output_type : OutputType | {
987
+ let mut load_from_incr_cache = |perform, output_type : OutputType | {
978
988
if perform {
979
989
let saved_file = module. source . saved_files . get ( output_type. extension ( ) ) ?;
980
990
let output_path = cgcx. output_filenames . temp_path ( output_type, Some ( & module. name ) ) ;
@@ -994,6 +1004,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
994
1004
}
995
1005
996
1006
WorkItemResult :: Finished ( CompiledModule {
1007
+ links_from_incr_cache,
997
1008
name : module. name ,
998
1009
kind : ModuleKind :: Regular ,
999
1010
object,
0 commit comments