Skip to content

Commit 17346a7

Browse files
Make sure upstream object files are added to staticlibs when compiling
with ThinLTO and cross-lang-lto. Normally, when compiling with whole-crate-graph ThinLTO, we expect rustc's LTO step to "uplift" upstream object files/LLVM modules to the current set of compilation artifacts. Therefore the staticlib creation code skips this uplifting. However, when compiling with "cross-language LTO" (i.e. defer LTO to the actual linker), the LTO step in rustc is not performed, so we have to take care of copying upstream object files during archive creation (like we already do when compiling without any LTO).
1 parent 282a7a7 commit 17346a7

File tree

1 file changed

+5
-1
lines changed
  • src/librustc_codegen_llvm/back

1 file changed

+5
-1
lines changed

src/librustc_codegen_llvm/back/link.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,8 +1626,12 @@ fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
16261626
fn is_full_lto_enabled(sess: &Session) -> bool {
16271627
match sess.lto() {
16281628
Lto::Yes |
1629-
Lto::Thin |
16301629
Lto::Fat => true,
1630+
Lto::Thin => {
1631+
// If we defer LTO to the linker, we haven't run LTO ourselves, so
1632+
// any upstream object files have not been copied yet.
1633+
!sess.opts.debugging_opts.cross_lang_lto.enabled()
1634+
}
16311635
Lto::No |
16321636
Lto::ThinLocal => false,
16331637
}

0 commit comments

Comments
 (0)