Skip to content

Commit

Permalink
fix: compile aarch64-linux-android binary on linux when enable lto.
Browse files Browse the repository at this point in the history
  • Loading branch information
fengys1996 committed Apr 30, 2024
1 parent 4f35ea8 commit 19f57f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
5 changes: 5 additions & 0 deletions jemalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ fn main() {
println!("cargo:rustc-link-lib=atomic");
}
println!("cargo:rerun-if-changed=jemalloc");

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) {
Expand Down
14 changes: 0 additions & 14 deletions jemalloc-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 11 additions & 0 deletions jemalloc-sys/src/pthread_atfork.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdint.h>

// 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(uint8_t *prefork __attribute__((unused)),
uint8_t *postfork_parent __attribute__((unused)),
uint8_t *postfork_child __attribute__((unused))) {
return 0;
}

0 comments on commit 19f57f2

Please sign in to comment.