Add an Mmap wrapper to rustc_data_structures

This wrapper implements StableAddress and falls back to directly reading
the file on wasm32
This commit is contained in:
bjorn3 2021-03-29 11:18:52 +02:00
parent 3aedcf06b7
commit 8331dbe6d0
12 changed files with 56 additions and 50 deletions

View file

@ -10,6 +10,7 @@ use crate::{
use crate::traits::*;
use jobserver::{Acquired, Client};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::profiling::TimingGuard;
use rustc_data_structures::profiling::VerboseTimingGuard;
@ -1958,7 +1959,7 @@ pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
.unwrap_or_else(|e| panic!("failed to open bitcode file `{}`: {}", bc_path.display(), e));
let mmap = unsafe {
memmap2::Mmap::map(&file).unwrap_or_else(|e| {
Mmap::map(file).unwrap_or_else(|e| {
panic!("failed to mmap bitcode file `{}`: {}", bc_path.display(), e)
})
};