Skip to content

Commit e5c0cb0

Browse files
committed
[WIP] Support hybrid LTO/non-LTO rlibs.
1 parent 99e28e9 commit e5c0cb0

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

build_system/build_sysroot.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ fn build_clif_sysroot_for_triple(
216216
}
217217

218218
// Build sysroot
219-
let mut rustflags = vec!["-Zforce-unstable-if-unmarked".to_owned()];
219+
let mut rustflags =
220+
vec!["-Zforce-unstable-if-unmarked".to_owned(), "-Cembed-bitcode=yes".to_owned()];
220221
if !panic_unwind_support {
221222
rustflags.push("-Cpanic=abort".to_owned());
222223
}
@@ -245,8 +246,6 @@ fn build_clif_sysroot_for_triple(
245246
prefix.to_str().unwrap()
246247
));
247248
}
248-
rustflags.push("-Clto=thin".to_owned());
249-
rustflags.push("-Zdylib-lto".to_owned());
250249
rustflags.push("-Cembed-bitcode=yes".to_owned());
251250
compiler.rustflags.extend(rustflags);
252251
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
@@ -258,7 +257,6 @@ fn build_clif_sysroot_for_triple(
258257
if compiler.triple.contains("apple") {
259258
build_cmd.env("CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO", "packed");
260259
}
261-
build_cmd.env("CARGO_PROFILE_RELEASE_LTO", "thin");
262260
spawn_and_wait(build_cmd);
263261

264262
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)