Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove hard dependency on Android NDK presence when performing check builds #94813

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions library/unwind/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ fn main() {
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");
// When building with Miri we shouldn't invoke the compiler as this puts
// a hard dependency on the NDK being present.
let has_unwind = if env::var_os("CARGO_CFG_MIRI").is_some() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead do an early return just after println!("cargo:rerun-if-changed=build.rs"); for miri? We need neither linker flags nor building libunwind when using miri.

true
} else {
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.
build.is_flag_supported("-lunwind").expect("Unable to invoke compiler")
};

if has_unwind {
println!("cargo:rustc-link-lib=unwind");
Expand Down