@@ -163,16 +163,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
163163 }
164164
165165 fn init ( & self , sess : & Session ) {
166- use rustc_session:: config:: { InstrumentCoverage , Lto } ;
167- match sess. lto ( ) {
168- Lto :: No | Lto :: ThinLocal => {
169- if sess. opts . crate_name . as_deref ( ) != Some ( "___" ) {
170- sess. dcx ( ) . fatal ( "No LTO" ) ;
171- }
172- }
173- Lto :: Thin | Lto :: Fat => { }
174- }
175-
166+ use rustc_session:: config:: InstrumentCoverage ;
176167 if sess. opts . cg . instrument_coverage ( ) != InstrumentCoverage :: No {
177168 sess. dcx ( )
178169 . fatal ( "`-Cinstrument-coverage` is LLVM specific and not supported by Cranelift" ) ;
@@ -216,27 +207,23 @@ impl CodegenBackend for CraneliftCodegenBackend {
216207 . unwrap_or_else ( |err| tcx. sess . dcx ( ) . fatal ( err) )
217208 } ) ;
218209 match config. codegen_mode {
219- CodegenMode :: Aot => {
220- match tcx. sess . lto ( ) {
221- Lto :: No | Lto :: ThinLocal => {
222- driver:: aot:: run_aot ( tcx, metadata, need_metadata_module)
223- }
224- Lto :: Thin | Lto :: Fat => {
225- if tcx. crate_name ( LOCAL_CRATE ) . as_str ( ) == "compiler_builtins" {
226- // FIXME remove special case once inline asm is supported in LTO mode
227- driver:: aot:: run_aot ( tcx, metadata, need_metadata_module)
228- } else {
229- #[ cfg( feature = "lto" ) ]
230- return driver:: lto:: run_aot ( tcx, metadata, need_metadata_module) ;
231-
232- #[ cfg( not( feature = "lto" ) ) ]
233- tcx. dcx ( ) . fatal (
234- "LTO support was disabled when compiling rustc_codegen_cranelift" ,
235- ) ;
236- }
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) ;
237217 }
218+
219+ #[ cfg( feature = "lto" ) ]
220+ return driver:: lto:: run_aot ( tcx, metadata, need_metadata_module) ;
221+
222+ #[ cfg( not( feature = "lto" ) ) ]
223+ tcx. dcx ( )
224+ . fatal ( "LTO support was disabled when compiling rustc_codegen_cranelift" ) ;
238225 }
239- }
226+ } ,
240227 CodegenMode :: Jit | CodegenMode :: JitLazy => {
241228 #[ cfg( feature = "jit" ) ]
242229 driver:: jit:: run_jit ( tcx, config. codegen_mode , config. jit_args ) ;
0 commit comments