@@ -13,10 +13,10 @@ extern crate rustc_interface;
1313extern crate rustc_session;
1414extern 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
2121use clippy_utils:: sym;
2222use 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) ]
191191pub 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