From aa9eeff26370b17e8ba140b6cb285a4613047132 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 2 Aug 2018 14:26:55 +0200 Subject: [PATCH] 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). --- src/librustc_codegen_llvm/back/link.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index 108734b67d3..72084c170aa 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -1626,8 +1626,12 @@ fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { fn is_full_lto_enabled(sess: &Session) -> bool { match sess.lto() { Lto::Yes | - Lto::Thin | Lto::Fat => true, + Lto::Thin => { + // If we defer LTO to the linker, we haven't run LTO ourselves, so + // any upstream object files have not been copied yet. + !sess.opts.debugging_opts.cross_lang_lto.enabled() + } Lto::No | Lto::ThinLocal => false, }