summaryrefslogtreecommitdiff
path: root/library/unwind/build.rs
diff options
context:
space:
mode:
authorTilmann Meyer <allescrafterx@gmail.com>2021-05-29 13:20:55 +0200
committerTilmann Meyer <allescrafterx@gmail.com>2021-06-01 21:37:50 +0200
commit965997b369a3c5c46e998e522333aadb7881237b (patch)
tree70d502083744f3b7822e83d44d6f9d136a2e8522 /library/unwind/build.rs
parent971a3f15f02752017e4d067acc01d3793dc72c40 (diff)
downloadrust-965997b369a3c5c46e998e522333aadb7881237b.tar.gz
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.
Diffstat (limited to 'library/unwind/build.rs')
-rw-r--r--library/unwind/build.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/library/unwind/build.rs b/library/unwind/build.rs
index 96df3fc5ac4..0529d24a274 100644
--- a/library/unwind/build.rs
+++ b/library/unwind/build.rs
@@ -20,6 +20,20 @@ fn main() {
// linking for Linux is handled in lib.rs
if target.contains("musl") {
llvm_libunwind::compile();
+ } else if target.contains("android") {
+ let build = cc::Build::new();
+
+ // Since ndk r23 beta 3 `libgcc` was replaced with `libunwind` thus
+ // check if we have `libunwind` available and if so use it. Otherwise
+ // fall back to `libgcc` to support older ndk versions.
+ let has_unwind =
+ build.is_flag_supported("-lunwind").expect("Unable to invoke compiler");
+
+ if has_unwind {
+ println!("cargo:rustc-link-lib=unwind");
+ } else {
+ println!("cargo:rustc-link-lib=gcc");
+ }
}
} else if target.contains("freebsd") {
println!("cargo:rustc-link-lib=gcc_s");