Skip to content

Commit aeff80d

Browse files
committed
[WIP] Support hybrid LTO/non-LTO rlibs.
1 parent 8ee8831 commit aeff80d

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

build_system/build_sysroot.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ fn build_clif_sysroot_for_triple(
212212
}
213213

214214
// Build sysroot
215-
let mut rustflags = vec!["-Zforce-unstable-if-unmarked".to_owned()];
215+
let mut rustflags =
216+
vec!["-Zforce-unstable-if-unmarked".to_owned(), "-Cembed-bitcode=yes".to_owned()];
216217
if !panic_unwind_support {
217218
rustflags.push("-Cpanic=abort".to_owned());
218219
}
@@ -237,8 +238,6 @@ fn build_clif_sysroot_for_triple(
237238
rustflags.push("--remap-path-prefix".to_owned());
238239
rustflags.push(format!("library/={}/library", prefix.to_str().unwrap()));
239240
}
240-
rustflags.push("-Clto=fat".to_owned());
241-
rustflags.push("-Zdylib-lto".to_owned());
242241
rustflags.push("-Cembed-bitcode=yes".to_owned());
243242
compiler.rustflags.extend(rustflags);
244243
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
@@ -256,7 +255,6 @@ fn build_clif_sysroot_for_triple(
256255
if env::var_os("CARGO_BUILD_INCREMENTAL").is_none() {
257256
build_cmd.env("CARGO_BUILD_INCREMENTAL", "true");
258257
}
259-
build_cmd.env("CARGO_PROFILE_RELEASE_LTO", "thin");
260258
spawn_and_wait(build_cmd);
261259

262260
for entry in fs::read_dir(build_dir.join("build"))

src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,19 @@ impl CodegenBackend for CraneliftCodegenBackend {
222222
#[cfg(not(feature = "jit"))]
223223
tcx.dcx().fatal("jit support was disabled when compiling rustc_codegen_cranelift");
224224
} else {
225+
if tcx.sess.opts.cg.linker_plugin_lto.enabled() {
226+
#[cfg(feature = "lto")]
227+
return driver::lto::run_lto(tcx);
228+
229+
#[cfg(not(feature = "lto"))]
230+
tcx.dcx().fatal("LTO support was disabled when compiling rustc_codegen_cranelift");
231+
}
232+
225233
match tcx.sess.lto() {
226234
Lto::No | Lto::ThinLocal => {
227235
Box::new(rustc_codegen_ssa::base::codegen_crate(driver::aot::AotDriver, tcx))
228236
}
229237
Lto::Thin | Lto::Fat => {
230-
if tcx.is_compiler_builtins(LOCAL_CRATE) {
231-
return Box::new(rustc_codegen_ssa::base::codegen_crate(
232-
driver::aot::AotDriver,
233-
tcx,
234-
));
235-
}
236-
237238
// #[cfg(feature = "lto")]
238239
// return Box::new(rustc_codegen_ssa::base::codegen_crate(
239240
// driver::lto::LtoDriver,

0 commit comments

Comments
 (0)