Skip to content

Commit 5bf52a6

Browse files
authored
std: always allow spawning processes when an env map is explicitly provided (#25092)
In a library, the two `builtin.link_libc` and `builtin.output_mode == .Exe` checks could both be false. Thus, you would get a compile error even if you specified an `env_map` at runtime. This change turns the compile error into a runtime panic and updates the documentation to reflect the runtime requirement.
1 parent bc51264 commit 5bf52a6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/std/process/Child.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ term: ?(SpawnError!Term),
5252
argv: []const []const u8,
5353

5454
/// Leave as null to use the current env map using the supplied allocator.
55+
/// Required if unable to access the current env map (e.g. building a library on
56+
/// some platforms).
5557
env_map: ?*const EnvMap,
5658

5759
stdin_behavior: StdIo,
@@ -414,6 +416,8 @@ pub fn run(args: struct {
414416
argv: []const []const u8,
415417
cwd: ?[]const u8 = null,
416418
cwd_dir: ?fs.Dir = null,
419+
/// Required if unable to access the current env map (e.g. building a
420+
/// library on some platforms).
417421
env_map: ?*const EnvMap = null,
418422
max_output_bytes: usize = 50 * 1024,
419423
expand_arg0: Arg0Expand = .no_expand,
@@ -614,7 +618,7 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void {
614618
})).ptr;
615619
} else {
616620
// TODO come up with a solution for this.
617-
@compileError("missing std lib enhancement: ChildProcess implementation has no way to collect the environment variables to forward to the child process");
621+
@panic("missing std lib enhancement: ChildProcess implementation has no way to collect the environment variables to forward to the child process");
618622
}
619623
};
620624

0 commit comments

Comments
 (0)