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