Skip to content

Commit

Permalink
Remove build.rs for Android when assuming API level is always >=21
Browse files Browse the repository at this point in the history
Since Rust 1.82 the minimum Android API level is 21.  In
`backtrace`, this warranted the removal of the API version check via
`__ANDROID_API__` in rust-lang/backtrace-rs#656
since it is now always known to be >=21.  When `findshlibs` bumps its
MSRV the same could be done.

This change is sparked by a long search for why backtraces always had
`<unknown>` symbols on Android - and when solving that by upgrading Rust
(for `std::backtrace`) or our `backtrace` dependency, why Sentry reports
did not record what images/libraries were loaded at which offsets to
resolve stack addresses back to function symbols.  It turned out that
the `xbuild` build tool never set `__ANDROID_API__` (by not telling
`clang` about the target API level via the triple) which would cause
this code to never set `feature = "dl_iterate_phdr"` to search for
libraries on Android: rust-mobile/xbuild#209
  • Loading branch information
MarijnS95 committed Jan 9, 2025
1 parent 42f4833 commit e943ece
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 61 deletions.
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ keywords = ["dyld", "dylib", "shared", "library", "dl_iterate_phdr"]
license = "MIT OR Apache-2.0"
readme = "./README.md"
repository = "https://github.com/gimli-rs/findshlibs"
rust-version = "1.82"

[dependencies]
libc = "0.2.104"

[build-dependencies]
# Only needed for Android, but cannot be target dependent
# https://github.com/rust-lang/cargo/issues/4932
cc = "1.0.67"

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
lazy_static = "1.4"

Expand Down
41 changes: 0 additions & 41 deletions build.rs

This file was deleted.

4 changes: 0 additions & 4 deletions src/android-api.c

This file was deleted.

15 changes: 4 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,18 @@
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub mod macos;

#[cfg(any(
target_os = "linux",
all(target_os = "android", feature = "dl_iterate_phdr")
))]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod linux;

#[cfg(target_os = "windows")]
pub mod windows;

use std::ffi::OsStr;
use std::fmt::{self, Debug};
use std::usize;

pub mod unsupported;

#[cfg(any(
target_os = "linux",
all(target_os = "android", feature = "dl_iterate_phdr")
))]
#[cfg(any(target_os = "linux", target_os = "android"))]
use crate::linux as native_mod;

#[cfg(any(target_os = "macos", target_os = "ios"))]
Expand All @@ -131,7 +124,7 @@ use crate::windows as native_mod;
target_os = "macos",
target_os = "ios",
target_os = "linux",
all(target_os = "android", feature = "dl_iterate_phdr"),
target_os = "android",
target_os = "windows"
)))]
use unsupported as native_mod;
Expand All @@ -145,7 +138,7 @@ pub const TARGET_SUPPORTED: bool = cfg!(any(
target_os = "macos",
target_os = "ios",
target_os = "linux",
all(target_os = "android", feature = "dl_iterate_phdr"),
target_os = "android",
target_os = "windows"
));

Expand Down

0 comments on commit e943ece

Please sign in to comment.