Skip to content

Commit

Permalink
Auto merge of #53962 - michaelwoerister:close-thinlto-file-descriptor…
Browse files Browse the repository at this point in the history
…s, r=alexcrichton

ThinLTO: Don't keep files open after mmaping them.

Fixes #53947.

r? @alexcrichton
  • Loading branch information
bors committed Sep 5, 2018
2 parents 780b0c7 + fc47a92 commit 6e0f1cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use {ModuleCodegen, ModuleLlvm, ModuleKind};
use libc;

use std::ffi::{CStr, CString};
use std::fs::{self, File};
use std::fs;
use std::ptr;
use std::slice;
use std::sync::Arc;
Expand Down Expand Up @@ -619,15 +619,15 @@ fn run_pass_manager(cgcx: &CodegenContext,
pub enum SerializedModule {
Local(ModuleBuffer),
FromRlib(Vec<u8>),
FromUncompressedFile(memmap::Mmap, File),
FromUncompressedFile(memmap::Mmap),
}

impl SerializedModule {
fn data(&self) -> &[u8] {
match *self {
SerializedModule::Local(ref m) => m.data(),
SerializedModule::FromRlib(ref m) => m,
SerializedModule::FromUncompressedFile(ref m, _) => m,
SerializedModule::FromUncompressedFile(ref m) => m,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2494,7 +2494,7 @@ pub(crate) fn submit_pre_lto_module_to_llvm(tcx: TyCtxt,

// Schedule the module to be loaded
drop(tcx.tx_to_llvm_workers.lock().send(Box::new(Message::AddImportOnlyModule {
module_data: SerializedModule::FromUncompressedFile(mmap, file),
module_data: SerializedModule::FromUncompressedFile(mmap),
work_product: module.source,
})));
}
Expand Down

0 comments on commit 6e0f1cc

Please sign in to comment.