about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/back
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2019-08-08 07:54:27 -0700
committerJoel Galenson <jgalenson@google.com>2019-08-08 08:58:09 -0700
commit5b2c5e181ac321f04621ef0b7dc78354bf3397d3 (patch)
tree6ec25ca92b51eeb93d7e82a8ee5410e1dddd8b01 /src/librustc_codegen_llvm/back
parentffa4d7e87f7565177693eefb4650bb32c3498968 (diff)
downloadrust-5b2c5e181ac321f04621ef0b7dc78354bf3397d3.tar.gz
rust-5b2c5e181ac321f04621ef0b7dc78354bf3397d3.zip
Sort fat LTO modules later and add a test.
Diffstat (limited to 'src/librustc_codegen_llvm/back')
-rw-r--r--src/librustc_codegen_llvm/back/lto.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs
index 5d3cc0c0a25..33b4c8eec54 100644
--- a/src/librustc_codegen_llvm/back/lto.rs
+++ b/src/librustc_codegen_llvm/back/lto.rs
@@ -265,7 +265,7 @@ fn fat_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
         // and we want to move everything to the same LLVM context. Currently the
         // way we know of to do that is to serialize them to a string and them parse
         // them later. Not great but hey, that's why it's "fat" LTO, right?
-        serialized_modules.extend(modules.into_iter().map(|module| {
+        let mut new_modules = modules.into_iter().map(|module| {
             match module {
                 FatLTOInput::InMemory(module) => {
                     let buffer = ModuleBuffer::new(module.module_llvm.llmod());
@@ -277,7 +277,9 @@ fn fat_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
                     (SerializedModule::Local(buffer), llmod_id)
                 }
             }
-        }));
+        }).collect::<Vec<_>>();
+        new_modules.sort_by(|module1, module2| module1.1.partial_cmp(&module2.1).unwrap());
+        serialized_modules.extend(new_modules);
         serialized_modules.extend(cached_modules.into_iter().map(|(buffer, wp)| {
             (buffer, CString::new(wp.cgu_name).unwrap())
         }));