From 536f3b2c6f435fff0fee210ae1ae44e108154812 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Thu, 23 Jun 2022 19:39:36 +1000 Subject: [PATCH] Fix macos detection: Use `super::TARGET` as fallback When `guess_host_triple` failed to detect the target. Signed-off-by: Jiahao XU --- src/target.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/target.rs b/src/target.rs index 1ce8d308..7f65209c 100644 --- a/src/target.rs +++ b/src/target.rs @@ -141,17 +141,20 @@ mod linux { #[cfg(target_os = "macos")] mod macos { + use super::TARGET; use guess_host_triple::guess_host_triple; pub(super) const AARCH64: &str = "aarch64-apple-darwin"; pub(super) const X86: &str = "x86_64-apple-darwin"; pub(super) fn detect_targets_macos() -> Vec { - if guess_host_triple() == Some(AARCH64) { - vec![AARCH64.into(), X86.into()] - } else { - vec![X86.into()] + let mut targets = vec![guess_host_triple().unwrap_or(TARGET).to_string()]; + + if targets[0] == AARCH64 { + targets.push(X86.into()); } + + targets } }