Skip to content

Commit 2fc8d71

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 e74d96b commit 2fc8d71

File tree

1 file changed

+7
-33
lines changed

1 file changed

+7
-33
lines changed

src/driver.rs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ 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.
18+
///
19+
/// FIXME(madsmtm): This is loaded from the sysroot that was built with the other `rustc` crates
20+
/// above, instead of via Cargo as you'd normally do. This is currently needed for LTO due to
21+
/// https://github.com/rust-lang/cc-rs/issues/1613.
1822
#[cfg(feature = "jemalloc")]
19-
extern crate tikv_jemalloc_sys as jemalloc_sys;
23+
extern crate tikv_jemalloc_sys as _;
2024

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

190194
#[expect(clippy::too_many_lines)]
191195
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-
222196
let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
223197

224198
rustc_driver::init_rustc_env_logger(&early_dcx);

0 commit comments

Comments
 (0)