From 2b18dfe5da11dd88f14e4bc17d0e7c2ceb8b5b53 Mon Sep 17 00:00:00 2001 From: Lander Brandt Date: Thu, 10 Mar 2022 08:16:10 -0800 Subject: [PATCH] remove hard dependency on Android NDK presence when building unwind --- library/unwind/build.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/library/unwind/build.rs b/library/unwind/build.rs index a3f5224151d94..235edc68e6241 100644 --- a/library/unwind/build.rs +++ b/library/unwind/build.rs @@ -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() { + 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");