@@ -35,8 +35,7 @@ fn disable_incr_cache() -> bool {
3535}
3636
3737struct ModuleCodegenResult {
38- module_regular : CompiledModule ,
39- module_global_asm : Option < CompiledModule > ,
38+ module : CompiledModule ,
4039 existing_work_product : Option < ( WorkProductId , WorkProduct ) > ,
4140}
4241
@@ -80,29 +79,25 @@ impl OngoingCodegen {
8079 Ok ( module_codegen_result) => module_codegen_result,
8180 Err ( err) => sess. dcx ( ) . fatal ( err) ,
8281 } ;
83- let ModuleCodegenResult { module_regular, module_global_asm, existing_work_product } =
84- module_codegen_result;
82+ let ModuleCodegenResult { module, existing_work_product } = module_codegen_result;
8583
8684 if let Some ( ( work_product_id, work_product) ) = existing_work_product {
8785 work_products. insert ( work_product_id, work_product) ;
8886 } else {
8987 let work_product = if disable_incr_cache {
9088 None
91- } else if let Some ( module_global_asm ) = & module_global_asm {
89+ } else if let Some ( global_asm_object ) = & module . global_asm_object {
9290 rustc_incremental:: copy_cgu_workproduct_to_incr_comp_cache_dir (
9391 sess,
94- & module_regular. name ,
95- & [
96- ( "o" , module_regular. object . as_ref ( ) . unwrap ( ) ) ,
97- ( "asm.o" , module_global_asm. object . as_ref ( ) . unwrap ( ) ) ,
98- ] ,
92+ & module. name ,
93+ & [ ( "o" , module. object . as_ref ( ) . unwrap ( ) ) , ( "asm.o" , global_asm_object) ] ,
9994 & [ ] ,
10095 )
10196 } else {
10297 rustc_incremental:: copy_cgu_workproduct_to_incr_comp_cache_dir (
10398 sess,
104- & module_regular . name ,
105- & [ ( "o" , module_regular . object . as_ref ( ) . unwrap ( ) ) ] ,
99+ & module . name ,
100+ & [ ( "o" , module . object . as_ref ( ) . unwrap ( ) ) ] ,
106101 & [ ] ,
107102 )
108103 } ;
@@ -111,10 +106,7 @@ impl OngoingCodegen {
111106 }
112107 }
113108
114- modules. push ( module_regular) ;
115- if let Some ( module_global_asm) = module_global_asm {
116- modules. push ( module_global_asm) ;
117- }
109+ modules. push ( module) ;
118110 }
119111
120112 self . concurrency_limiter . finished ( ) ;
@@ -163,29 +155,17 @@ fn emit_cgu(
163155 debug. emit ( & mut product) ;
164156 }
165157
166- let module_regular = emit_module (
158+ let module = emit_module (
167159 output_filenames,
168160 prof,
169161 product. object ,
170162 ModuleKind :: Regular ,
171163 name. clone ( ) ,
164+ global_asm_object_file,
172165 producer,
173166 ) ?;
174167
175- Ok ( ModuleCodegenResult {
176- module_regular,
177- module_global_asm : global_asm_object_file. map ( |global_asm_object_file| CompiledModule {
178- name : format ! ( "{name}.asm" ) ,
179- kind : ModuleKind :: Regular ,
180- object : Some ( global_asm_object_file) ,
181- dwarf_object : None ,
182- bytecode : None ,
183- assembly : None ,
184- llvm_ir : None ,
185- links_from_incr_cache : Vec :: new ( ) ,
186- } ) ,
187- existing_work_product : None ,
188- } )
168+ Ok ( ModuleCodegenResult { module, existing_work_product : None } )
189169}
190170
191171fn emit_module (
@@ -194,6 +174,7 @@ fn emit_module(
194174 mut object : cranelift_object:: object:: write:: Object < ' _ > ,
195175 kind : ModuleKind ,
196176 name : String ,
177+ global_asm_object : Option < PathBuf > ,
197178 producer_str : & str ,
198179) -> Result < CompiledModule , String > {
199180 if object. format ( ) == cranelift_object:: object:: BinaryFormat :: Elf {
@@ -235,6 +216,7 @@ fn emit_module(
235216 name,
236217 kind,
237218 object : Some ( tmp_file) ,
219+ global_asm_object,
238220 dwarf_object : None ,
239221 bytecode : None ,
240222 assembly : None ,
@@ -265,7 +247,7 @@ fn reuse_workproduct_for_cgu(
265247 }
266248
267249 let obj_out_global_asm =
268- crate :: global_asm :: add_file_stem_postfix ( obj_out_regular . clone ( ) , ". asm" ) ;
250+ tcx . output_filenames ( ( ) ) . temp_path_ext_for_cgu ( " asm.o" , cgu . name ( ) . as_str ( ) ) ;
269251 let source_file_global_asm = if let Some ( asm_o) = work_product. saved_files . get ( "asm.o" ) {
270252 let source_file_global_asm = rustc_incremental:: in_incr_comp_dir_sess ( tcx. sess , asm_o) ;
271253 if let Err ( err) = rustc_fs_util:: link_or_copy ( & source_file_global_asm, & obj_out_global_asm)
@@ -283,26 +265,21 @@ fn reuse_workproduct_for_cgu(
283265 } ;
284266
285267 Ok ( ModuleCodegenResult {
286- module_regular : CompiledModule {
268+ module : CompiledModule {
287269 name : cgu. name ( ) . to_string ( ) ,
288270 kind : ModuleKind :: Regular ,
289271 object : Some ( obj_out_regular) ,
272+ global_asm_object : source_file_global_asm. as_ref ( ) . map ( |_| obj_out_global_asm) ,
290273 dwarf_object : None ,
291274 bytecode : None ,
292275 assembly : None ,
293276 llvm_ir : None ,
294- links_from_incr_cache : vec ! [ source_file_regular] ,
277+ links_from_incr_cache : if let Some ( source_file_global_asm) = source_file_global_asm {
278+ vec ! [ source_file_regular, source_file_global_asm]
279+ } else {
280+ vec ! [ source_file_regular]
281+ } ,
295282 } ,
296- module_global_asm : source_file_global_asm. map ( |source_file| CompiledModule {
297- name : cgu. name ( ) . to_string ( ) ,
298- kind : ModuleKind :: Regular ,
299- object : Some ( obj_out_global_asm) ,
300- dwarf_object : None ,
301- bytecode : None ,
302- assembly : None ,
303- llvm_ir : None ,
304- links_from_incr_cache : vec ! [ source_file] ,
305- } ) ,
306283 existing_work_product : Some ( ( cgu. work_product_id ( ) , work_product) ) ,
307284 } )
308285}
@@ -447,6 +424,7 @@ fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> {
447424 product. object ,
448425 ModuleKind :: Allocator ,
449426 "allocator_shim" . to_owned ( ) ,
427+ None ,
450428 & crate :: debuginfo:: producer ( tcx. sess ) ,
451429 ) {
452430 Ok ( allocator_module) => Some ( allocator_module) ,
0 commit comments