@@ -456,27 +456,39 @@ fn reuse_workproduct_for_cgu(
456
456
& work_product. saved_files . get ( "o" ) . expect ( "no saved object file in work product" ) ,
457
457
) ;
458
458
459
- if let Err ( err) = rustc_fs_util:: link_or_copy ( & source_file_regular, & obj_out_regular) {
460
- return Err ( format ! (
461
- "unable to copy {} to {}: {}" ,
462
- source_file_regular. display( ) ,
463
- obj_out_regular. display( ) ,
464
- err
465
- ) ) ;
466
- }
467
- let obj_out_global_asm =
468
- crate :: global_asm:: add_file_stem_postfix ( obj_out_regular. clone ( ) , ".asm" ) ;
469
- let has_global_asm = if let Some ( asm_o) = work_product. saved_files . get ( "asm.o" ) {
470
- let source_file_global_asm = rustc_incremental:: in_incr_comp_dir_sess ( & tcx. sess , asm_o) ;
471
- if let Err ( err) = rustc_fs_util:: link_or_copy ( & source_file_global_asm, & obj_out_global_asm)
472
- {
459
+ let mut links_from_incr_cache = Vec :: new ( ) ;
460
+
461
+ match rustc_fs_util:: link_or_copy ( & source_file_regular, & obj_out_regular) {
462
+ Err ( err) => {
473
463
return Err ( format ! (
474
464
"unable to copy {} to {}: {}" ,
475
465
source_file_regular. display( ) ,
476
466
obj_out_regular. display( ) ,
477
467
err
478
468
) ) ;
479
469
}
470
+ Ok ( _) => {
471
+ links_from_incr_cache. push ( source_file_regular) ;
472
+ }
473
+ }
474
+
475
+ let obj_out_global_asm =
476
+ crate :: global_asm:: add_file_stem_postfix ( obj_out_regular. clone ( ) , ".asm" ) ;
477
+ let has_global_asm = if let Some ( asm_o) = work_product. saved_files . get ( "asm.o" ) {
478
+ let source_file_global_asm = rustc_incremental:: in_incr_comp_dir_sess ( & tcx. sess , asm_o) ;
479
+ match rustc_fs_util:: link_or_copy ( & source_file_global_asm, & obj_out_global_asm) {
480
+ Err ( err) => {
481
+ return Err ( format ! (
482
+ "unable to copy {} to {}: {}" ,
483
+ source_file_global_asm. display( ) ,
484
+ obj_out_global_asm. display( ) ,
485
+ err
486
+ ) ) ;
487
+ }
488
+ Ok ( _) => {
489
+ links_from_incr_cache. push ( source_file_global_asm) ;
490
+ }
491
+ }
480
492
true
481
493
} else {
482
494
false
@@ -491,7 +503,7 @@ fn reuse_workproduct_for_cgu(
491
503
bytecode : None ,
492
504
assembly : None ,
493
505
llvm_ir : None ,
494
- links_from_incr_cache : Vec :: new ( ) ,
506
+ links_from_incr_cache : links_from_incr_cache . clone ( ) ,
495
507
} ,
496
508
module_global_asm : has_global_asm. then ( || CompiledModule {
497
509
name : cgu. name ( ) . to_string ( ) ,
@@ -501,7 +513,7 @@ fn reuse_workproduct_for_cgu(
501
513
bytecode : None ,
502
514
assembly : None ,
503
515
llvm_ir : None ,
504
- links_from_incr_cache : Vec :: new ( ) ,
516
+ links_from_incr_cache,
505
517
} ) ,
506
518
existing_work_product : Some ( ( cgu. work_product_id ( ) , work_product) ) ,
507
519
} )
0 commit comments