Skip to content

Commit

Permalink
Rollup merge of rust-lang#83236 - cjgillot:memmap, r=joshtriplett
Browse files Browse the repository at this point in the history
Upgrade memmap to memmap2

memmap is no longer maintained. memmap2 is a fork that is still maintained. https://rustsec.org/advisories/RUSTSEC-2020-0077.html

The remaining use of memmap is through measureme.
  • Loading branch information
JohnTitor authored Mar 19, 2021
2 parents ac5f433 + 458d044 commit 2eb324f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
13 changes: 11 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,15 @@ dependencies = [
"winapi 0.3.9",
]

[[package]]
name = "memmap2"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04e3e85b970d650e2ae6d70592474087051c11c54da7f7b4949725c5735fbcc6"
dependencies = [
"libc",
]

[[package]]
name = "memoffset"
version = "0.5.5"
Expand Down Expand Up @@ -3782,7 +3791,7 @@ dependencies = [
"itertools 0.9.0",
"jobserver",
"libc",
"memmap",
"memmap2",
"pathdiff",
"rustc_apfloat",
"rustc_ast",
Expand Down Expand Up @@ -4116,7 +4125,7 @@ name = "rustc_metadata"
version = "0.0.0"
dependencies = [
"libc",
"memmap",
"memmap2",
"rustc_ast",
"rustc_attr",
"rustc_data_structures",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test = false
bitflags = "1.2.1"
cc = "1.0.1"
itertools = "0.9"
memmap = "0.7"
memmap2 = "0.2.1"
tracing = "0.1"
libc = "0.2.50"
jobserver = "0.1.11"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
pub enum SerializedModule<M: ModuleBufferMethods> {
Local(M),
FromRlib(Vec<u8>),
FromUncompressedFile(memmap::Mmap),
FromUncompressedFile(memmap2::Mmap),
}

impl<M: ModuleBufferMethods> SerializedModule<M> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,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 {
memmap::Mmap::map(&file).unwrap_or_else(|e| {
memmap2::Mmap::map(&file).unwrap_or_else(|e| {
panic!("failed to mmap bitcode file `{}`: {}", bc_path.display(), e)
})
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ doctest = false
libc = "0.2"
snap = "1"
tracing = "0.1"
memmap = "0.7"
memmap2 = "0.2.1"
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
rustc_middle = { path = "../rustc_middle" }
rustc_attr = { path = "../rustc_attr" }
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl<'a> CrateLocator<'a> {
}

/// A trivial wrapper for `Mmap` that implements `StableDeref`.
struct StableDerefMmap(memmap::Mmap);
struct StableDerefMmap(memmap2::Mmap);

impl Deref for StableDerefMmap {
type Target = [u8];
Expand Down Expand Up @@ -779,7 +779,7 @@ fn get_metadata_section(
// mmap the file, because only a small fraction of it is read.
let file = std::fs::File::open(filename)
.map_err(|_| format!("failed to open rmeta metadata: '{}'", filename.display()))?;
let mmap = unsafe { memmap::Mmap::map(&file) };
let mmap = unsafe { memmap2::Mmap::map(&file) };
let mmap = mmap
.map_err(|_| format!("failed to mmap rmeta metadata: '{}'", filename.display()))?;

Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
"measureme",
"memchr",
"memmap",
"memmap2",
"memoffset",
"miniz_oxide",
"num_cpus",
Expand Down

0 comments on commit 2eb324f

Please sign in to comment.