Skip to content

Commit

Permalink
Merge #656: remove build.rs for android
Browse files Browse the repository at this point in the history
Since rust-lang/rust#120593
the minimum android API level is 21.

Related:
https://github.com/android/ndk/wiki/Changelog-r26
rust-lang/rust#129305

1. stop setting `dl_iterate_phdr` based on whether the android API level
    is greater than or equal to 21, but retain it for back compat.
2. remove `cc` build dependency.
3. upgrade ndk r25b to r26d in CI.
  • Loading branch information
workingjubilee committed Aug 23, 2024
2 parents fd0aed5 + 1f6cd98 commit 6a2e7a1
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 84 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "backtrace"
version = "0.3.73"
authors = ["The Rust Project Developers"]
build = "build.rs"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/rust-lang/backtrace-rs"
Expand Down Expand Up @@ -49,11 +48,6 @@ version = "0.36.0"
default-features = false
features = ['read_core', 'elf', 'macho', 'pe', 'xcoff', 'unaligned', 'archive']

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

[dev-dependencies]
dylib-dep = { path = "crates/dylib-dep" }
libloading = "0.7"
Expand Down
55 changes: 0 additions & 55 deletions build.rs

This file was deleted.

2 changes: 1 addition & 1 deletion ci/android-ndk.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set -ex

ANDROID_NDK_URL=https://dl.google.com/android/repository
ANDROID_NDK_ARCHIVE=android-ndk-r25b-linux.zip
ANDROID_NDK_ARCHIVE=android-ndk-r26d-linux.zip

mkdir /android-toolchain
cd /android-toolchain
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/arm-linux-androideabi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ RUN /android-ndk.sh
ENV PATH=$PATH:/android-toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin

# TODO: run tests in an emulator eventually
ENV CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi19-clang \
ENV CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi21-clang \
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER=echo
2 changes: 1 addition & 1 deletion ci/docker/armv7-linux-androideabi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ RUN /android-ndk.sh
ENV PATH=$PATH:/android-toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin

# TODO: run tests in an emulator eventually
ENV CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi19-clang \
ENV CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi21-clang \
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_RUNNER=echo
2 changes: 1 addition & 1 deletion ci/docker/i686-linux-android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ RUN /android-ndk.sh
ENV PATH=$PATH:/android-toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin

# TODO: run tests in an emulator eventually
ENV CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android19-clang \
ENV CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android21-clang \
CARGO_TARGET_I686_LINUX_ANDROID_RUNNER=echo
1 change: 0 additions & 1 deletion crates/as-if-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ features = ['read_core', 'elf', 'macho', 'pe', 'xcoff', 'unaligned', 'archive']

[build-dependencies]
# Dependency of the `backtrace` crate
cc = "1.0.97"
windows-bindgen = "0.56"

[features]
Expand Down
8 changes: 0 additions & 8 deletions crates/as-if-std/build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// backtrace-rs requires a feature check on Android targets, so
// we need to run its build.rs as well.
#[allow(unused_extern_crates)]
#[path = "../../build.rs"]
mod backtrace_build_rs;

fn main() {
println!("cargo:rustc-cfg=backtrace_in_libstd");

backtrace_build_rs::main();
}
14 changes: 6 additions & 8 deletions src/symbolize/gimli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Mapping {
// only borrow `map` and `stash` and we're preserving them below.
cx: unsafe { core::mem::transmute::<Context<'_>, Context<'static>>(cx) },
_map: data,
stash: stash,
stash,
})
}
}
Expand All @@ -122,13 +122,11 @@ impl<'data> Context<'data> {
if cfg!(not(target_os = "aix")) {
let data = object.section(stash, id.name()).unwrap_or(&[]);
Ok(EndianSlice::new(data, Endian))
} else if let Some(name) = id.xcoff_name() {
let data = object.section(stash, name).unwrap_or(&[]);
Ok(EndianSlice::new(data, Endian))
} else {
if let Some(name) = id.xcoff_name() {
let data = object.section(stash, name).unwrap_or(&[]);
Ok(EndianSlice::new(data, Endian))
} else {
Ok(EndianSlice::new(&[], Endian))
}
Ok(EndianSlice::new(&[], Endian))
}
})
.ok()?;
Expand Down Expand Up @@ -226,7 +224,7 @@ cfg_if::cfg_if! {
target_os = "hurd",
target_os = "openbsd",
target_os = "netbsd",
all(target_os = "android", feature = "dl_iterate_phdr"),
target_os = "android",
),
not(target_env = "uclibc"),
))] {
Expand Down

0 comments on commit 6a2e7a1

Please sign in to comment.