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

Fix aarch64-apple-darwin fallback to x86_64h #1278

Merged
merged 1 commit into from
Aug 11, 2023
Merged
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
12 changes: 9 additions & 3 deletions crates/detect-targets/src/detect/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@ async fn is_arch_supported(arch_name: &str) -> bool {
pub(super) async fn detect_alternative_targets(target: &str) -> impl Iterator<Item = String> {
match target {
AARCH64 => {
let is_x86_64_supported = is_arch_supported("x86_64").await;
// Spawn `arch` in parallel (probably from different threads if
// mutlti-thread runtime is used).
//
// These two tasks are never cancelled, so it can only fail due to
// panic, in which cause we would propagate by also panic here.
let x86_64h_task = tokio::spawn(is_arch_supported("x86_64h"));
let x86_64_task = tokio::spawn(is_arch_supported("x86_64"));
[
// Prefer universal as it provides native arm executable
Copy link
Member

Choose a reason for hiding this comment

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

Hmm unrelated to this PR but I wonder about that, given that universal can contain anything really. Like you could have a x64 and x64h universal with no arm

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, according to bjorn3 on zulip it could even have a PowerPC and m68k binary inside.

Some(UNIVERSAL),
Some(UNIVERSAL2),
// Prefer x86h since it is more optimized
is_x86_64_supported.then_some(X86H),
is_x86_64_supported.then_some(X86),
x86_64h_task.await.unwrap().then_some(X86H),
x86_64_task.await.unwrap().then_some(X86),
]
}
X86 => [
Expand Down