Skip to content

Commit

Permalink
Rollup merge of rust-lang#82642 - sfackler:jemalloc-zone, r=pnkfelix
Browse files Browse the repository at this point in the history
Fix jemalloc usage on OSX

Closes rust-lang#82423
  • Loading branch information
Dylan-DPC committed Mar 8, 2021
2 parents 6dbcc77 + 1b4860a commit a5bb582
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions compiler/rustc/src/main.rs
Expand Up @@ -24,6 +24,20 @@ fn main() {
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc;
#[used]
static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free;

// On OSX, jemalloc 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 _rjem_je_zone_register();
}

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

rustc_driver::set_sigpipe_handler();
Expand Down

0 comments on commit a5bb582

Please sign in to comment.