Skip to content

Commit 0a3bedc

Browse files
committed
Allow non-LTO mode
1 parent c9f6a2d commit 0a3bedc

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
@@ -214,6 +214,8 @@ pub(super) fn load_lto_modules(
214214
}
215215

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

src/lib.rs

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

163163
fn init(&self, sess: &Session) {
164-
use rustc_session::config::{InstrumentCoverage, Lto};
165-
match sess.lto() {
166-
Lto::No | Lto::ThinLocal => {
167-
if sess.opts.crate_name.as_deref() != Some("___") {
168-
sess.dcx().fatal("No LTO");
169-
}
170-
}
171-
Lto::Thin | Lto::Fat => {}
172-
}
173-
164+
use rustc_session::config::InstrumentCoverage;
174165
if sess.opts.cg.instrument_coverage() != InstrumentCoverage::No {
175166
sess.dcx()
176167
.fatal("`-Cinstrument-coverage` is LLVM specific and not supported by Cranelift");
@@ -252,18 +243,16 @@ impl CodegenBackend for CraneliftCodegenBackend {
252243
match tcx.sess.lto() {
253244
Lto::No | Lto::ThinLocal => driver::aot::run_aot(tcx),
254245
Lto::Thin | Lto::Fat => {
255-
if tcx.crate_name(LOCAL_CRATE).as_str() == "compiler_builtins" {
256-
// FIXME remove special case once inline asm is supported in LTO mode
257-
driver::aot::run_aot(tcx)
258-
} else {
259-
#[cfg(feature = "lto")]
260-
return driver::lto::run_aot(tcx);
261-
262-
#[cfg(not(feature = "lto"))]
263-
tcx.dcx().fatal(
264-
"LTO support was disabled when compiling rustc_codegen_cranelift",
265-
);
246+
if tcx.crate_name(LOCAL_CRATE) == sym::compiler_builtins {
247+
return driver::aot::run_aot(tcx);
266248
}
249+
250+
#[cfg(feature = "lto")]
251+
return driver::lto::run_aot(tcx);
252+
253+
#[cfg(not(feature = "lto"))]
254+
tcx.dcx()
255+
.fatal("LTO support was disabled when compiling rustc_codegen_cranelift");
267256
}
268257
}
269258
}

0 commit comments

Comments
 (0)