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:
Peter Collingbourne 2023-11-01 18:43:04 -07:00
parent 722b3eeb72
commit 654288bbb7
4 changed files with 1 additions and 34 deletions

View File

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

View File

@ -19,9 +19,6 @@ libc = { version = "0.2.79", features = ['rustc-dep-of-std'], default-features =
compiler_builtins = "0.1.0" compiler_builtins = "0.1.0"
cfg-if = "1.0" cfg-if = "1.0"
[build-dependencies]
cc = "1.0.76"
[features] [features]
# Only applies for Linux and Fuchsia targets # 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! { cfg_if::cfg_if! {
if #[cfg(feature = "llvm-libunwind")] { if #[cfg(feature = "llvm-libunwind")] {
compile_error!("`llvm-libunwind` is not supported for Android targets"); 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", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {} 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`. // Android's unwinding library depends on dl_iterate_phdr in `libdl`.