aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-11-10 07:40:52 -0800
committerJakub Konka <kubkon@jakubkonka.com>2021-12-02 00:22:09 +0100
commit3e2f8233a86bf4a2787eb6d37a54b9c8eae8a985 (patch)
treec937506b8b1ada5367bb2856674ac3728af7178e /lib
parent77c5208c77f8e91786192dfc4e5945d40d67312a (diff)
downloadzig-3e2f8233a86bf4a2787eb6d37a54b9c8eae8a985.tar.gz
zig-3e2f8233a86bf4a2787eb6d37a54b9c8eae8a985.zip
Make Rosetta a new variant in ExternalExecutor enum
When running, check if Rosetta is available, otherwise, pass the tests.
Diffstat (limited to 'lib')
-rw-r--r--lib/std/build.zig2
-rw-r--r--lib/std/zig/CrossTarget.zig9
-rw-r--r--lib/std/zig/cross_target.zig10
3 files changed, 14 insertions, 7 deletions
diff --git a/lib/std/build.zig b/lib/std/build.zig
index ea6a0e05f1..6c91303c14 100644
--- a/lib/std/build.zig
+++ b/lib/std/build.zig
@@ -2529,7 +2529,7 @@ pub const LibExeObjStep = struct {
}
}
} else switch (self.target.getExternalExecutor()) {
- .native, .unavailable => {},
+ .native, .rosetta, .unavailable => {},
.qemu => |bin_name| if (self.enable_qemu) qemu: {
const need_cross_glibc = self.target.isGnuLibC() and self.is_linking_libc;
const glibc_dir_arg = if (need_cross_glibc)
diff --git a/lib/std/zig/CrossTarget.zig b/lib/std/zig/CrossTarget.zig
index 6024c893fb..96213b1471 100644
--- a/lib/std/zig/CrossTarget.zig
+++ b/lib/std/zig/CrossTarget.zig
@@ -643,10 +643,13 @@ pub fn getExternalExecutor(self: CrossTarget) Executor {
return .native;
}
}
- // If the OS match and OS is macOS and CPU is arm64, treat always as native
- // since we'll be running the foreign architecture tests using Rosetta2.
+ // If the OS match and OS is macOS and CPU is arm64, we can use Rosetta 2
+ // to emulate the foreign architecture.
if (os_match and os_tag == .macos and builtin.cpu.arch == .aarch64) {
- return .native;
+ return switch (cpu_arch) {
+ .x86_64 => .rosetta,
+ else => .unavailable,
+ };
}
// If the OS matches, we can use QEMU to emulate a foreign architecture.
diff --git a/lib/std/zig/cross_target.zig b/lib/std/zig/cross_target.zig
index 8e3725c623..9134b6ad5c 100644
--- a/lib/std/zig/cross_target.zig
+++ b/lib/std/zig/cross_target.zig
@@ -596,6 +596,7 @@ pub const CrossTarget = struct {
pub const Executor = union(enum) {
native,
+ rosetta,
qemu: []const u8,
wine: []const u8,
wasmtime: []const u8,
@@ -626,10 +627,13 @@ pub const CrossTarget = struct {
return .native;
}
}
- // If the OS match and OS is macOS and CPU is arm64, treat always as native
- // since we'll be running the foreign architecture tests using Rosetta2.
+ // If the OS match and OS is macOS and CPU is arm64, we can use Rosetta 2
+ // to emulate the foreign architecture.
if (os_match and os_tag == .macos and builtin.cpu.arch == .aarch64) {
- return .native;
+ return switch (cpu_arch) {
+ .x86_64 => .rosetta,
+ else => .unavailable,
+ };
}
// If the OS matches, we can use QEMU to emulate a foreign architecture.