@@ -798,19 +798,12 @@ pub(crate) fn compute_per_cgu_lto_type(
798798 sess_lto : & Lto ,
799799 opts : & config:: Options ,
800800 sess_crate_types : & [ CrateType ] ,
801- module_kind : ModuleKind ,
802801) -> ComputedLtoType {
803802 // If the linker does LTO, we don't have to do it. Note that we
804803 // keep doing full LTO, if it is requested, as not to break the
805804 // assumption that the output will be a single module.
806805 let linker_does_lto = opts. cg . linker_plugin_lto . enabled ( ) ;
807806
808- // When we're automatically doing ThinLTO for multi-codegen-unit
809- // builds we don't actually want to LTO the allocator modules if
810- // it shows up. This is due to various linker shenanigans that
811- // we'll encounter later.
812- let is_allocator = module_kind == ModuleKind :: Allocator ;
813-
814807 // We ignore a request for full crate graph LTO if the crate type
815808 // is only an rlib, as there is no full crate graph to process,
816809 // that'll happen later.
@@ -822,7 +815,7 @@ pub(crate) fn compute_per_cgu_lto_type(
822815 let is_rlib = matches ! ( sess_crate_types, [ CrateType :: Rlib ] ) ;
823816
824817 match sess_lto {
825- Lto :: ThinLocal if !linker_does_lto && !is_allocator => ComputedLtoType :: Thin ,
818+ Lto :: ThinLocal if !linker_does_lto => ComputedLtoType :: Thin ,
826819 Lto :: Thin if !linker_does_lto && !is_rlib => ComputedLtoType :: Thin ,
827820 Lto :: Fat if !is_rlib => ComputedLtoType :: Fat ,
828821 _ => ComputedLtoType :: No ,
@@ -844,7 +837,16 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
844837 // back to the coordinator thread for further LTO processing (which
845838 // has to wait for all the initial modules to be optimized).
846839
847- let lto_type = compute_per_cgu_lto_type ( & cgcx. lto , & cgcx. opts , & cgcx. crate_types , module. kind ) ;
840+ // When we're automatically doing ThinLTO for multi-codegen-unit
841+ // builds we don't actually want to LTO the allocator modules if
842+ // it shows up. This is due to various linker shenanigans that
843+ // we'll encounter later.
844+ if module. kind == ModuleKind :: Allocator {
845+ let module = B :: codegen ( cgcx, module, module_config) ;
846+ return WorkItemResult :: Finished ( module) ;
847+ }
848+
849+ let lto_type = compute_per_cgu_lto_type ( & cgcx. lto , & cgcx. opts , & cgcx. crate_types ) ;
848850
849851 // If we're doing some form of incremental LTO then we need to be sure to
850852 // save our module to disk first.
0 commit comments