@@ -456,27 +456,39 @@ fn reuse_workproduct_for_cgu(
456456 & work_product. saved_files . get ( "o" ) . expect ( "no saved object file in work product" ) ,
457457 ) ;
458458
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) => {
473463 return Err ( format ! (
474464 "unable to copy {} to {}: {}" ,
475465 source_file_regular. display( ) ,
476466 obj_out_regular. display( ) ,
477467 err
478468 ) ) ;
479469 }
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+ }
480492 true
481493 } else {
482494 false
@@ -491,7 +503,7 @@ fn reuse_workproduct_for_cgu(
491503 bytecode : None ,
492504 assembly : None ,
493505 llvm_ir : None ,
494- links_from_incr_cache : Vec :: new ( ) ,
506+ links_from_incr_cache : links_from_incr_cache . clone ( ) ,
495507 } ,
496508 module_global_asm : has_global_asm. then ( || CompiledModule {
497509 name : cgu. name ( ) . to_string ( ) ,
@@ -501,7 +513,7 @@ fn reuse_workproduct_for_cgu(
501513 bytecode : None ,
502514 assembly : None ,
503515 llvm_ir : None ,
504- links_from_incr_cache : Vec :: new ( ) ,
516+ links_from_incr_cache,
505517 } ) ,
506518 existing_work_product : Some ( ( cgu. work_product_id ( ) , work_product) ) ,
507519 } )
0 commit comments