@@ -622,6 +622,29 @@ fn emit_metadata_module(tcx: TyCtxt<'_>, metadata: &EncodedMetadata) -> Compiled
622
622
}
623
623
}
624
624
625
+ fn emit_allocator_module ( tcx : TyCtxt < ' _ > ) -> Option < CompiledModule > {
626
+ let mut allocator_module = make_module ( tcx. sess , "allocator_shim" . to_string ( ) ) ;
627
+ let created_alloc_shim = crate :: allocator:: codegen ( tcx, & mut allocator_module) ;
628
+
629
+ if created_alloc_shim {
630
+ let product = allocator_module. finish ( ) ;
631
+
632
+ match emit_module (
633
+ tcx. output_filenames ( ( ) ) ,
634
+ & tcx. sess . prof ,
635
+ product. object ,
636
+ ModuleKind :: Allocator ,
637
+ "allocator_shim" . to_owned ( ) ,
638
+ & crate :: debuginfo:: producer ( tcx. sess ) ,
639
+ ) {
640
+ Ok ( allocator_module) => Some ( allocator_module) ,
641
+ Err ( err) => tcx. dcx ( ) . fatal ( err) ,
642
+ }
643
+ } else {
644
+ None
645
+ }
646
+ }
647
+
625
648
pub ( crate ) fn run_aot (
626
649
tcx : TyCtxt < ' _ > ,
627
650
metadata : EncodedMetadata ,
@@ -700,26 +723,7 @@ pub(crate) fn run_aot(
700
723
modules
701
724
} ) ;
702
725
703
- let mut allocator_module = make_module ( tcx. sess , "allocator_shim" . to_string ( ) ) ;
704
- let created_alloc_shim = crate :: allocator:: codegen ( tcx, & mut allocator_module) ;
705
-
706
- let allocator_module = if created_alloc_shim {
707
- let product = allocator_module. finish ( ) ;
708
-
709
- match emit_module (
710
- tcx. output_filenames ( ( ) ) ,
711
- & tcx. sess . prof ,
712
- product. object ,
713
- ModuleKind :: Allocator ,
714
- "allocator_shim" . to_owned ( ) ,
715
- & crate :: debuginfo:: producer ( tcx. sess ) ,
716
- ) {
717
- Ok ( allocator_module) => Some ( allocator_module) ,
718
- Err ( err) => tcx. dcx ( ) . fatal ( err) ,
719
- }
720
- } else {
721
- None
722
- } ;
726
+ let allocator_module = emit_allocator_module ( tcx) ;
723
727
724
728
let metadata_module =
725
729
if need_metadata_module { Some ( emit_metadata_module ( tcx, & metadata) ) } else { None } ;
0 commit comments