@@ -38,12 +38,11 @@ pub(crate) struct OngoingCodegen {
38
38
metadata_module : Option < CompiledModule > ,
39
39
metadata : EncodedMetadata ,
40
40
crate_info : CrateInfo ,
41
- work_products : FxHashMap < WorkProductId , WorkProduct > ,
42
41
}
43
42
44
43
impl OngoingCodegen {
45
44
pub ( crate ) fn join ( self ) -> ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) {
46
- let mut work_products = self . work_products ;
45
+ let mut work_products = FxHashMap :: default ( ) ;
47
46
let mut modules = vec ! [ ] ;
48
47
49
48
for module_codegen_result in self . modules {
@@ -331,8 +330,6 @@ pub(crate) fn run_aot(
331
330
332
331
tcx. sess . abort_if_errors ( ) ;
333
332
334
- let mut work_products = FxHashMap :: default ( ) ;
335
-
336
333
let isa = crate :: build_isa ( tcx. sess , & backend_config) ;
337
334
let mut allocator_module = make_module ( tcx. sess , isa, "allocator_shim" . to_string ( ) ) ;
338
335
assert_eq ! ( pointer_ty( tcx) , allocator_module. target_config( ) . pointer_type( ) ) ;
@@ -341,21 +338,27 @@ pub(crate) fn run_aot(
341
338
crate :: allocator:: codegen ( tcx, & mut allocator_module, & mut allocator_unwind_context) ;
342
339
343
340
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) ) ;
357
353
}
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
+ } )
359
362
} else {
360
363
None
361
364
} ;
@@ -408,7 +411,6 @@ pub(crate) fn run_aot(
408
411
metadata_module,
409
412
metadata,
410
413
crate_info : CrateInfo :: new ( tcx, target_cpu) ,
411
- work_products,
412
414
} )
413
415
}
414
416
0 commit comments