Skip to content

Commit

Permalink
Use beta 2.x version of mimalloc
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Dec 27, 2021
1 parent b90cfc8 commit eb2a635
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 39 deletions.
27 changes: 10 additions & 17 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -888,12 +888,6 @@ dependencies = [
"syn",
]

[[package]]
name = "cty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"

[[package]]
name = "curl"
version = "0.4.41"
Expand Down Expand Up @@ -1942,16 +1936,6 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"

[[package]]
name = "libmimalloc-sys"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9636c194f9db483f4d0adf2f99a65011a99f904bd222bbd67fb4df4f37863c30"
dependencies = [
"cc",
"cty",
]

[[package]]
name = "libnghttp2-sys"
version = "0.1.4+1.41.0"
Expand Down Expand Up @@ -2253,6 +2237,15 @@ dependencies = [
"syn",
]

[[package]]
name = "mimallocate-sys"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40f7fce1d2b85a787a1dc11f59afab35d1fee036a5267b7e1d2013de1ba6eb83"
dependencies = [
"cc",
]

[[package]]
name = "minifier"
version = "0.0.41"
Expand Down Expand Up @@ -3489,7 +3482,7 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
name = "rustc-main"
version = "0.0.0"
dependencies = [
"libmimalloc-sys",
"mimallocate-sys",
"rustc_codegen_ssa",
"rustc_driver",
]
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ rustc_driver = { path = "../rustc_driver" }
# crate is intended to be used by codegen backends, which may not be in-tree.
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }

[dependencies.libmimalloc-sys]
version = '0.1.20'
[dependencies.mimallocate-sys]
version = '0.1.0'
optional = true
default-features = false
features = ['extended', 'override']

[features]
mimalloc = ['libmimalloc-sys']
mimalloc = ['mimallocate-sys']
llvm = ['rustc_driver/llvm']
max_level_info = ['rustc_driver/max_level_info']
25 changes: 10 additions & 15 deletions compiler/rustc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,34 @@

fn main() {
// See the comment at the top of this file for an explanation of this.
#[cfg(feature = "libmimalloc-sys")]
#[cfg(feature = "mimallocate-sys")]
{
use std::os::raw::{c_int, c_void};

#[used]
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = libmimalloc_sys::mi_calloc;
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = mimallocate_sys::mi_calloc;
#[used]
static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int =
libmimalloc_sys::mi_posix_memalign;
mimallocate_sys::mi_posix_memalign;
#[used]
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void =
libmimalloc_sys::mi_aligned_alloc;
mimallocate_sys::mi_aligned_alloc;
#[used]
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = libmimalloc_sys::mi_malloc;
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = mimallocate_sys::mi_malloc;
#[used]
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void =
libmimalloc_sys::mi_realloc;
mimallocate_sys::mi_realloc;
#[used]
static _F6: unsafe extern "C" fn(*mut c_void) = libmimalloc_sys::mi_free;
static _F6: unsafe extern "C" fn(*mut c_void) = mimallocate_sys::mi_free;

// On OSX, mimalloc doesn't directly override malloc/free, but instead
// registers itself with the allocator's zone APIs in a ctor. However,
// the linker doesn't seem to consider ctors as "used" when statically
// linking, so we need to explicitly depend on the function.
#[cfg(target_os = "macos")]
{
extern "C" {
fn _mi_macos_override_malloc();
}

#[used]
static _F7: unsafe extern "C" fn() = _mi_macos_override_malloc;
}
#[used]
static _F7: unsafe extern "C" fn() =
mimallocate_sys::_mi_macos_override_malloc;
}

rustc_driver::set_sigpipe_handler();
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ extern crate test;
// See docs in https://github.com/rust-lang/rust/blob/master/compiler/rustc/src/main.rs
// about mimalloc.
#[cfg(feature = "mimalloc")]
extern crate libmimalloc_sys;
extern crate mimallocate_sys;
#[cfg(feature = "mimalloc")]
use libmimalloc_sys as mimalloc_sys;
use mimallocate_sys as mimalloc_sys;

use std::default::Default;
use std::env;
Expand Down

0 comments on commit eb2a635

Please sign in to comment.