diff options
| author | Steven Fackler <sfackler@gmail.com> | 2021-02-28 14:50:03 -0500 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2021-02-28 14:53:21 -0500 |
| commit | 6e52b23fa94ed967daed38cb3796d0874ec705a7 (patch) | |
| tree | c26171dee02d31525c2ae9660f8265d5b9d0d648 /compiler/rustc | |
| parent | 573a697a6197abaad5a2d7208dbf1bbc77f4dcf3 (diff) | |
| download | rust-6e52b23fa94ed967daed38cb3796d0874ec705a7.tar.gz rust-6e52b23fa94ed967daed38cb3796d0874ec705a7.zip | |
Fix jemalloc usage on OSX
Closes #82423
Diffstat (limited to 'compiler/rustc')
| -rw-r--r-- | compiler/rustc/src/main.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc/src/main.rs b/compiler/rustc/src/main.rs index 6bc5aa6382c..3f03d1b6869 100644 --- a/compiler/rustc/src/main.rs +++ b/compiler/rustc/src/main.rs @@ -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(); |
