@@ -809,19 +809,12 @@ pub(crate) fn compute_per_cgu_lto_type(
809
809
sess_lto : & Lto ,
810
810
opts : & config:: Options ,
811
811
sess_crate_types : & [ CrateType ] ,
812
- module_kind : ModuleKind ,
813
812
) -> ComputedLtoType {
814
813
// If the linker does LTO, we don't have to do it. Note that we
815
814
// keep doing full LTO, if it is requested, as not to break the
816
815
// assumption that the output will be a single module.
817
816
let linker_does_lto = opts. cg . linker_plugin_lto . enabled ( ) ;
818
817
819
- // When we're automatically doing ThinLTO for multi-codegen-unit
820
- // builds we don't actually want to LTO the allocator modules if
821
- // it shows up. This is due to various linker shenanigans that
822
- // we'll encounter later.
823
- let is_allocator = module_kind == ModuleKind :: Allocator ;
824
-
825
818
// We ignore a request for full crate graph LTO if the crate type
826
819
// is only an rlib, as there is no full crate graph to process,
827
820
// that'll happen later.
@@ -833,7 +826,7 @@ pub(crate) fn compute_per_cgu_lto_type(
833
826
let is_rlib = matches ! ( sess_crate_types, [ CrateType :: Rlib ] ) ;
834
827
835
828
match sess_lto {
836
- Lto :: ThinLocal if !linker_does_lto && !is_allocator => ComputedLtoType :: Thin ,
829
+ Lto :: ThinLocal if !linker_does_lto => ComputedLtoType :: Thin ,
837
830
Lto :: Thin if !linker_does_lto && !is_rlib => ComputedLtoType :: Thin ,
838
831
Lto :: Fat if !is_rlib => ComputedLtoType :: Fat ,
839
832
_ => ComputedLtoType :: No ,
@@ -855,7 +848,16 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
855
848
// back to the coordinator thread for further LTO processing (which
856
849
// has to wait for all the initial modules to be optimized).
857
850
858
- let lto_type = compute_per_cgu_lto_type ( & cgcx. lto , & cgcx. opts , & cgcx. crate_types , module. kind ) ;
851
+ // When we're automatically doing ThinLTO for multi-codegen-unit
852
+ // builds we don't actually want to LTO the allocator modules if
853
+ // it shows up. This is due to various linker shenanigans that
854
+ // we'll encounter later.
855
+ if module. kind == ModuleKind :: Allocator {
856
+ let module = B :: codegen ( cgcx, module, module_config) ;
857
+ return WorkItemResult :: Finished ( module) ;
858
+ }
859
+
860
+ let lto_type = compute_per_cgu_lto_type ( & cgcx. lto , & cgcx. opts , & cgcx. crate_types ) ;
859
861
860
862
// If we're doing some form of incremental LTO then we need to be sure to
861
863
// save our module to disk first.
0 commit comments