@@ -494,12 +494,18 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
494
494
let _timer = sess. timer ( "copy_all_cgu_workproducts_to_incr_comp_cache_dir" ) ;
495
495
496
496
for module in compiled_modules. modules . iter ( ) . filter ( |m| m. kind == ModuleKind :: Regular ) {
497
- if let Some ( path) = & module. object {
498
- if let Some ( ( id, product) ) =
499
- copy_cgu_workproduct_to_incr_comp_cache_dir ( sess, & module. name , path)
500
- {
501
- work_products. insert ( id, product) ;
502
- }
497
+ let mut files = Vec :: new ( ) ;
498
+ if let Some ( object_file_path) = & module. object {
499
+ files. push ( ( "o" , object_file_path. as_path ( ) ) ) ;
500
+ }
501
+ if let Some ( dwarf_object_file_path) = & module. dwarf_object {
502
+ files. push ( ( "dwo" , dwarf_object_file_path. as_path ( ) ) ) ;
503
+ }
504
+
505
+ if let Some ( ( id, product) ) =
506
+ copy_cgu_workproduct_to_incr_comp_cache_dir ( sess, & module. name , files. as_slice ( ) )
507
+ {
508
+ work_products. insert ( id, product) ;
503
509
}
504
510
}
505
511
@@ -856,29 +862,50 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
856
862
assert ! ( module_config. emit_obj != EmitObj :: None ) ;
857
863
858
864
let incr_comp_session_dir = cgcx. incr_comp_session_dir . as_ref ( ) . unwrap ( ) ;
859
- let obj_out = cgcx. output_filenames . temp_path ( OutputType :: Object , Some ( & module. name ) ) ;
860
- let source_file = in_incr_comp_dir ( & incr_comp_session_dir, & module. source . saved_file ) ;
861
- debug ! (
862
- "copying pre-existing module `{}` from {:?} to {}" ,
863
- module. name,
864
- source_file,
865
- obj_out. display( )
865
+
866
+ let load_from_incr_comp_dir = |output_path : PathBuf , saved_path : & str | {
867
+ let source_file = in_incr_comp_dir ( & incr_comp_session_dir, saved_path) ;
868
+ debug ! (
869
+ "copying pre-existing module `{}` from {:?} to {}" ,
870
+ module. name,
871
+ source_file,
872
+ output_path. display( )
873
+ ) ;
874
+ match link_or_copy ( & source_file, & output_path) {
875
+ Ok ( _) => Some ( output_path) ,
876
+ Err ( err) => {
877
+ let diag_handler = cgcx. create_diag_handler ( ) ;
878
+ diag_handler. err ( & format ! (
879
+ "unable to copy {} to {}: {}" ,
880
+ source_file. display( ) ,
881
+ output_path. display( ) ,
882
+ err
883
+ ) ) ;
884
+ None
885
+ }
886
+ }
887
+ } ;
888
+
889
+ let object = load_from_incr_comp_dir (
890
+ cgcx. output_filenames . temp_path ( OutputType :: Object , Some ( & module. name ) ) ,
891
+ & module. source . saved_files . get ( "o" ) . expect ( "no saved object file in work product" ) ,
866
892
) ;
867
- if let Err ( err) = link_or_copy ( & source_file, & obj_out) {
868
- let diag_handler = cgcx. create_diag_handler ( ) ;
869
- diag_handler. err ( & format ! (
870
- "unable to copy {} to {}: {}" ,
871
- source_file. display( ) ,
872
- obj_out. display( ) ,
873
- err
874
- ) ) ;
875
- }
893
+ let dwarf_object =
894
+ module. source . saved_files . get ( "dwo" ) . as_ref ( ) . and_then ( |saved_dwarf_object_file| {
895
+ let dwarf_obj_out = cgcx
896
+ . output_filenames
897
+ . split_dwarf_path ( cgcx. split_debuginfo , cgcx. split_dwarf_kind , Some ( & module. name ) )
898
+ . expect (
899
+ "saved dwarf object in work product but `split_dwarf_path` returned `None`" ,
900
+ ) ;
901
+ load_from_incr_comp_dir ( dwarf_obj_out, & saved_dwarf_object_file)
902
+ } ) ;
876
903
877
904
WorkItemResult :: Compiled ( CompiledModule {
878
905
name : module. name ,
879
906
kind : ModuleKind :: Regular ,
880
- object : Some ( obj_out ) ,
881
- dwarf_object : None ,
907
+ object,
908
+ dwarf_object,
882
909
bytecode : None ,
883
910
} )
884
911
}
0 commit comments