Sort fat LTO modules later and add a test.
This commit is contained in:
parent
ffa4d7e87f
commit
5b2c5e181a
@ -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())
|
||||
}));
|
||||
|
@ -755,15 +755,6 @@ pub enum FatLTOInput<B: WriteBackendMethods> {
|
||||
InMemory(ModuleCodegen<B::Module>),
|
||||
}
|
||||
|
||||
impl<B: WriteBackendMethods> FatLTOInput<B> {
|
||||
fn name(&'a self) -> &'a String {
|
||||
match self {
|
||||
FatLTOInput::Serialized { name, buffer: _ } => &name,
|
||||
FatLTOInput::InMemory(module) => &module.name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn execute_work_item<B: ExtraBackendMethods>(
|
||||
cgcx: &CodegenContext<B>,
|
||||
work_item: WorkItem<B>,
|
||||
@ -1354,15 +1345,10 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||
assert!(!started_lto);
|
||||
started_lto = true;
|
||||
|
||||
let mut needs_fat_lto: Vec<FatLTOInput<B>> = mem::take(&mut needs_fat_lto);
|
||||
let needs_fat_lto = mem::take(&mut needs_fat_lto);
|
||||
let needs_thin_lto = mem::take(&mut needs_thin_lto);
|
||||
let import_only_modules = mem::take(&mut lto_import_only_modules);
|
||||
|
||||
// Regardless of what order these modules completed in, report them to
|
||||
// the backend in the same order every time to ensure that we're handing
|
||||
// out deterministic results.
|
||||
needs_fat_lto.sort_by(|m1, m2| m1.name().cmp(m2.name()));
|
||||
|
||||
for (work, cost) in generate_lto_work(&cgcx, needs_fat_lto,
|
||||
needs_thin_lto, import_only_modules) {
|
||||
let insertion_index = work_items
|
||||
|
@ -10,7 +10,8 @@ all: \
|
||||
link_paths \
|
||||
remap_paths \
|
||||
different_source_dirs \
|
||||
extern_flags
|
||||
extern_flags \
|
||||
fat_lto
|
||||
|
||||
smoke:
|
||||
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
|
||||
@ -76,3 +77,11 @@ extern_flags:
|
||||
--extern reproducible_build_aux=$(TMPDIR)/libbar.rlib \
|
||||
--crate-type rlib
|
||||
cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
|
||||
|
||||
fat_lto:
|
||||
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
|
||||
$(RUSTC) reproducible-build-aux.rs
|
||||
$(RUSTC) reproducible-build.rs -C lto=fat
|
||||
cp $(TMPDIR)/reproducible-build $(TMPDIR)/reproducible-build-a
|
||||
$(RUSTC) reproducible-build.rs -C lto=fat
|
||||
cmp "$(TMPDIR)/reproducible-build-a" "$(TMPDIR)/reproducible-build" || exit 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user