@@ -166,16 +166,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
166166 }
167167
168168 fn init ( & self , sess : & Session ) {
169- use rustc_session:: config:: { InstrumentCoverage , Lto } ;
170- match sess. lto ( ) {
171- Lto :: No | Lto :: ThinLocal => {
172- if sess. opts . crate_name . as_deref ( ) != Some ( "___" ) {
173- sess. dcx ( ) . fatal ( "No LTO" ) ;
174- }
175- }
176- Lto :: Thin | Lto :: Fat => { }
177- }
178-
169+ use rustc_session:: config:: InstrumentCoverage ;
179170 if sess. opts . cg . instrument_coverage ( ) != InstrumentCoverage :: No {
180171 sess. dcx ( )
181172 . fatal ( "`-Cinstrument-coverage` is LLVM specific and not supported by Cranelift" ) ;
@@ -219,27 +210,23 @@ impl CodegenBackend for CraneliftCodegenBackend {
219210 . unwrap_or_else ( |err| tcx. sess . dcx ( ) . fatal ( err) )
220211 } ) ;
221212 match config. codegen_mode {
222- CodegenMode :: Aot => {
223- match tcx. sess . lto ( ) {
224- Lto :: No | Lto :: ThinLocal => {
225- driver:: aot:: run_aot ( tcx, metadata, need_metadata_module)
226- }
227- Lto :: Thin | Lto :: Fat => {
228- if tcx. crate_name ( LOCAL_CRATE ) . as_str ( ) == "compiler_builtins" {
229- // FIXME remove special case once inline asm is supported in LTO mode
230- driver:: aot:: run_aot ( tcx, metadata, need_metadata_module)
231- } else {
232- #[ cfg( feature = "lto" ) ]
233- return driver:: lto:: run_aot ( tcx, metadata, need_metadata_module) ;
234-
235- #[ cfg( not( feature = "lto" ) ) ]
236- tcx. dcx ( ) . fatal (
237- "LTO support was disabled when compiling rustc_codegen_cranelift" ,
238- ) ;
239- }
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) ;
240220 }
221+
222+ #[ cfg( feature = "lto" ) ]
223+ return driver:: lto:: run_aot ( tcx, metadata, need_metadata_module) ;
224+
225+ #[ cfg( not( feature = "lto" ) ) ]
226+ tcx. dcx ( )
227+ . fatal ( "LTO support was disabled when compiling rustc_codegen_cranelift" ) ;
241228 }
242- }
229+ } ,
243230 CodegenMode :: Jit | CodegenMode :: JitLazy => {
244231 #[ cfg( feature = "jit" ) ]
245232 driver:: jit:: run_jit ( tcx, config. codegen_mode , config. jit_args ) ;
0 commit comments