@@ -38,12 +38,11 @@ pub(crate) struct OngoingCodegen {
3838 metadata_module : Option < CompiledModule > ,
3939 metadata : EncodedMetadata ,
4040 crate_info : CrateInfo ,
41- work_products : FxHashMap < WorkProductId , WorkProduct > ,
4241}
4342
4443impl OngoingCodegen {
4544 pub ( crate ) fn join ( self ) -> ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) {
46- let mut work_products = self . work_products ;
45+ let mut work_products = FxHashMap :: default ( ) ;
4746 let mut modules = vec ! [ ] ;
4847
4948 for module_codegen_result in self . modules {
@@ -331,8 +330,6 @@ pub(crate) fn run_aot(
331330
332331 tcx. sess . abort_if_errors ( ) ;
333332
334- let mut work_products = FxHashMap :: default ( ) ;
335-
336333 let isa = crate :: build_isa ( tcx. sess , & backend_config) ;
337334 let mut allocator_module = make_module ( tcx. sess , isa, "allocator_shim" . to_string ( ) ) ;
338335 assert_eq ! ( pointer_ty( tcx) , allocator_module. target_config( ) . pointer_type( ) ) ;
@@ -341,21 +338,27 @@ pub(crate) fn run_aot(
341338 crate :: allocator:: codegen ( tcx, & mut allocator_module, & mut allocator_unwind_context) ;
342339
343340 let allocator_module = if created_alloc_shim {
344- let ModuleCodegenResult { module_regular, module_global_asm, work_product } = emit_module (
345- tcx,
346- & backend_config,
347- "allocator_shim" . to_string ( ) ,
348- ModuleKind :: Allocator ,
349- allocator_module,
350- None ,
351- allocator_unwind_context,
352- None ,
353- ) ;
354- assert ! ( module_global_asm. is_none( ) ) ;
355- if let Some ( ( id, product) ) = work_product {
356- work_products. insert ( id, product) ;
341+ let name = "allocator_shim" . to_owned ( ) ;
342+
343+ let mut product = allocator_module. finish ( ) ;
344+ allocator_unwind_context. emit ( & mut product) ;
345+
346+ let tmp_file = tcx. output_filenames ( ( ) ) . temp_path ( OutputType :: Object , Some ( & name) ) ;
347+ let obj = product. object . write ( ) . unwrap ( ) ;
348+
349+ tcx. sess . prof . artifact_size ( "object_file" , & * name, obj. len ( ) . try_into ( ) . unwrap ( ) ) ;
350+
351+ if let Err ( err) = std:: fs:: write ( & tmp_file, obj) {
352+ tcx. sess . fatal ( & format ! ( "error writing object file: {}" , err) ) ;
357353 }
358- Some ( module_regular)
354+
355+ Some ( CompiledModule {
356+ name,
357+ kind : ModuleKind :: Allocator ,
358+ object : Some ( tmp_file) ,
359+ dwarf_object : None ,
360+ bytecode : None ,
361+ } )
359362 } else {
360363 None
361364 } ;
@@ -408,7 +411,6 @@ pub(crate) fn run_aot(
408411 metadata_module,
409412 metadata,
410413 crate_info : CrateInfo :: new ( tcx, target_cpu) ,
411- work_products,
412414 } )
413415}
414416
0 commit comments