Skip to content

Commit efc4e37

Browse files
committed
Auto merge of #85806 - ATiltedTree:android-ndk-beta, r=petrochenkov
Support Android ndk versions `r23-beta3` and up Since android ndk version `r23-beta3`, `libgcc` has been replaced with `libunwind`. This moves the linking of `libgcc`/`libunwind` into the `unwind` crate where we check if the system compiler can find `libunwind` and fall back to `libgcc` if needed.
2 parents 595088d + b271f2b commit efc4e37

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,9 @@ dependencies = [
652652

653653
[[package]]
654654
name = "compiler_builtins"
655-
version = "0.1.43"
655+
version = "0.1.45"
656656
source = "registry+https://github.com/rust-lang/crates.io-index"
657-
checksum = "65af2dcae4779003dfa91aedc6ade7bdc7ba685944e50a8b4f9380df376a4466"
657+
checksum = "787187ae221adfcda34b03006f1617099e4ae26b50e5a4db282496014ab75837"
658658
dependencies = [
659659
"cc",
660660
"rustc-std-workspace-core",

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ panic_unwind = { path = "../panic_unwind", optional = true }
1717
panic_abort = { path = "../panic_abort" }
1818
core = { path = "../core" }
1919
libc = { version = "0.2.93", default-features = false, features = ['rustc-dep-of-std'] }
20-
compiler_builtins = { version = "0.1.43" }
20+
compiler_builtins = { version = "0.1.44" }
2121
profiler_builtins = { path = "../profiler_builtins", optional = true }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.11", default-features = false, features = ['rustc-dep-of-std'] }

library/std/src/sys/unix/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ cfg_if::cfg_if! {
210210
if #[cfg(target_os = "android")] {
211211
#[link(name = "dl")]
212212
#[link(name = "log")]
213-
#[link(name = "gcc")]
214213
extern "C" {}
215214
} else if #[cfg(target_os = "freebsd")] {
216215
#[link(name = "execinfo")]

library/unwind/build.rs

+14
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ fn main() {
2020
// linking for Linux is handled in lib.rs
2121
if target.contains("musl") {
2222
llvm_libunwind::compile();
23+
} else if target.contains("android") {
24+
let build = cc::Build::new();
25+
26+
// Since ndk r23 beta 3 `libgcc` was replaced with `libunwind` thus
27+
// check if we have `libunwind` available and if so use it. Otherwise
28+
// fall back to `libgcc` to support older ndk versions.
29+
let has_unwind =
30+
build.is_flag_supported("-lunwind").expect("Unable to invoke compiler");
31+
32+
if has_unwind {
33+
println!("cargo:rustc-link-lib=unwind");
34+
} else {
35+
println!("cargo:rustc-link-lib=gcc");
36+
}
2337
}
2438
} else if target.contains("freebsd") {
2539
println!("cargo:rustc-link-lib=gcc_s");

0 commit comments

Comments
 (0)