@@ -207,23 +207,30 @@ impl CodegenBackend for CraneliftCodegenBackend {
207207 . unwrap_or_else ( |err| tcx. sess . dcx ( ) . fatal ( err) )
208208 } ) ;
209209 match config. codegen_mode {
210- CodegenMode :: Aot => match tcx. sess . lto ( ) {
211- Lto :: No | Lto :: ThinLocal => {
212- driver:: aot:: run_aot ( tcx, metadata, need_metadata_module)
213- }
214- Lto :: Thin | Lto :: Fat => {
215- if tcx. crate_name ( LOCAL_CRATE ) == sym:: compiler_builtins {
216- return driver:: aot:: run_aot ( tcx, metadata, need_metadata_module) ;
217- }
218-
210+ CodegenMode :: Aot => {
211+ if tcx. sess . opts . cg . linker_plugin_lto . enabled ( ) {
219212 #[ cfg( feature = "lto" ) ]
220213 return driver:: lto:: run_aot ( tcx, metadata, need_metadata_module) ;
221214
222215 #[ cfg( not( feature = "lto" ) ) ]
223216 tcx. dcx ( )
224217 . fatal ( "LTO support was disabled when compiling rustc_codegen_cranelift" ) ;
225218 }
226- } ,
219+ match tcx. sess . lto ( ) {
220+ Lto :: No | Lto :: ThinLocal => {
221+ driver:: aot:: run_aot ( tcx, metadata, need_metadata_module)
222+ }
223+ Lto :: Thin | Lto :: Fat => {
224+ #[ cfg( feature = "lto" ) ]
225+ return driver:: lto:: run_aot ( tcx, metadata, need_metadata_module) ;
226+
227+ #[ cfg( not( feature = "lto" ) ) ]
228+ tcx. dcx ( ) . fatal (
229+ "LTO support was disabled when compiling rustc_codegen_cranelift" ,
230+ ) ;
231+ }
232+ }
233+ }
227234 CodegenMode :: Jit | CodegenMode :: JitLazy => {
228235 #[ cfg( feature = "jit" ) ]
229236 driver:: jit:: run_jit ( tcx, config. codegen_mode , config. jit_args ) ;
0 commit comments