From 5065830aa007c374c382be9e80ba924df6cecc78 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Thu, 3 Feb 2022 15:27:01 -0700 Subject: Avoid depending on child process execution when not supported by host OS In accordance with the requesting issue (#10750): - `zig test` skips any tests that it cannot spawn, returning success - `zig run` and `zig build` exit with failure, reporting the command the cannot be run - `zig clang`, `zig ar`, etc. already punt directly to the appropriate clang/lld main(), even before this change - Native `libc` Detection is not supported Additionally, `exec()` and related Builder functions error at run-time, reporting the command that cannot be run --- lib/std/process.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/std/process.zig') diff --git a/lib/std/process.zig b/lib/std/process.zig index 699c994abf..c0f11b22ce 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -950,7 +950,13 @@ pub fn getSelfExeSharedLibPaths(allocator: Allocator) error{OutOfMemory}![][:0]u /// Tells whether calling the `execv` or `execve` functions will be a compile error. pub const can_execv = switch (builtin.os.tag) { - .windows, .haiku => false, + .windows, .haiku, .wasi => false, + else => true, +}; + +/// Tells whether spawning child processes is supported (e.g. via ChildProcess) +pub const can_spawn = switch (builtin.os.tag) { + .wasi => false, else => true, }; -- cgit v1.2.3