@@ -13,6 +13,11 @@ extern crate rustc_interface;
1313extern crate rustc_session;
1414extern crate rustc_span;
1515
16+ // See docs in https://github.com/rust-lang/rust/blob/master/compiler/rustc/src/main.rs
17+ // about jemalloc.
18+ #[ cfg( feature = "jemalloc" ) ]
19+ extern crate tikv_jemalloc_sys as jemalloc_sys;
20+
1621use clippy_utils:: sym;
1722use rustc_interface:: interface;
1823use rustc_session:: EarlyDiagCtxt ;
@@ -181,6 +186,36 @@ const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/ne
181186#[ allow( clippy:: too_many_lines) ]
182187#[ allow( clippy:: ignored_unit_patterns) ]
183188pub fn main ( ) {
189+ // See docs in https://github.com/rust-lang/rust/blob/master/compiler/rustc/src/main.rs
190+ // about jemalloc.
191+ #[ cfg( feature = "jemalloc" ) ]
192+ {
193+ use std:: os:: raw:: { c_int, c_void} ;
194+
195+ #[ used]
196+ static _F1: unsafe extern "C" fn ( usize , usize ) -> * mut c_void = jemalloc_sys:: calloc;
197+ #[ used]
198+ static _F2: unsafe extern "C" fn ( * mut * mut c_void , usize , usize ) -> c_int = jemalloc_sys:: posix_memalign;
199+ #[ used]
200+ static _F3: unsafe extern "C" fn ( usize , usize ) -> * mut c_void = jemalloc_sys:: aligned_alloc;
201+ #[ used]
202+ static _F4: unsafe extern "C" fn ( usize ) -> * mut c_void = jemalloc_sys:: malloc;
203+ #[ used]
204+ static _F5: unsafe extern "C" fn ( * mut c_void , usize ) -> * mut c_void = jemalloc_sys:: realloc;
205+ #[ used]
206+ static _F6: unsafe extern "C" fn ( * mut c_void ) = jemalloc_sys:: free;
207+
208+ #[ cfg( target_os = "macos" ) ]
209+ {
210+ unsafe extern "C" {
211+ fn _rjem_je_zone_register ( ) ;
212+ }
213+
214+ #[ used]
215+ static _F7: unsafe extern "C" fn ( ) = _rjem_je_zone_register;
216+ }
217+ }
218+
184219 let early_dcx = EarlyDiagCtxt :: new ( ErrorOutputType :: default ( ) ) ;
185220
186221 rustc_driver:: init_rustc_env_logger ( & early_dcx) ;
0 commit comments