From 55ee88f9c0cf2c03f05cce6cbb887dc60c8b418b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 2 Apr 2025 23:36:01 +0200 Subject: [PATCH 1/4] std.zig.system: Fix wine executable name in getExternalExecutor(). I'm not actually aware of any distro where the name is wine64, so just use wine in all cases. As part of this, I also fixed the architecture checks to match reality. Closes #23411. --- lib/std/zig/system.zig | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 427b260de0..8003c39dc8 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -128,19 +128,17 @@ pub fn getExternalExecutor( switch (candidate.os.tag) { .windows => { if (options.allow_wine) { - // x86_64 wine does not support emulating aarch64-windows and - // vice versa. - if (candidate.cpu.arch != builtin.cpu.arch and - !(candidate.cpu.arch == .thumb and builtin.cpu.arch == .aarch64) and - !(candidate.cpu.arch == .x86 and builtin.cpu.arch == .x86_64)) - { - return bad_result; - } - switch (candidate.ptrBitWidth()) { - 32 => return Executor{ .wine = "wine" }, - 64 => return Executor{ .wine = "wine64" }, - else => return bad_result, - } + const wine_supported = switch (candidate.cpu.arch) { + .thumb => switch (host.cpu.arch) { + .arm, .thumb, .aarch64 => true, + else => false, + }, + .aarch64 => host.cpu.arch == .aarch64, + .x86 => host.cpu.arch.isX86(), + .x86_64 => host.cpu.arch == .x86_64, + else => false, + }; + return if (wine_supported) Executor{ .wine = "wine" } else bad_result; } return bad_result; }, From 11db7eaf4efd0305c294a53c74e022e2231f67d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 2 Apr 2025 23:41:43 +0200 Subject: [PATCH 2/4] std.zig.system: Fix a check in getExternalExecutor() to use the host argument. --- lib/std/zig/system.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 8003c39dc8..4c38b19c1d 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -156,7 +156,7 @@ pub fn getExternalExecutor( // This check can be loosened once darling adds a QEMU-based emulation // layer for non-host architectures: // https://github.com/darlinghq/darling/issues/863 - if (candidate.cpu.arch != builtin.cpu.arch) { + if (candidate.cpu.arch != host.cpu.arch) { return bad_result; } return Executor{ .darling = "darling" }; From c3f2222a59af4c189562b63c45ead23b02cda5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 2 Apr 2025 23:47:37 +0200 Subject: [PATCH 3/4] std.zig.system: Make getExternalExecutor() less opinionated about Wasmtime. Wasmtime supports both wasm32 and wasm64, and can run freestanding WASM binaries just fine (although the usefulness of the latter is fairly limited). --- lib/std/zig/system.zig | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 4c38b19c1d..2a959217d8 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -125,6 +125,10 @@ pub fn getExternalExecutor( }; } + if (options.allow_wasmtime and candidate.cpu.arch.isWasm()) { + return Executor{ .wasmtime = "wasmtime" }; + } + switch (candidate.os.tag) { .windows => { if (options.allow_wine) { @@ -142,15 +146,6 @@ pub fn getExternalExecutor( } return bad_result; }, - .wasi => { - if (options.allow_wasmtime) { - switch (candidate.ptrBitWidth()) { - 32 => return Executor{ .wasmtime = "wasmtime" }, - else => return bad_result, - } - } - return bad_result; - }, .macos => { if (options.allow_darling) { // This check can be loosened once darling adds a QEMU-based emulation From 171cea74b64d4d2c6f7379cebc6b0b7162bb7b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 2 Apr 2025 23:50:09 +0200 Subject: [PATCH 4/4] std.zig.system: Make getExternalExecutor() allow Darling for driverkit. --- lib/std/zig/system.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 2a959217d8..81a3013b34 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -146,7 +146,7 @@ pub fn getExternalExecutor( } return bad_result; }, - .macos => { + .driverkit, .macos => { if (options.allow_darling) { // This check can be loosened once darling adds a QEMU-based emulation // layer for non-host architectures: