Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2485,7 +2485,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