diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index dc07fc35d..12daa04d4 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -338,6 +338,16 @@ fn main() { println!("cargo:rustc-link-lib=atomic"); } println!("cargo:rerun-if-changed=jemalloc"); + + if target.contains("android") { + // These symbols are used by jemalloc on android but the really old android + // we're building on doesn't have them defined, so just make sure the symbols + // are available. + cc::Build::new() + .file("src/pthread_atfork.c") + .compile("pthread_atfork"); + println!("cargo:rerun-if-changed=src/pthread_atfork.c"); + } } fn run_and_log(cmd: &mut Command, log_file: &Path) { diff --git a/jemalloc-sys/src/lib.rs b/jemalloc-sys/src/lib.rs index 58010afdc..5ad550772 100644 --- a/jemalloc-sys/src/lib.rs +++ b/jemalloc-sys/src/lib.rs @@ -890,20 +890,6 @@ pub type extent_merge_t = unsafe extern "C" fn( arena_ind: c_uint, ) -> c_bool; -// These symbols are used by jemalloc on android but the really old android -// we're building on doesn't have them defined, so just make sure the symbols -// are available. -#[no_mangle] -#[cfg(target_os = "android")] -#[doc(hidden)] -pub extern "C" fn pthread_atfork( - _prefork: *mut u8, - _postfork_parent: *mut u8, - _postfork_child: *mut u8, -) -> i32 { - 0 -} - #[allow(missing_docs)] mod env; diff --git a/jemalloc-sys/src/pthread_atfork.c b/jemalloc-sys/src/pthread_atfork.c new file mode 100644 index 000000000..254443d20 --- /dev/null +++ b/jemalloc-sys/src/pthread_atfork.c @@ -0,0 +1,11 @@ +/* + * These symbols are used by jemalloc on android but the really old android + * we're building on doesn't have them defined, so just make sure the symbols + * are available. + */ +__attribute__((weak)) int +pthread_atfork(void (*prepare)(void) __attribute__((unused)), + void (*parent)(void) __attribute__((unused)), + void (*child)(void) __attribute__((unused))) { + return 0; +}