Skip to content

Commit a72893f

Browse files
committed
Simplify jemalloc setup
Using the new `override_allocator_on_supported_platforms` feature in `tikv-jemalloc-sys v0.6.1` we can avoid the manual statics.
1 parent 39107ff commit a72893f

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

src/driver.rs

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ extern crate rustc_interface;
1313
extern crate rustc_session;
1414
extern crate rustc_span;
1515

16-
// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs
17-
// about jemalloc.
16+
/// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs
17+
/// and https://github.com/rust-lang/rust/pull/146627 for why we need this `use` statement.
1818
#[cfg(feature = "jemalloc")]
19-
extern crate tikv_jemalloc_sys as jemalloc_sys;
19+
use tikv_jemalloc_sys as _;
2020

2121
use clippy_utils::sym;
2222
use declare_clippy_lint::LintListBuilder;
@@ -189,36 +189,6 @@ const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/ne
189189

190190
#[expect(clippy::too_many_lines)]
191191
pub fn main() {
192-
// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs
193-
// about jemalloc.
194-
#[cfg(feature = "jemalloc")]
195-
{
196-
use std::os::raw::{c_int, c_void};
197-
198-
#[used]
199-
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::calloc;
200-
#[used]
201-
static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int = jemalloc_sys::posix_memalign;
202-
#[used]
203-
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::aligned_alloc;
204-
#[used]
205-
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc;
206-
#[used]
207-
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc;
208-
#[used]
209-
static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free;
210-
211-
#[cfg(target_os = "macos")]
212-
{
213-
unsafe extern "C" {
214-
fn _rjem_je_zone_register();
215-
}
216-
217-
#[used]
218-
static _F7: unsafe extern "C" fn() = _rjem_je_zone_register;
219-
}
220-
}
221-
222192
let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
223193

224194
rustc_driver::init_rustc_env_logger(&early_dcx);

0 commit comments

Comments
 (0)