Skip to content

Commit a200679

Browse files
committed
Revert "Rollup merge of #146627 - madsmtm:jemalloc-simplify, r=jdonszelmann"
This reverts commit 5dc3c19, reversing changes made to 11339a0.
1 parent 3352bea commit a200679

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ tempfile = { version = "3.20", optional = true }
3131
termize = "0.2"
3232
color-print = "0.3.4"
3333
anstream = "0.6.18"
34-
tikv-jemalloc-sys = { version = "0.6.1", optional = true, features = ['override_allocator_on_supported_platforms'] }
3534

3635
[dev-dependencies]
3736
cargo_metadata = "0.18.1"
@@ -57,7 +56,7 @@ rustc_tools_util = { path = "rustc_tools_util", version = "0.4.2" }
5756
[features]
5857
integration = ["dep:tempfile"]
5958
internal = ["dep:clippy_lints_internal", "dep:tempfile"]
60-
jemalloc = ["dep:tikv-jemalloc-sys"]
59+
jemalloc = []
6160

6261
[package.metadata.rust-analyzer]
6362
# This package uses #[feature(rustc_private)]

src/driver.rs

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

2121
use clippy_utils::sym;
2222
use declare_clippy_lint::LintListBuilder;
@@ -189,6 +189,36 @@ 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+
192222
let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
193223

194224
rustc_driver::init_rustc_env_logger(&early_dcx);

0 commit comments

Comments
 (0)