@@ -809,19 +809,12 @@ pub(crate) fn compute_per_cgu_lto_type(
809809    sess_lto :  & Lto , 
810810    opts :  & config:: Options , 
811811    sess_crate_types :  & [ CrateType ] , 
812-     module_kind :  ModuleKind , 
813812)  -> ComputedLtoType  { 
814813    // If the linker does LTO, we don't have to do it. Note that we 
815814    // keep doing full LTO, if it is requested, as not to break the 
816815    // assumption that the output will be a single module. 
817816    let  linker_does_lto = opts. cg . linker_plugin_lto . enabled ( ) ; 
818817
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- 
825818    // We ignore a request for full crate graph LTO if the crate type 
826819    // is only an rlib, as there is no full crate graph to process, 
827820    // that'll happen later. 
@@ -833,7 +826,7 @@ pub(crate) fn compute_per_cgu_lto_type(
833826    let  is_rlib = matches ! ( sess_crate_types,  [ CrateType :: Rlib ] ) ; 
834827
835828    match  sess_lto { 
836-         Lto :: ThinLocal  if  !linker_does_lto && !is_allocator  => ComputedLtoType :: Thin , 
829+         Lto :: ThinLocal  if  !linker_does_lto => ComputedLtoType :: Thin , 
837830        Lto :: Thin  if  !linker_does_lto && !is_rlib => ComputedLtoType :: Thin , 
838831        Lto :: Fat  if  !is_rlib => ComputedLtoType :: Fat , 
839832        _ => ComputedLtoType :: No , 
@@ -855,7 +848,16 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
855848    // back to the coordinator thread for further LTO processing (which 
856849    // has to wait for all the initial modules to be optimized). 
857850
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 ) ; 
859861
860862    // If we're doing some form of incremental LTO then we need to be sure to 
861863    // save our module to disk first. 
0 commit comments