Skip to content

Commit 246f0cb

Browse files
committed
Allow non-LTO mode
1 parent c2d65b8 commit 246f0cb

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

src/driver/lto.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ pub(super) fn load_lto_modules(
218218
}
219219

220220
pub(crate) fn run_aot(tcx: TyCtxt<'_>) -> Box<OngoingCodegen> {
221+
tcx.dcx().note(format!("Using LTO for {}", tcx.crate_name(LOCAL_CRATE)));
222+
221223
// FIXME handle `-Ctarget-cpu=native`
222224
let target_cpu = match tcx.sess.opts.cg.target_cpu {
223225
Some(ref name) => name,

src/lib.rs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
139139
}
140140

141141
fn init(&self, sess: &Session) {
142-
use rustc_session::config::{InstrumentCoverage, Lto};
143-
match sess.lto() {
144-
Lto::No | Lto::ThinLocal => {
145-
if sess.opts.crate_name.as_deref() != Some("___") {
146-
sess.dcx().fatal("No LTO");
147-
}
148-
}
149-
Lto::Thin | Lto::Fat => {}
150-
}
151-
142+
use rustc_session::config::InstrumentCoverage;
152143
if sess.opts.cg.instrument_coverage() != InstrumentCoverage::No {
153144
sess.dcx()
154145
.fatal("`-Cinstrument-coverage` is LLVM specific and not supported by Cranelift");
@@ -223,18 +214,16 @@ impl CodegenBackend for CraneliftCodegenBackend {
223214
match tcx.sess.lto() {
224215
Lto::No | Lto::ThinLocal => driver::aot::run_aot(tcx),
225216
Lto::Thin | Lto::Fat => {
226-
if tcx.crate_name(LOCAL_CRATE).as_str() == "compiler_builtins" {
227-
// FIXME remove special case once inline asm is supported in LTO mode
228-
driver::aot::run_aot(tcx)
229-
} else {
230-
#[cfg(feature = "lto")]
231-
return driver::lto::run_aot(tcx);
232-
233-
#[cfg(not(feature = "lto"))]
234-
tcx.dcx().fatal(
235-
"LTO support was disabled when compiling rustc_codegen_cranelift",
236-
);
217+
if tcx.crate_name(LOCAL_CRATE) == sym::compiler_builtins {
218+
return driver::aot::run_aot(tcx);
237219
}
220+
221+
#[cfg(feature = "lto")]
222+
return driver::lto::run_aot(tcx);
223+
224+
#[cfg(not(feature = "lto"))]
225+
tcx.dcx()
226+
.fatal("LTO support was disabled when compiling rustc_codegen_cranelift");
238227
}
239228
}
240229
}

0 commit comments

Comments
 (0)