From e2c0dcc417b0e187ecc4e6223c583db347b6faa5 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 19 May 2026 16:40:33 +0100 Subject: [PATCH] Try redefining --- Cargo.lock | 1 + rust/Cargo.toml | 8 +++++++- rust/src/lib.rs | 31 +++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 54fa711e1f..1d56fc1ec3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1342,6 +1342,7 @@ dependencies = [ "serde", "serde_json", "sha2", + "tikv-jemalloc-sys", "tikv-jemallocator", "tokio", "ulid", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 9608ed0de6..64290b3ca6 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -65,10 +65,16 @@ once_cell = "1.18.0" itertools = "0.14.0" tikv-jemallocator = { version = "0.6.1", features = [ "disable_initial_exec_tls", - "unprefixed_malloc_on_supported_platforms", +] } +tikv-jemalloc-sys = { version = "0.6.1", features = [ + "disable_initial_exec_tls", ] } [build-dependencies] blake2 = "0.10.4" hex = "0.4.3" rustc_version = "0.4.1" + + +[target.x86_64-unknown-linux-gnu] +rustflags = ["-C", "link-arg=-Wl,--version-script=export.map"] diff --git a/rust/src/lib.rs b/rust/src/lib.rs index bac2499fe9..1fe4496317 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -90,3 +90,34 @@ impl UnwrapInfallible for Result { } } } + +#[no_mangle] +pub unsafe extern "C" fn malloc(size: usize) -> *mut std::ffi::c_void { + tikv_jemalloc_sys::malloc(size) +} + +#[no_mangle] +pub unsafe extern "C" fn calloc(number: usize, size: usize) -> *mut std::ffi::c_void { + tikv_jemalloc_sys::calloc(number, size) +} + +#[no_mangle] +pub unsafe extern "C" fn realloc(ptr: *mut std::ffi::c_void, size: usize) -> *mut std::ffi::c_void { + tikv_jemalloc_sys::realloc(ptr, size) +} + +#[no_mangle] +pub unsafe extern "C" fn free(ptr: *mut std::ffi::c_void) { + tikv_jemalloc_sys::free(ptr) +} + +#[no_mangle] +pub unsafe extern "C" fn mallctl( + name: *const std::ffi::c_char, + oldp: *mut std::ffi::c_void, + oldlenp: *mut usize, + newp: *mut std::ffi::c_void, + newlen: usize, +) -> i32 { + tikv_jemalloc_sys::mallctl(name, oldp, oldlenp, newp, newlen) +}