Skip to content

Commit 805804a

Browse files
authored
fix: compile aarch64-linux-android binary on linux when enable lto. (#83)
Close #81. Signed-off-by: fys <fengys1996@gmail.com>
1 parent 4f35ea8 commit 805804a

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

jemalloc-sys/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,16 @@ fn main() {
338338
println!("cargo:rustc-link-lib=atomic");
339339
}
340340
println!("cargo:rerun-if-changed=jemalloc");
341+
342+
if target.contains("android") {
343+
// These symbols are used by jemalloc on android but the really old android
344+
// we're building on doesn't have them defined, so just make sure the symbols
345+
// are available.
346+
cc::Build::new()
347+
.file("src/pthread_atfork.c")
348+
.compile("pthread_atfork");
349+
println!("cargo:rerun-if-changed=src/pthread_atfork.c");
350+
}
341351
}
342352

343353
fn run_and_log(cmd: &mut Command, log_file: &Path) {

jemalloc-sys/src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -890,20 +890,6 @@ pub type extent_merge_t = unsafe extern "C" fn(
890890
arena_ind: c_uint,
891891
) -> c_bool;
892892

893-
// These symbols are used by jemalloc on android but the really old android
894-
// we're building on doesn't have them defined, so just make sure the symbols
895-
// are available.
896-
#[no_mangle]
897-
#[cfg(target_os = "android")]
898-
#[doc(hidden)]
899-
pub extern "C" fn pthread_atfork(
900-
_prefork: *mut u8,
901-
_postfork_parent: *mut u8,
902-
_postfork_child: *mut u8,
903-
) -> i32 {
904-
0
905-
}
906-
907893
#[allow(missing_docs)]
908894
mod env;
909895

jemalloc-sys/src/pthread_atfork.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* These symbols are used by jemalloc on android but the really old android
3+
* we're building on doesn't have them defined, so just make sure the symbols
4+
* are available.
5+
*/
6+
__attribute__((weak)) int
7+
pthread_atfork(void (*prepare)(void) __attribute__((unused)),
8+
void (*parent)(void) __attribute__((unused)),
9+
void (*child)(void) __attribute__((unused))) {
10+
return 0;
11+
}

0 commit comments

Comments
 (0)