Skip to content

Commit a7c59df

Browse files
committed
[WIP] Support hybrid LTO/non-LTO rlibs.
1 parent 0af37b0 commit a7c59df

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

build_system/build_sysroot.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ fn build_clif_sysroot_for_triple(
245245
prefix.to_str().unwrap()
246246
));
247247
}
248-
rustflags.push("-Clto=thin".to_owned());
249-
rustflags.push("-Zdylib-lto".to_owned());
250248
rustflags.push("-Cembed-bitcode=yes".to_owned());
251249
compiler.rustflags.extend(rustflags);
252250
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
@@ -258,7 +256,6 @@ fn build_clif_sysroot_for_triple(
258256
if compiler.triple.contains("apple") {
259257
build_cmd.env("CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO", "packed");
260258
}
261-
build_cmd.env("CARGO_PROFILE_RELEASE_LTO", "thin");
262259
spawn_and_wait(build_cmd);
263260

264261
for entry in fs::read_dir(build_dir.join("deps")).unwrap() {

src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,17 @@ impl CodegenBackend for CraneliftCodegenBackend {
240240
#[cfg(not(feature = "jit"))]
241241
tcx.dcx().fatal("jit support was disabled when compiling rustc_codegen_cranelift");
242242
} else {
243+
if tcx.sess.opts.cg.linker_plugin_lto.enabled() {
244+
#[cfg(feature = "lto")]
245+
return driver::lto::run_aot(tcx);
246+
247+
#[cfg(not(feature = "lto"))]
248+
tcx.dcx().fatal("LTO support was disabled when compiling rustc_codegen_cranelift");
249+
}
250+
243251
match tcx.sess.lto() {
244252
Lto::No | Lto::ThinLocal => driver::aot::run_aot(tcx),
245253
Lto::Thin | Lto::Fat => {
246-
if tcx.crate_name(LOCAL_CRATE) == sym::compiler_builtins {
247-
return driver::aot::run_aot(tcx);
248-
}
249-
250254
#[cfg(feature = "lto")]
251255
return driver::lto::run_aot(tcx);
252256

0 commit comments

Comments
 (0)