Auto merge of #117504 - pcc:android-link-libunwind, r=Mark-Simulacrum

Remove obsolete support for linking unwinder on Android

Linking libgcc is no longer supported (see #103673), so remove the related link attributes and the check in unwind's build.rs. The check was the last remaining significant piece of logic in build.rs, so remove build.rs as well.
This commit is contained in:
bors 2023-11-05 09:50:21 +00:00
commit 513a48517e
4 changed files with 1 additions and 34 deletions

View file

@ -5923,7 +5923,6 @@ dependencies = [
name = "unwind"
version = "0.0.0"
dependencies = [
"cc",
"cfg-if",
"compiler_builtins",
"core",

View file

@ -19,9 +19,6 @@ libc = { version = "0.2.79", features = ['rustc-dep-of-std'], default-features =
compiler_builtins = "0.1.0"
cfg-if = "1.0"
[build-dependencies]
cc = "1.0.76"
[features]
# Only applies for Linux and Fuchsia targets

View file

@ -1,25 +0,0 @@
use std::env;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=CARGO_CFG_MIRI");
if env::var_os("CARGO_CFG_MIRI").is_some() {
// Miri doesn't need the linker flags or a libunwind build.
return;
}
let target = env::var("TARGET").expect("TARGET was not set");
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-cfg=feature=\"system-llvm-libunwind\"");
}
}
}

View file

@ -76,14 +76,10 @@
cfg_if::cfg_if! {
if #[cfg(feature = "llvm-libunwind")] {
compile_error!("`llvm-libunwind` is not supported for Android targets");
} else if #[cfg(feature = "system-llvm-libunwind")] {
} else {
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
} else {
#[link(name = "gcc", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "gcc", cfg(not(target_feature = "crt-static")))]
extern "C" {}
}
}
// Android's unwinding library depends on dl_iterate_phdr in `libdl`.