aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-05-13 11:03:44 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-05-13 20:31:33 +0200
commit402264ab0e16dfdc98e861a440df9ef5db35c402 (patch)
tree6abe6a4502e56cef173f48c8a75a09f3a83d37cb /lib
parente902c19c0e2bf7f0e9bc83b2c58d19ec024d56db (diff)
downloadzig-402264ab0e16dfdc98e861a440df9ef5db35c402.tar.gz
zig-402264ab0e16dfdc98e861a440df9ef5db35c402.zip
Add experimental Darling support for cross testing macOS
* for cross testing stage2 tests, we use `darling shell` command since the path to the tested binary is relative to cwd * for the `zig test` command, we simply use `darling` since the path to the binary is absolute
Diffstat (limited to 'lib')
-rw-r--r--lib/std/build.zig8
-rw-r--r--lib/std/zig/cross_target.zig10
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/std/build.zig b/lib/std/build.zig
index 9d12a4de51..808f3374d8 100644
--- a/lib/std/build.zig
+++ b/lib/std/build.zig
@@ -1398,6 +1398,9 @@ pub const LibExeObjStep = struct {
/// Uses system Wasmtime installation to run cross compiled wasm/wasi build artifacts.
enable_wasmtime: bool = false,
+ /// Experimental. Uses system Darling installation to run cross compiled macOS build artifacts.
+ enable_darling: bool = false,
+
/// After following the steps in https://github.com/ziglang/zig/wiki/Updating-libc#glibc,
/// this will be the directory $glibc-build-dir/install/glibcs
/// Given the example of the aarch64 target, this is the directory
@@ -2514,6 +2517,11 @@ pub const LibExeObjStep = struct {
try zig_args.append("--dir=.");
try zig_args.append("--test-cmd-bin");
},
+ .darling => |bin_name| if (self.enable_darling) {
+ try zig_args.append("--test-cmd");
+ try zig_args.append(bin_name);
+ try zig_args.append("--test-cmd-bin");
+ },
}
for (self.packages.items) |pkg| {
diff --git a/lib/std/zig/cross_target.zig b/lib/std/zig/cross_target.zig
index bf62a49ef6..e724be17ae 100644
--- a/lib/std/zig/cross_target.zig
+++ b/lib/std/zig/cross_target.zig
@@ -606,6 +606,7 @@ pub const CrossTarget = struct {
qemu: []const u8,
wine: []const u8,
wasmtime: []const u8,
+ darling: []const u8,
unavailable,
};
@@ -667,6 +668,15 @@ pub const CrossTarget = struct {
32 => return Executor{ .wasmtime = "wasmtime" },
else => return .unavailable,
},
+ .macos => {
+ // TODO loosen this check once upstream adds QEMU-based emulation
+ // layer for non-host architectures:
+ // https://github.com/darlinghq/darling/issues/863
+ if (cpu_arch != Target.current.cpu.arch) {
+ return .unavailable;
+ }
+ return Executor{ .darling = "darling" };
+ },
else => return .unavailable,
}
}