Skip to content

Commit 6118dcb

Browse files
committed
[WIP] Support hybrid LTO/non-LTO rlibs.
1 parent db3bb11 commit 6118dcb

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
@@ -197,7 +197,8 @@ fn build_clif_sysroot_for_triple(
197197
}
198198

199199
// Build sysroot
200-
let mut rustflags = vec!["-Zforce-unstable-if-unmarked".to_owned()];
200+
let mut rustflags =
201+
vec!["-Zforce-unstable-if-unmarked".to_owned(), "-Cembed-bitcode=yes".to_owned()];
201202
if !panic_unwind_support {
202203
rustflags.push("-Cpanic=abort".to_owned());
203204
}
@@ -224,8 +225,6 @@ fn build_clif_sysroot_for_triple(
224225
prefix.to_str().unwrap()
225226
));
226227
}
227-
rustflags.push("-Clto=thin".to_owned());
228-
rustflags.push("-Zdylib-lto".to_owned());
229228
rustflags.push("-Cembed-bitcode=yes".to_owned());
230229
compiler.rustflags.extend(rustflags);
231230
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
@@ -237,7 +236,6 @@ fn build_clif_sysroot_for_triple(
237236
if compiler.triple.contains("apple") {
238237
build_cmd.env("CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO", "packed");
239238
}
240-
build_cmd.env("CARGO_PROFILE_RELEASE_LTO", "thin");
241239
spawn_and_wait(build_cmd);
242240

243241
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
@@ -211,13 +211,17 @@ impl CodegenBackend for CraneliftCodegenBackend {
211211
#[cfg(not(feature = "jit"))]
212212
tcx.dcx().fatal("jit support was disabled when compiling rustc_codegen_cranelift");
213213
} else {
214+
if tcx.sess.opts.cg.linker_plugin_lto.enabled() {
215+
#[cfg(feature = "lto")]
216+
return driver::lto::run_lto(tcx);
217+
218+
#[cfg(not(feature = "lto"))]
219+
tcx.dcx().fatal("LTO support was disabled when compiling rustc_codegen_cranelift");
220+
}
221+
214222
match tcx.sess.lto() {
215223
Lto::No | Lto::ThinLocal => driver::aot::run_aot(tcx),
216224
Lto::Thin | Lto::Fat => {
217-
if tcx.crate_name(LOCAL_CRATE) == sym::compiler_builtins {
218-
return driver::aot::run_aot(tcx);
219-
}
220-
221225
#[cfg(feature = "lto")]
222226
return driver::lto::run_lto(tcx);
223227

0 commit comments

Comments
 (0)