authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-02 21:57:47-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-04 00:27:09-08:00
log1070c2a71a89175461273eba9f49bb85bdc83ecd
tree78be01bf6551d1aa1c1314769c9272846cb21ef6
parentf25de4c7a238d46a20c6a22e3b951ee09ecfb962

rename env_map to environ_map

For naming consistency with `std.process.Environ.Map`.

37 files changed, 290 insertions(+), 291 deletions(-)

lib/compiler/aro/aro/Compilation.zig+2-2
......@@ -193,14 +193,14 @@ pub fn initDefault(
193193 io: Io,
194194 diagnostics: *Diagnostics,
195195 cwd: Io.Dir,
196 env_map: *const std.process.Environ.Map,
196 environ_map: *const std.process.Environ.Map,
197197) !Compilation {
198198 var comp: Compilation = .{
199199 .gpa = gpa,
200200 .arena = arena,
201201 .io = io,
202202 .diagnostics = diagnostics,
203 .environment = try Environment.loadAll(gpa, env_map),
203 .environment = try Environment.loadAll(gpa, environ_map),
204204 .cwd = cwd,
205205 };
206206 errdefer comp.deinit();
lib/compiler/build_runner.zig+5-5
......@@ -87,7 +87,7 @@ pub fn main(init: process.Init.Minimal) !void {
8787 .cwd = try process.getCwdAlloc(single_threaded_arena.allocator()),
8888 },
8989 .zig_exe = zig_exe,
90 .env_map = try init.environ.createMap(arena),
90 .environ_map = try init.environ.createMap(arena),
9191 .global_cache_root = global_cache_directory,
9292 .zig_lib_directory = zig_lib_directory,
9393 .host = .{
......@@ -130,13 +130,13 @@ pub fn main(init: process.Init.Minimal) !void {
130130 var debounce_interval_ms: u16 = 50;
131131 var webui_listen: ?Io.net.IpAddress = null;
132132
133 if (std.zig.EnvVar.ZIG_BUILD_ERROR_STYLE.get(&graph.env_map)) |str| {
133 if (std.zig.EnvVar.ZIG_BUILD_ERROR_STYLE.get(&graph.environ_map)) |str| {
134134 if (std.meta.stringToEnum(ErrorStyle, str)) |style| {
135135 error_style = style;
136136 }
137137 }
138138
139 if (std.zig.EnvVar.ZIG_BUILD_MULTILINE_ERRORS.get(&graph.env_map)) |str| {
139 if (std.zig.EnvVar.ZIG_BUILD_MULTILINE_ERRORS.get(&graph.environ_map)) |str| {
140140 if (std.meta.stringToEnum(MultilineErrors, str)) |style| {
141141 multiline_errors = style;
142142 }
......@@ -433,8 +433,8 @@ pub fn main(init: process.Init.Minimal) !void {
433433 }
434434 }
435435
436 const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(&graph.env_map);
437 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(&graph.env_map);
436 const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(&graph.environ_map);
437 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(&graph.environ_map);
438438
439439 graph.stderr_mode = switch (color) {
440440 .auto => try .detect(io, .stderr(), NO_COLOR, CLICOLOR_FORCE),
lib/compiler/libc.zig+3-3
......@@ -29,7 +29,7 @@ pub fn main(init: std.process.Init) !void {
2929 const gpa = init.gpa;
3030 const io = init.io;
3131 const args = try init.minimal.args.toSlice(arena);
32 const env_map = init.env_map;
32 const environ_map = init.environ_map;
3333
3434 const zig_lib_directory = args[1];
3535
......@@ -92,7 +92,7 @@ pub fn main(init: std.process.Init) !void {
9292 is_native_abi,
9393 true,
9494 libc_installation,
95 env_map,
95 environ_map,
9696 ) catch |err| {
9797 const zig_target = try target.zigTriple(arena);
9898 fatal("unable to detect libc for target {s}: {t}", .{ zig_target, err });
......@@ -123,7 +123,7 @@ pub fn main(init: std.process.Init) !void {
123123 var libc = LibCInstallation.findNative(gpa, io, .{
124124 .verbose = true,
125125 .target = &target,
126 .env_map = env_map,
126 .environ_map = environ_map,
127127 }) catch |err| {
128128 fatal("unable to detect native libc: {t}", .{err});
129129 };
lib/compiler/resinator/compile.zig+2-2
......@@ -80,7 +80,7 @@ pub const Dependencies = struct {
8080 }
8181};
8282
83pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io.Writer, options: CompileOptions, env_map: *const std.process.Environ.Map) !void {
83pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io.Writer, options: CompileOptions, environ_map: *const std.process.Environ.Map) !void {
8484 var lexer = lex.Lexer.init(source, .{
8585 .default_code_page = options.default_code_page,
8686 .source_mappings = options.source_mappings,
......@@ -148,7 +148,7 @@ pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io
148148 try search_dirs.append(allocator, .{ .dir = dir, .path = try allocator.dupe(u8, system_include_path) });
149149 }
150150 if (!options.ignore_include_env_var) {
151 const INCLUDE = env_map.get("INCLUDE") orelse "";
151 const INCLUDE = environ_map.get("INCLUDE") orelse "";
152152
153153 // The only precedence here is llvm-rc which also uses the platform-specific
154154 // delimiter. There's no precedence set by `rc.exe` since it's Windows-only.
lib/compiler/resinator/main.zig+10-10
......@@ -24,8 +24,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
2424 defer std.debug.assert(debug_allocator.deinit() == .ok);
2525 const gpa = debug_allocator.allocator();
2626
27 var env_map = try init.environ.createMap(gpa);
28 defer env_map.deinit();
27 var environ_map = try init.environ.createMap(gpa);
28 defer environ_map.deinit();
2929
3030 var threaded: std.Io.Threaded = .init(gpa, .{
3131 .environ = init.environ,
......@@ -151,8 +151,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
151151 defer argv.deinit(aro_arena);
152152
153153 try argv.append(aro_arena, "arocc"); // dummy command name
154 const resolved_include_paths = try include_paths.get(&error_handler, &env_map);
155 try preprocess.appendAroArgs(aro_arena, &argv, options, resolved_include_paths, &env_map);
154 const resolved_include_paths = try include_paths.get(&error_handler, &environ_map);
155 try preprocess.appendAroArgs(aro_arena, &argv, options, resolved_include_paths, &environ_map);
156156 try argv.append(aro_arena, switch (options.input_source) {
157157 .stdio => "-",
158158 .filename => |filename| filename,
......@@ -286,7 +286,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
286286 .dependencies = maybe_dependencies,
287287 .ignore_include_env_var = options.ignore_include_env_var,
288288 .extra_include_paths = options.extra_include_paths.items,
289 .system_include_paths = try include_paths.get(&error_handler, &env_map),
289 .system_include_paths = try include_paths.get(&error_handler, &environ_map),
290290 .default_language_id = options.default_language_id,
291291 .default_code_page = default_code_page,
292292 .disjoint_code_page = has_disjoint_code_page,
......@@ -295,7 +295,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
295295 .max_string_literal_codepoints = options.max_string_literal_codepoints,
296296 .silent_duplicate_control_ids = options.silent_duplicate_control_ids,
297297 .warn_instead_of_error_on_invalid_code_page = options.warn_instead_of_error_on_invalid_code_page,
298 }, &env_map) catch |err| switch (err) {
298 }, &environ_map) catch |err| switch (err) {
299299 error.ParseError, error.CompileError => {
300300 try error_handler.emitDiagnostics(gpa, Io.Dir.cwd(), final_input, &diagnostics, mapping_results.mappings);
301301 // Delete the output file on error
......@@ -545,7 +545,7 @@ const LazyIncludePaths = struct {
545545 pub fn get(
546546 self: *LazyIncludePaths,
547547 error_handler: *ErrorHandler,
548 env_map: *const std.process.Environ.Map,
548 environ_map: *const std.process.Environ.Map,
549549 ) ![]const []const u8 {
550550 const io = self.io;
551551
......@@ -558,7 +558,7 @@ const LazyIncludePaths = struct {
558558 self.auto_includes_option,
559559 self.zig_lib_dir,
560560 self.target_machine_type,
561 env_map,
561 environ_map,
562562 ) catch |err| switch (err) {
563563 error.OutOfMemory => |e| return e,
564564 else => |e| {
......@@ -586,7 +586,7 @@ fn getIncludePaths(
586586 auto_includes_option: cli.Options.AutoIncludes,
587587 zig_lib_dir: []const u8,
588588 target_machine_type: std.coff.IMAGE.FILE.MACHINE,
589 env_map: *const std.process.Environ.Map,
589 environ_map: *const std.process.Environ.Map,
590590) ![]const []const u8 {
591591 if (auto_includes_option == .none) return &[_][]const u8{};
592592
......@@ -667,7 +667,7 @@ fn getIncludePaths(
667667 is_native_abi,
668668 true,
669669 null,
670 env_map,
670 environ_map,
671671 ) catch |err| switch (err) {
672672 error.OutOfMemory => |e| return e,
673673 else => return error.MingwIncludesNotFound,
lib/compiler/resinator/preprocess.zig+2-2
......@@ -86,7 +86,7 @@ fn hasAnyErrors(comp: *aro.Compilation) bool {
8686
8787/// `arena` is used for temporary -D argument strings and the INCLUDE environment variable.
8888/// The arena should be kept alive at least as long as `argv`.
89pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options: cli.Options, system_include_paths: []const []const u8, env_map: *const std.process.Environ.Map) !void {
89pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options: cli.Options, system_include_paths: []const []const u8, environ_map: *const std.process.Environ.Map) !void {
9090 try argv.appendSlice(arena, &.{
9191 "-E",
9292 "--comments",
......@@ -109,7 +109,7 @@ pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options
109109 }
110110
111111 if (!options.ignore_include_env_var) {
112 const INCLUDE = env_map.get("INCLUDE") orelse "";
112 const INCLUDE = environ_map.get("INCLUDE") orelse "";
113113
114114 // The only precedence here is llvm-rc which also uses the platform-specific
115115 // delimiter. There's no precedence set by `rc.exe` since it's Windows-only.
lib/compiler/translate-c/main.zig+4-4
......@@ -13,7 +13,7 @@ pub fn main(init: std.process.Init) u8 {
1313 const gpa = init.gpa;
1414 const arena = init.arena.allocator();
1515 const io = init.io;
16 const env_map = init.env_map;
16 const environ_map = init.environ_map;
1717
1818 const args = init.minimal.args.toSlice(arena) catch {
1919 std.debug.print("ran out of memory allocating arguments\n", .{});
......@@ -26,8 +26,8 @@ pub fn main(init: std.process.Init) u8 {
2626 zig_integration = true;
2727 }
2828
29 const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(env_map);
30 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(env_map);
29 const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(environ_map);
30 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(environ_map);
3131
3232 var stderr_buf: [1024]u8 = undefined;
3333 var stderr = Io.File.stderr().writer(io, &stderr_buf);
......@@ -42,7 +42,7 @@ pub fn main(init: std.process.Init) u8 {
4242 };
4343 defer diagnostics.deinit();
4444
45 var comp = aro.Compilation.initDefault(gpa, arena, io, &diagnostics, .cwd(), env_map) catch |err| switch (err) {
45 var comp = aro.Compilation.initDefault(gpa, arena, io, &diagnostics, .cwd(), environ_map) catch |err| switch (err) {
4646 error.OutOfMemory => {
4747 std.debug.print("ran out of memory initializing C compilation\n", .{});
4848 if (fast_exit) process.exit(1);
lib/std/Build.zig+6-7
......@@ -12,7 +12,6 @@ const StringHashMap = std.StringHashMap;
1212const Allocator = std.mem.Allocator;
1313const Target = std.Target;
1414const process = std.process;
15const EnvMap = std.process.Environ.Map;
1615const File = std.Io.File;
1716const Sha256 = std.crypto.hash.sha2.Sha256;
1817const ArrayList = std.ArrayList;
......@@ -118,7 +117,7 @@ pub const Graph = struct {
118117 debug_compiler_runtime_libs: bool = false,
119118 cache: Cache,
120119 zig_exe: [:0]const u8,
121 env_map: EnvMap,
120 environ_map: process.Environ.Map,
122121 global_cache_root: Cache.Directory,
123122 zig_lib_directory: Cache.Directory,
124123 needed_lazy_dependencies: std.StringArrayHashMapUnmanaged(void) = .empty,
......@@ -289,7 +288,7 @@ pub fn create(
289288 .lib_dir = undefined,
290289 .exe_dir = undefined,
291290 .h_dir = undefined,
292 .dest_dir = graph.env_map.get("DESTDIR"),
291 .dest_dir = graph.environ_map.get("DESTDIR"),
293292 .install_tls = .{
294293 .step = .init(.{
295294 .id = TopLevelStep.base_id,
......@@ -1772,7 +1771,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
17721771 }
17731772
17741773 if (builtin.os.tag == .windows) {
1775 if (b.graph.env_map.get("PATHEXT")) |PATHEXT| {
1774 if (b.graph.environ_map.get("PATHEXT")) |PATHEXT| {
17761775 var it = mem.tokenizeScalar(u8, PATHEXT, fs.path.delimiter);
17771776
17781777 while (it.next()) |ext| {
......@@ -1803,7 +1802,7 @@ pub fn findProgram(b: *Build, names: []const []const u8, paths: []const []const
18031802 return tryFindProgram(b, b.pathJoin(&.{ search_prefix, "bin", name })) orelse continue;
18041803 }
18051804 }
1806 if (b.graph.env_map.get("PATH")) |PATH| {
1805 if (b.graph.environ_map.get("PATH")) |PATH| {
18071806 for (names) |name| {
18081807 if (fs.path.isAbsolute(name)) {
18091808 return name;
......@@ -1840,11 +1839,11 @@ pub fn runAllowFail(
18401839 const io = graph.io;
18411840
18421841 const max_output_size = 400 * 1024;
1843 try Step.handleVerbose2(b, null, &graph.env_map, argv);
1842 try Step.handleVerbose2(b, null, &graph.environ_map, argv);
18441843
18451844 var child = try std.process.spawn(io, .{
18461845 .argv = argv,
1847 .env_map = &graph.env_map,
1846 .environ_map = &graph.environ_map,
18481847 .stdin = .ignore,
18491848 .stdout = .pipe,
18501849 .stderr = stderr_behavior,
lib/std/Build/Step.zig+3-3
......@@ -362,7 +362,7 @@ pub fn captureChildProcess(
362362
363363 const result = std.process.run(arena, io, .{
364364 .argv = argv,
365 .env_map = &graph.env_map,
365 .environ_map = &graph.environ_map,
366366 .progress_node = progress_node,
367367 }) catch |err| return s.fail("failed to run {s}: {t}", .{ argv[0], err });
368368
......@@ -453,7 +453,7 @@ pub fn evalZigProcess(
453453
454454 zp.child = std.process.spawn(io, .{
455455 .argv = argv,
456 .env_map = &b.graph.env_map,
456 .environ_map = &b.graph.environ_map,
457457 .stdin = .pipe,
458458 .stdout = .pipe,
459459 .stderr = .pipe,
......@@ -702,7 +702,7 @@ pub fn handleVerbose2(
702702 // stderr before spawning them.
703703 const text = try allocPrintCmd(b.allocator, opt_cwd, if (opt_env) |env| .{
704704 .child = env,
705 .parent = &graph.env_map,
705 .parent = &graph.environ_map,
706706 } else null, argv);
707707 std.debug.print("{s}\n", .{text});
708708 }
lib/std/Build/Step/Compile.zig+2-2
......@@ -741,7 +741,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
741741 };
742742
743743 var code: u8 = undefined;
744 const pkg_config_exe = b.graph.env_map.get("PKG_CONFIG") orelse "pkg-config";
744 const pkg_config_exe = b.graph.environ_map.get("PKG_CONFIG") orelse "pkg-config";
745745 const stdout = if (b.runAllowFail(&[_][]const u8{
746746 pkg_config_exe,
747747 pkg_name,
......@@ -1846,7 +1846,7 @@ pub fn doAtomicSymLinks(
18461846}
18471847
18481848fn execPkgConfigList(b: *std.Build, out_code: *u8) (PkgConfigError || RunError)![]const PkgConfigPkg {
1849 const pkg_config_exe = b.graph.env_map.get("PKG_CONFIG") orelse "pkg-config";
1849 const pkg_config_exe = b.graph.environ_map.get("PKG_CONFIG") orelse "pkg-config";
18501850 const stdout = try b.runAllowFail(&[_][]const u8{ pkg_config_exe, "--list-all" }, out_code, .ignore);
18511851 var list = std.array_list.Managed(PkgConfigPkg).init(b.allocator);
18521852 errdefer list.deinit();
lib/std/Build/Step/Options.zig+1-1
......@@ -550,7 +550,7 @@ test Options {
550550 .cwd = cwd,
551551 },
552552 .zig_exe = "test",
553 .env_map = std.process.Environ.Map.init(arena.allocator()),
553 .environ_map = std.process.Environ.Map.init(arena.allocator()),
554554 .global_cache_root = .{ .path = "test", .handle = Io.Dir.cwd() },
555555 .host = .{
556556 .query = .{},
lib/std/Build/Step/Run.zig+34-34
......@@ -23,7 +23,7 @@ argv: std.ArrayList(Arg),
2323cwd: ?Build.LazyPath,
2424
2525/// Override this field to modify the environment, or use setEnvironmentVariable
26env_map: ?*EnvMap,
26environ_map: ?*EnvMap,
2727
2828/// Controls the `NO_COLOR` and `CLICOLOR_FORCE` environment variables.
2929color: Color = .auto,
......@@ -215,7 +215,7 @@ pub fn create(owner: *std.Build, name: []const u8) *Run {
215215 }),
216216 .argv = .{},
217217 .cwd = null,
218 .env_map = null,
218 .environ_map = null,
219219 .disable_zig_progress = false,
220220 .stdio = .infer_from_args,
221221 .stdin = .none,
......@@ -540,12 +540,12 @@ pub fn clearEnvironment(run: *Run) void {
540540 const b = run.step.owner;
541541 const new_env_map = b.allocator.create(EnvMap) catch @panic("OOM");
542542 new_env_map.* = .init(b.allocator);
543 run.env_map = new_env_map;
543 run.environ_map = new_env_map;
544544}
545545
546546pub fn addPathDir(run: *Run, search_path: []const u8) void {
547547 const b = run.step.owner;
548 const env_map = getEnvMapInternal(run);
548 const environ_map = getEnvMapInternal(run);
549549
550550 const use_wine = b.enable_wine and b.graph.host.result.os.tag != .windows and use_wine: switch (run.argv.items[0]) {
551551 .artifact => |p| p.artifact.rootModuleTarget().os.tag == .windows,
......@@ -562,7 +562,7 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {
562562 .output_file, .output_directory => false,
563563 };
564564 const key = if (use_wine) "WINEPATH" else "PATH";
565 const prev_path = env_map.get(key);
565 const prev_path = environ_map.get(key);
566566
567567 if (prev_path) |pp| {
568568 const new_path = b.fmt("{s}{c}{s}", .{
......@@ -570,9 +570,9 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {
570570 if (use_wine) Dir.path.delimiter_windows else Dir.path.delimiter,
571571 search_path,
572572 });
573 env_map.put(key, new_path) catch @panic("OOM");
573 environ_map.put(key, new_path) catch @panic("OOM");
574574 } else {
575 env_map.put(key, b.dupePath(search_path)) catch @panic("OOM");
575 environ_map.put(key, b.dupePath(search_path)) catch @panic("OOM");
576576 }
577577}
578578
......@@ -583,18 +583,18 @@ pub fn getEnvMap(run: *Run) *EnvMap {
583583fn getEnvMapInternal(run: *Run) *EnvMap {
584584 const graph = run.step.owner.graph;
585585 const arena = graph.arena;
586 return run.env_map orelse {
586 return run.environ_map orelse {
587587 const cloned_map = arena.create(EnvMap) catch @panic("OOM");
588 cloned_map.* = graph.env_map.clone(arena) catch @panic("OOM");
589 run.env_map = cloned_map;
588 cloned_map.* = graph.environ_map.clone(arena) catch @panic("OOM");
589 run.environ_map = cloned_map;
590590 return cloned_map;
591591 };
592592}
593593
594594pub fn setEnvironmentVariable(run: *Run, key: []const u8, value: []const u8) void {
595 const env_map = run.getEnvMap();
595 const environ_map = run.getEnvMap();
596596 // This data structure already dupes keys and values.
597 env_map.put(key, value) catch @panic("OOM");
597 environ_map.put(key, value) catch @panic("OOM");
598598}
599599
600600pub fn removeEnvironmentVariable(run: *Run, key: []const u8) void {
......@@ -762,7 +762,7 @@ fn convertPathArg(run: *Run, path: Build.Cache.Path) []const u8 {
762762 const child_lazy_cwd = run.cwd orelse break :rel path_str;
763763 const child_cwd = child_lazy_cwd.getPath3(b, &run.step).toString(arena) catch @panic("OOM");
764764 // Convert it from relative to *our* cwd, to relative to the *child's* cwd.
765 break :rel Dir.path.relative(arena, graph.cache.cwd, &graph.env_map, child_cwd, path_str) catch @panic("OOM");
765 break :rel Dir.path.relative(arena, graph.cache.cwd, &graph.environ_map, child_cwd, path_str) catch @panic("OOM");
766766 };
767767 // Not every path can be made relative, e.g. if the path and the child cwd are on different
768768 // disk designators on Windows. In that case, `relative` will return an absolute path which we can
......@@ -794,8 +794,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
794794 var man = b.graph.cache.obtain();
795795 defer man.deinit();
796796
797 if (run.env_map) |env_map| {
798 for (env_map.keys(), env_map.values()) |key, value| {
797 if (run.environ_map) |environ_map| {
798 for (environ_map.keys(), environ_map.values()) |key, value| {
799799 man.hash.addBytes(key);
800800 man.hash.addBytes(value);
801801 }
......@@ -1222,7 +1222,7 @@ fn runCommand(
12221222 const cwd: ?[]const u8 = if (run.cwd) |lazy_cwd| lazy_cwd.getPath2(b, step) else null;
12231223
12241224 try step.handleChildProcUnsupported();
1225 try Step.handleVerbose2(step.owner, cwd, run.env_map, argv);
1225 try Step.handleVerbose2(step.owner, cwd, run.environ_map, argv);
12261226
12271227 const allow_skip = switch (run.stdio) {
12281228 .check, .zig_test => run.skip_foreign_checks,
......@@ -1232,13 +1232,13 @@ fn runCommand(
12321232 var interp_argv = std.array_list.Managed([]const u8).init(b.allocator);
12331233 defer interp_argv.deinit();
12341234
1235 var env_map: EnvMap = env: {
1236 const orig = run.env_map orelse &b.graph.env_map;
1235 var environ_map: EnvMap = env: {
1236 const orig = run.environ_map orelse &b.graph.environ_map;
12371237 break :env try orig.clone(gpa);
12381238 };
1239 defer env_map.deinit();
1239 defer environ_map.deinit();
12401240
1241 const opt_generic_result = spawnChildAndCollect(run, argv, &env_map, has_side_effects, options, fuzz_context) catch |err| term: {
1241 const opt_generic_result = spawnChildAndCollect(run, argv, &environ_map, has_side_effects, options, fuzz_context) catch |err| term: {
12421242 // InvalidExe: cpu arch mismatch
12431243 // FileNotFound: can happen with a wrong dynamic linker path
12441244 if (err == error.InvalidExe or err == error.FileNotFound) interpret: {
......@@ -1274,8 +1274,8 @@ fn runCommand(
12741274
12751275 // Wine's excessive stderr logging is only situationally helpful. Disable it by default, but
12761276 // allow the user to override it (e.g. with `WINEDEBUG=err+all`) if desired.
1277 if (env_map.get("WINEDEBUG") == null) {
1278 try env_map.put("WINEDEBUG", "-all");
1277 if (environ_map.get("WINEDEBUG") == null) {
1278 try environ_map.put("WINEDEBUG", "-all");
12791279 }
12801280 } else {
12811281 return failForeign(run, "-fwine", argv[0], exe);
......@@ -1372,9 +1372,9 @@ fn runCommand(
13721372
13731373 gpa.free(step.result_failed_command.?);
13741374 step.result_failed_command = null;
1375 try Step.handleVerbose2(step.owner, cwd, run.env_map, interp_argv.items);
1375 try Step.handleVerbose2(step.owner, cwd, run.environ_map, interp_argv.items);
13761376
1377 break :term spawnChildAndCollect(run, interp_argv.items, &env_map, has_side_effects, options, fuzz_context) catch |e| {
1377 break :term spawnChildAndCollect(run, interp_argv.items, &environ_map, has_side_effects, options, fuzz_context) catch |e| {
13781378 if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped;
13791379 if (e == error.MakeFailed) return error.MakeFailed; // error already reported
13801380 return step.fail("unable to spawn interpreter {s}: {s}", .{
......@@ -1529,7 +1529,7 @@ const EvalGenericResult = struct {
15291529fn spawnChildAndCollect(
15301530 run: *Run,
15311531 argv: []const []const u8,
1532 env_map: *EnvMap,
1532 environ_map: *EnvMap,
15331533 has_side_effects: bool,
15341534 options: Step.MakeOptions,
15351535 fuzz_context: ?FuzzContext,
......@@ -1548,14 +1548,14 @@ fn spawnChildAndCollect(
15481548 // If an error occurs, it's caused by this command:
15491549 assert(run.step.result_failed_command == null);
15501550 run.step.result_failed_command = try Step.allocPrintCmd(options.gpa, child_cwd, .{
1551 .child = env_map,
1552 .parent = &graph.env_map,
1551 .child = environ_map,
1552 .parent = &graph.environ_map,
15531553 }, argv);
15541554
15551555 var spawn_options: process.SpawnOptions = .{
15561556 .argv = argv,
15571557 .cwd = child_cwd,
1558 .env_map = env_map,
1558 .environ_map = environ_map,
15591559 .request_resource_usage_statistics = true,
15601560 .stdin = if (run.stdin != .none) s: {
15611561 assert(run.stdio != .inherit);
......@@ -1595,7 +1595,7 @@ fn spawnChildAndCollect(
15951595 break :m stderr.terminal_mode;
15961596 } else .no_color;
15971597 defer if (inherit) io.unlockStderr();
1598 try setColorEnvironmentVariables(run, env_map, terminal_mode);
1598 try setColorEnvironmentVariables(run, environ_map, terminal_mode);
15991599 var timer = try std.time.Timer.start();
16001600 const res = try evalGeneric(run, spawn_options);
16011601 run.step.result_duration_ns = timer.read();
......@@ -1603,16 +1603,16 @@ fn spawnChildAndCollect(
16031603 }
16041604}
16051605
1606fn setColorEnvironmentVariables(run: *Run, env_map: *EnvMap, terminal_mode: Io.Terminal.Mode) !void {
1606fn setColorEnvironmentVariables(run: *Run, environ_map: *EnvMap, terminal_mode: Io.Terminal.Mode) !void {
16071607 color: switch (run.color) {
16081608 .manual => {},
16091609 .enable => {
1610 try env_map.put("CLICOLOR_FORCE", "1");
1611 _ = env_map.swapRemove("NO_COLOR");
1610 try environ_map.put("CLICOLOR_FORCE", "1");
1611 _ = environ_map.swapRemove("NO_COLOR");
16121612 },
16131613 .disable => {
1614 try env_map.put("NO_COLOR", "1");
1615 _ = env_map.swapRemove("CLICOLOR_FORCE");
1614 try environ_map.put("NO_COLOR", "1");
1615 _ = environ_map.swapRemove("CLICOLOR_FORCE");
16161616 },
16171617 .inherit => switch (terminal_mode) {
16181618 .no_color, .windows_api => continue :color .disable,
lib/std/Build/WebServer.zig+1-1
......@@ -568,7 +568,7 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
568568
569569 var child = try std.process.spawn(io, .{
570570 .argv = argv.items,
571 .env_map = &graph.env_map,
571 .environ_map = &graph.environ_map,
572572 .stdin = .pipe,
573573 .stdout = .pipe,
574574 .stderr = .pipe,
lib/std/Io/Threaded.zig+3-3
......@@ -12887,8 +12887,8 @@ fn spawnPosix(t: *Threaded, options: process.SpawnOptions) process.SpawnError!Sp
1288712887
1288812888 const envp: [*:null]const ?[*:0]const u8 = m: {
1288912889 const prog_fd: i32 = if (prog_pipe[1] == -1) -1 else prog_fileno;
12890 if (options.env_map) |env_map| {
12891 break :m (try env_map.createBlockPosix(arena, .{
12890 if (options.environ_map) |environ_map| {
12891 break :m (try environ_map.createBlockPosix(arena, .{
1289212892 .zig_progress_fd = prog_fd,
1289312893 })).ptr;
1289412894 }
......@@ -13436,7 +13436,7 @@ fn processSpawnWindows(userdata: ?*anyopaque, options: process.SpawnOptions) pro
1343613436 const cwd_w = if (options.cwd) |cwd| try std.unicode.wtf8ToWtf16LeAllocZ(arena, cwd) else null;
1343713437 const cwd_w_ptr = if (cwd_w) |cwd| cwd.ptr else null;
1343813438
13439 const maybe_envp_buf = if (options.env_map) |env_map| try env_map.createBlockWindows(arena) else null;
13439 const maybe_envp_buf = if (options.environ_map) |environ_map| try environ_map.createBlockWindows(arena) else null;
1344013440 const envp_ptr = if (maybe_envp_buf) |envp_buf| envp_buf.ptr else null;
1344113441
1344213442 const app_name_wtf8 = options.argv[0];
lib/std/fs/path.zig+10-10
......@@ -1506,16 +1506,16 @@ fn testBasenameWindows(input: []const u8, expected_output: []const u8) !void {
15061506/// on each), a zero-length string is returned.
15071507///
15081508/// See `relativePosix` and `relativeWindows` for operating system specific
1509/// details and for how `env_map` is used.
1509/// details and for how `environ_map` is used.
15101510pub fn relative(
15111511 gpa: Allocator,
15121512 cwd: []const u8,
1513 env_map: ?*const std.process.Environ.Map,
1513 environ_map: ?*const std.process.Environ.Map,
15141514 from: []const u8,
15151515 to: []const u8,
15161516) Allocator.Error![]u8 {
15171517 if (native_os == .windows) {
1518 return relativeWindows(gpa, cwd, env_map, from, to);
1518 return relativeWindows(gpa, cwd, environ_map, from, to);
15191519 } else {
15201520 return relativePosix(gpa, cwd, from, to);
15211521 }
......@@ -1536,12 +1536,12 @@ pub fn relative(
15361536/// Per-drive CWDs are stored in special semi-hidden environment variables of
15371537/// the format `=<drive-letter>:`, e.g. `=C:`. This type of CWD is purely a
15381538/// shell concept, so there's no guarantee that it'll be set or that it'll even
1539/// be accurate. This is the only reason for the `env_map` parameter. `null` is
1539/// be accurate. This is the only reason for the `environ_map` parameter. `null` is
15401540/// treated equivalent to the environment variable missing.
15411541pub fn relativeWindows(
15421542 gpa: Allocator,
15431543 cwd: []const u8,
1544 env_map: ?*const std.process.Environ.Map,
1544 environ_map: ?*const std.process.Environ.Map,
15451545 from: []const u8,
15461546 to: []const u8,
15471547) Allocator.Error![]u8 {
......@@ -1565,13 +1565,13 @@ pub fn relativeWindows(
15651565 };
15661566
15671567 if (result_is_always_to) {
1568 return windowsResolveAgainstCwd(gpa, cwd, env_map, to, parsed_to);
1568 return windowsResolveAgainstCwd(gpa, cwd, environ_map, to, parsed_to);
15691569 }
15701570
1571 const resolved_from = try windowsResolveAgainstCwd(gpa, cwd, env_map, from, parsed_from);
1571 const resolved_from = try windowsResolveAgainstCwd(gpa, cwd, environ_map, from, parsed_from);
15721572 defer gpa.free(resolved_from);
15731573 var clean_up_resolved_to = true;
1574 const resolved_to = try windowsResolveAgainstCwd(gpa, cwd, env_map, to, parsed_to);
1574 const resolved_to = try windowsResolveAgainstCwd(gpa, cwd, environ_map, to, parsed_to);
15751575 defer if (clean_up_resolved_to) gpa.free(resolved_to);
15761576
15771577 const parsed_resolved_from = parsePathWindows(u8, resolved_from);
......@@ -1637,7 +1637,7 @@ pub fn relativeWindows(
16371637fn windowsResolveAgainstCwd(
16381638 gpa: Allocator,
16391639 cwd: []const u8,
1640 env_map: ?*const std.process.Environ.Map,
1640 environ_map: ?*const std.process.Environ.Map,
16411641 path: []const u8,
16421642 parsed: WindowsPath2(u8),
16431643) ![]u8 {
......@@ -1679,7 +1679,7 @@ fn windowsResolveAgainstCwd(
16791679 if (drive_letters_match)
16801680 break :drive_cwd cwd;
16811681
1682 if (env_map) |m| {
1682 if (environ_map) |m| {
16831683 if (m.get(&.{ '=', parsed.root[0], ':' })) |v| {
16841684 break :drive_cwd try temp_allocator.dupe(u8, v);
16851685 }
lib/std/http/Client.zig+5-5
......@@ -1307,7 +1307,7 @@ pub fn deinit(client: *Client) void {
13071307/// Asserts the client has no active connections.
13081308/// Uses `arena` for a few small allocations that must outlive the client, or
13091309/// at least until those fields are set to different values.
1310pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.process.Environ.Map) !void {
1310pub fn initDefaultProxies(client: *Client, arena: Allocator, environ_map: *std.process.Environ.Map) !void {
13111311 // Prevent any new connections from being created.
13121312 client.connection_pool.mutex.lock();
13131313 defer client.connection_pool.mutex.unlock();
......@@ -1315,13 +1315,13 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce
13151315 assert(client.connection_pool.used.first == null); // There are active requests.
13161316
13171317 if (client.http_proxy == null) {
1318 client.http_proxy = try createProxyFromEnvVar(arena, env_map, &.{
1318 client.http_proxy = try createProxyFromEnvVar(arena, environ_map, &.{
13191319 "http_proxy", "HTTP_PROXY", "all_proxy", "ALL_PROXY",
13201320 });
13211321 }
13221322
13231323 if (client.https_proxy == null) {
1324 client.https_proxy = try createProxyFromEnvVar(arena, env_map, &.{
1324 client.https_proxy = try createProxyFromEnvVar(arena, environ_map, &.{
13251325 "https_proxy", "HTTPS_PROXY", "all_proxy", "ALL_PROXY",
13261326 });
13271327 }
......@@ -1329,11 +1329,11 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce
13291329
13301330fn createProxyFromEnvVar(
13311331 arena: Allocator,
1332 env_map: *std.process.Environ.Map,
1332 environ_map: *std.process.Environ.Map,
13331333 env_var_names: []const []const u8,
13341334) !?*Proxy {
13351335 const content = for (env_var_names) |name| {
1336 const content = env_map.get(name) orelse continue;
1336 const content = environ_map.get(name) orelse continue;
13371337 if (content.len == 0) continue;
13381338 break content;
13391339 } else return null;
lib/std/process.zig+5-5
......@@ -46,7 +46,7 @@ pub const Init = struct {
4646 /// configuration. Debug mode will set up leak checking.
4747 io: Io,
4848 /// Environment variables, initialized with `gpa`. Not threadsafe.
49 env_map: *Environ.Map,
49 environ_map: *Environ.Map,
5050
5151 /// Alternative to `Init` as the first parameter of the main function.
5252 pub const Minimal = struct {
......@@ -295,7 +295,7 @@ pub const ReplaceOptions = struct {
295295 arg0_expand: ArgExpansion = .no_expand,
296296 /// Replaces the environment when provided. The PATH value from here is
297297 /// never used to resolve `argv[0]`.
298 env_map: ?*const Environ.Map = null,
298 environ_map: ?*const Environ.Map = null,
299299};
300300
301301/// Replaces the current process image with the executed process. If this
......@@ -377,7 +377,7 @@ pub const SpawnOptions = struct {
377377 /// Replaces the child environment when provided. The PATH value from here
378378 /// is not used to resolve `argv[0]`; that resolution always uses parent
379379 /// environment.
380 env_map: ?*const Environ.Map = null,
380 environ_map: ?*const Environ.Map = null,
381381 expand_arg0: ArgExpansion = .no_expand,
382382 /// When populated, a pipe will be created for the child process to
383383 /// communicate progress back to the parent. The file descriptor of the
......@@ -475,7 +475,7 @@ pub const RunOptions = struct {
475475 /// Replaces the child environment when provided. The PATH value from here
476476 /// is not used to resolve `argv[0]`; that resolution always uses parent
477477 /// environment.
478 env_map: ?*const Environ.Map = null,
478 environ_map: ?*const Environ.Map = null,
479479 expand_arg0: ArgExpansion = .no_expand,
480480 /// When populated, a pipe will be created for the child process to
481481 /// communicate progress back to the parent. The file descriptor of the
......@@ -505,7 +505,7 @@ pub fn run(gpa: Allocator, io: Io, options: RunOptions) RunError!RunResult {
505505 .argv = options.argv,
506506 .cwd = options.cwd,
507507 .cwd_dir = options.cwd_dir,
508 .env_map = options.env_map,
508 .environ_map = options.environ_map,
509509 .expand_arg0 = options.expand_arg0,
510510 .progress_node = options.progress_node,
511511 .create_no_window = options.create_no_window,
lib/std/start.zig+3-3
......@@ -699,9 +699,9 @@ inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.B
699699 });
700700 defer threaded.deinit();
701701
702 var env_map = std.process.Environ.createMap(.{ .block = environ }, gpa) catch |err|
702 var environ_map = std.process.Environ.createMap(.{ .block = environ }, gpa) catch |err|
703703 std.process.fatal("failed to parse environment variables: {t}", .{err});
704 defer env_map.deinit();
704 defer environ_map.deinit();
705705
706706 return wrapMain(root.main(.{
707707 .minimal = .{
......@@ -711,7 +711,7 @@ inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.B
711711 .arena = &arena_allocator,
712712 .gpa = gpa,
713713 .io = threaded.io(),
714 .env_map = &env_map,
714 .environ_map = &environ_map,
715715 }));
716716}
717717
lib/std/zig/LibCDirs.zig+3-3
......@@ -28,7 +28,7 @@ pub fn detect(
2828 is_native_abi: bool,
2929 link_libc: bool,
3030 libc_installation: ?*const LibCInstallation,
31 env_map: *const std.process.Environ.Map,
31 environ_map: *const std.process.Environ.Map,
3232) LibCInstallation.FindError!LibCDirs {
3333 if (!link_libc) {
3434 return .{
......@@ -50,7 +50,7 @@ pub fn detect(
5050 const libc = try arena.create(LibCInstallation);
5151 libc.* = LibCInstallation.findNative(arena, io, .{
5252 .target = target,
53 .env_map = env_map,
53 .environ_map = environ_map,
5454 }) catch |err| switch (err) {
5555 error.CCompilerExitCode,
5656 error.CCompilerCrashed,
......@@ -91,7 +91,7 @@ pub fn detect(
9191 libc.* = try LibCInstallation.findNative(arena, io, .{
9292 .verbose = true,
9393 .target = target,
94 .env_map = env_map,
94 .environ_map = environ_map,
9595 });
9696 return detectFromInstallation(arena, target, libc);
9797 }
lib/std/zig/LibCInstallation.zig+20-20
......@@ -168,7 +168,7 @@ pub fn render(self: LibCInstallation, out: *std.Io.Writer) !void {
168168
169169pub const FindNativeOptions = struct {
170170 target: *const std.Target,
171 env_map: *const Environ.Map,
171 environ_map: *const Environ.Map,
172172
173173 /// If enabled, will print human-friendly errors to stderr.
174174 verbose: bool = false,
......@@ -193,7 +193,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
193193 });
194194 return self;
195195 } else if (is_windows) {
196 const sdk = std.zig.WindowsSdk.find(gpa, io, args.target.cpu.arch, args.env_map) catch |err| switch (err) {
196 const sdk = std.zig.WindowsSdk.find(gpa, io, args.target.cpu.arch, args.environ_map) catch |err| switch (err) {
197197 error.NotFound => return error.WindowsSdkNotFound,
198198 error.PathTooLong => return error.WindowsSdkNotFound,
199199 error.OutOfMemory => return error.OutOfMemory,
......@@ -240,17 +240,17 @@ pub fn deinit(self: *LibCInstallation, allocator: Allocator) void {
240240
241241fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {
242242 // Detect infinite loops.
243 var env_map = try args.env_map.clone(gpa);
244 defer env_map.deinit();
245 const skip_cc_env_var = if (env_map.get(inf_loop_env_key)) |phase| blk: {
243 var environ_map = try args.environ_map.clone(gpa);
244 defer environ_map.deinit();
245 const skip_cc_env_var = if (environ_map.get(inf_loop_env_key)) |phase| blk: {
246246 if (std.mem.eql(u8, phase, "1")) {
247 try env_map.put(inf_loop_env_key, "2");
247 try environ_map.put(inf_loop_env_key, "2");
248248 break :blk true;
249249 } else {
250250 return error.ZigIsTheCCompiler;
251251 }
252252 } else blk: {
253 try env_map.put(inf_loop_env_key, "1");
253 try environ_map.put(inf_loop_env_key, "1");
254254 break :blk false;
255255 };
256256
......@@ -259,7 +259,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar
259259 var argv = std.array_list.Managed([]const u8).init(gpa);
260260 defer argv.deinit();
261261
262 try appendCcExe(&argv, skip_cc_env_var, &env_map);
262 try appendCcExe(&argv, skip_cc_env_var, &environ_map);
263263 try argv.appendSlice(&.{
264264 "-E",
265265 "-Wp,-v",
......@@ -270,7 +270,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar
270270 const run_res = std.process.run(gpa, io, .{
271271 .max_output_bytes = 1024 * 1024,
272272 .argv = argv.items,
273 .env_map = &env_map,
273 .environ_map = &environ_map,
274274 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path
275275 // to their own executable, without even bothering to resolve PATH. This results in the message:
276276 // error: unable to execute command: Executable "" doesn't exist!
......@@ -446,7 +446,7 @@ fn findNativeCrtDirWindows(
446446
447447fn findNativeCrtDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {
448448 self.crt_dir = try ccPrintFileName(gpa, io, .{
449 .env_map = args.env_map,
449 .environ_map = args.environ_map,
450450 .search_basename = switch (args.target.os.tag) {
451451 .linux => if (args.target.abi.isAndroid()) "crtbegin_dynamic.o" else "crt1.o",
452452 else => "crt1.o",
......@@ -551,7 +551,7 @@ fn findNativeMsvcLibDir(
551551}
552552
553553pub const CCPrintFileNameOptions = struct {
554 env_map: *const Environ.Map,
554 environ_map: *const Environ.Map,
555555 search_basename: []const u8,
556556 want_dirname: enum { full_path, only_dir },
557557 verbose: bool = false,
......@@ -560,17 +560,17 @@ pub const CCPrintFileNameOptions = struct {
560560/// caller owns returned memory
561561fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {
562562 // Detect infinite loops.
563 var env_map = try args.env_map.clone(gpa);
564 defer env_map.deinit();
565 const skip_cc_env_var = if (env_map.get(inf_loop_env_key)) |phase| blk: {
563 var environ_map = try args.environ_map.clone(gpa);
564 defer environ_map.deinit();
565 const skip_cc_env_var = if (environ_map.get(inf_loop_env_key)) |phase| blk: {
566566 if (std.mem.eql(u8, phase, "1")) {
567 try env_map.put(inf_loop_env_key, "2");
567 try environ_map.put(inf_loop_env_key, "2");
568568 break :blk true;
569569 } else {
570570 return error.ZigIsTheCCompiler;
571571 }
572572 } else blk: {
573 try env_map.put(inf_loop_env_key, "1");
573 try environ_map.put(inf_loop_env_key, "1");
574574 break :blk false;
575575 };
576576
......@@ -580,13 +580,13 @@ fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {
580580 const arg1 = try std.fmt.allocPrint(gpa, "-print-file-name={s}", .{args.search_basename});
581581 defer gpa.free(arg1);
582582
583 try appendCcExe(&argv, skip_cc_env_var, &env_map);
583 try appendCcExe(&argv, skip_cc_env_var, &environ_map);
584584 try argv.append(arg1);
585585
586586 const run_res = std.process.run(gpa, io, .{
587587 .max_output_bytes = 1024 * 1024,
588588 .argv = argv.items,
589 .env_map = &env_map,
589 .environ_map = &environ_map,
590590 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path
591591 // to their own executable, without even bothering to resolve PATH. This results in the message:
592592 // error: unable to execute command: Executable "" doesn't exist!
......@@ -669,7 +669,7 @@ const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS";
669669fn appendCcExe(
670670 args: *std.array_list.Managed([]const u8),
671671 skip_cc_env_var: bool,
672 env_map: *const Environ.Map,
672 environ_map: *const Environ.Map,
673673) !void {
674674 const default_cc_exe = if (is_windows) "cc.exe" else "cc";
675675 try args.ensureUnusedCapacity(1);
......@@ -677,7 +677,7 @@ fn appendCcExe(
677677 args.appendAssumeCapacity(default_cc_exe);
678678 return;
679679 }
680 const cc_env_var = std.zig.EnvVar.CC.get(env_map) orelse {
680 const cc_env_var = std.zig.EnvVar.CC.get(environ_map) orelse {
681681 args.appendAssumeCapacity(default_cc_exe);
682682 return;
683683 };
lib/std/zig/WindowsSdk.zig+14-14
......@@ -29,7 +29,7 @@ pub fn find(
2929 gpa: Allocator,
3030 io: Io,
3131 arch: std.Target.Cpu.Arch,
32 env_map: *const Environ.Map,
32 environ_map: *const Environ.Map,
3333) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk {
3434 if (builtin.os.tag != .windows) return error.NotFound;
3535
......@@ -55,7 +55,7 @@ pub fn find(
5555 };
5656 errdefer if (windows81sdk) |*w| w.free(gpa);
5757
58 const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, arch, env_map) catch |err| switch (err) {
58 const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, arch, environ_map) catch |err| switch (err) {
5959 error.MsvcLibDirNotFound => null,
6060 error.OutOfMemory => return error.OutOfMemory,
6161 };
......@@ -680,7 +680,7 @@ const MsvcLibDir = struct {
680680 fn findInstancesDir(
681681 gpa: Allocator,
682682 io: Io,
683 env_map: *const Environ.Map,
683 environ_map: *const Environ.Map,
684684 ) error{ OutOfMemory, PathNotFound }!Dir {
685685 // First, try getting the packages cache path from the registry.
686686 // This only seems to exist when the path is different from the default.
......@@ -701,7 +701,7 @@ const MsvcLibDir = struct {
701701 // If that can't be found, fall back to manually appending
702702 // `Microsoft\VisualStudio\Packages\_Instances` to %PROGRAMDATA%
703703 method3: {
704 const program_data = std.zig.EnvVar.PROGRAMDATA.get(env_map) orelse break :method3;
704 const program_data = std.zig.EnvVar.PROGRAMDATA.get(environ_map) orelse break :method3;
705705
706706 if (!Dir.path.isAbsolute(program_data)) break :method3;
707707
......@@ -765,13 +765,13 @@ const MsvcLibDir = struct {
765765 gpa: Allocator,
766766 io: Io,
767767 arch: std.Target.Cpu.Arch,
768 env_map: *const Environ.Map,
768 environ_map: *const Environ.Map,
769769 ) error{ OutOfMemory, PathNotFound }![]const u8 {
770770 // Typically `%PROGRAMDATA%\Microsoft\VisualStudio\Packages\_Instances`
771771 // This will contain directories with names of instance IDs like 80a758ca,
772772 // which will contain `state.json` files that have the version and
773773 // installation directory.
774 var instances_dir = try findInstancesDir(gpa, io, env_map);
774 var instances_dir = try findInstancesDir(gpa, io, environ_map);
775775 defer instances_dir.close(io);
776776
777777 var state_subpath_buf: [Dir.max_name_bytes + 32]u8 = undefined;
......@@ -872,12 +872,12 @@ const MsvcLibDir = struct {
872872 gpa: Allocator,
873873 io: Io,
874874 arch: std.Target.Cpu.Arch,
875 env_map: *const Environ.Map,
875 environ_map: *const Environ.Map,
876876 ) error{ OutOfMemory, PathNotFound }![]const u8 {
877877
878878 // %localappdata%\Microsoft\VisualStudio\
879879 // %appdata%\Local\Microsoft\VisualStudio\
880 const local_app_data_path = std.zig.EnvVar.LOCALAPPDATA.get(env_map) orelse return error.PathNotFound;
880 const local_app_data_path = std.zig.EnvVar.LOCALAPPDATA.get(environ_map) orelse return error.PathNotFound;
881881 const visualstudio_folder_path = try Dir.path.join(gpa, &.{
882882 local_app_data_path, "Microsoft\\VisualStudio\\",
883883 });
......@@ -968,11 +968,11 @@ const MsvcLibDir = struct {
968968 gpa: Allocator,
969969 io: Io,
970970 arch: std.Target.Cpu.Arch,
971 env_map: *const Environ.Map,
971 environ_map: *const Environ.Map,
972972 ) error{ OutOfMemory, PathNotFound }![]const u8 {
973973 var base_path: std.array_list.Managed(u8) = base_path: {
974974 try_env: {
975 if (env_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| {
975 if (environ_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| {
976976 if (VS140COMNTOOLS.len < "C:\\Common7\\Tools".len) break :try_env;
977977 if (!Dir.path.isAbsolute(VS140COMNTOOLS)) break :try_env;
978978 var list = std.array_list.Managed(u8).init(gpa);
......@@ -1046,13 +1046,13 @@ const MsvcLibDir = struct {
10461046 gpa: Allocator,
10471047 io: Io,
10481048 arch: std.Target.Cpu.Arch,
1049 env_map: *const Environ.Map,
1049 environ_map: *const Environ.Map,
10501050 ) error{ OutOfMemory, MsvcLibDirNotFound }![]const u8 {
1051 const full_path = MsvcLibDir.findViaCOM(gpa, io, arch, env_map) catch |err1| switch (err1) {
1051 const full_path = MsvcLibDir.findViaCOM(gpa, io, arch, environ_map) catch |err1| switch (err1) {
10521052 error.OutOfMemory => return error.OutOfMemory,
1053 error.PathNotFound => MsvcLibDir.findViaRegistry(gpa, io, arch, env_map) catch |err2| switch (err2) {
1053 error.PathNotFound => MsvcLibDir.findViaRegistry(gpa, io, arch, environ_map) catch |err2| switch (err2) {
10541054 error.OutOfMemory => return error.OutOfMemory,
1055 error.PathNotFound => MsvcLibDir.findViaVs7Key(gpa, io, arch, env_map) catch |err3| switch (err3) {
1055 error.PathNotFound => MsvcLibDir.findViaVs7Key(gpa, io, arch, environ_map) catch |err3| switch (err3) {
10561056 error.OutOfMemory => return error.OutOfMemory,
10571057 error.PathNotFound => return error.MsvcLibDirNotFound,
10581058 },
lib/std/zig/system/NativePaths.zig+8-8
......@@ -18,12 +18,12 @@ pub fn detect(
1818 arena: Allocator,
1919 io: Io,
2020 native_target: *const std.Target,
21 env_map: *process.Environ.Map,
21 environ_map: *process.Environ.Map,
2222) !NativePaths {
2323 var self: NativePaths = .{ .arena = arena };
2424 var is_nix = false;
2525
26 if (std.zig.EnvVar.NIX_CFLAGS_COMPILE.get(env_map)) |nix_cflags_compile| {
26 if (std.zig.EnvVar.NIX_CFLAGS_COMPILE.get(environ_map)) |nix_cflags_compile| {
2727 is_nix = true;
2828 var it = mem.tokenizeScalar(u8, nix_cflags_compile, ' ');
2929 while (true) {
......@@ -49,7 +49,7 @@ pub fn detect(
4949 }
5050 }
5151
52 if (std.zig.EnvVar.NIX_LDFLAGS.get(env_map)) |nix_ldflags| {
52 if (std.zig.EnvVar.NIX_LDFLAGS.get(environ_map)) |nix_ldflags| {
5353 is_nix = true;
5454 var it = mem.tokenizeScalar(u8, nix_ldflags, ' ');
5555 while (true) {
......@@ -78,7 +78,7 @@ pub fn detect(
7878 }
7979 }
8080
81 if (std.zig.EnvVar.NIX_CFLAGS_LINK.get(env_map)) |nix_cflags_link| {
81 if (std.zig.EnvVar.NIX_CFLAGS_LINK.get(environ_map)) |nix_cflags_link| {
8282 is_nix = true;
8383 var it = mem.tokenizeScalar(u8, nix_cflags_link, ' ');
8484 while (true) {
......@@ -121,7 +121,7 @@ pub fn detect(
121121 }
122122
123123 // Check for homebrew paths
124 if (std.zig.EnvVar.HOMEBREW_PREFIX.get(env_map)) |prefix| {
124 if (std.zig.EnvVar.HOMEBREW_PREFIX.get(environ_map)) |prefix| {
125125 try self.addLibDir(try std.fs.path.join(arena, &.{ prefix, "/lib" }));
126126 try self.addIncludeDir(try std.fs.path.join(arena, &.{ prefix, "/include" }));
127127 }
......@@ -177,21 +177,21 @@ pub fn detect(
177177
178178 // Distros like guix don't use FHS, so they rely on environment
179179 // variables to search for headers and libraries.
180 if (std.zig.EnvVar.C_INCLUDE_PATH.get(env_map)) |c_include_path| {
180 if (std.zig.EnvVar.C_INCLUDE_PATH.get(environ_map)) |c_include_path| {
181181 var it = mem.tokenizeScalar(u8, c_include_path, ':');
182182 while (it.next()) |dir| {
183183 try self.addIncludeDir(dir);
184184 }
185185 }
186186
187 if (std.zig.EnvVar.CPLUS_INCLUDE_PATH.get(env_map)) |cplus_include_path| {
187 if (std.zig.EnvVar.CPLUS_INCLUDE_PATH.get(environ_map)) |cplus_include_path| {
188188 var it = mem.tokenizeScalar(u8, cplus_include_path, ':');
189189 while (it.next()) |dir| {
190190 try self.addIncludeDir(dir);
191191 }
192192 }
193193
194 if (std.zig.EnvVar.LIBRARY_PATH.get(env_map)) |library_path| {
194 if (std.zig.EnvVar.LIBRARY_PATH.get(environ_map)) |library_path| {
195195 var it = mem.tokenizeScalar(u8, library_path, ':');
196196 while (it.next()) |dir| {
197197 try self.addLibDir(dir);
src/Compilation.zig+4-4
......@@ -762,7 +762,7 @@ pub const Directories = struct {
762762 .wasi => void,
763763 else => []const u8,
764764 },
765 env_map: *const std.process.Environ.Map,
765 environ_map: *const std.process.Environ.Map,
766766 ) Directories {
767767 const wasi = builtin.target.os.tag == .wasi;
768768
......@@ -781,7 +781,7 @@ pub const Directories = struct {
781781 const global_cache: Cache.Directory = d: {
782782 if (override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache");
783783 if (wasi) break :d openWasiPreopen(wasi_preopens, "/cache");
784 const path = introspect.resolveGlobalCacheDir(arena, env_map) catch |err| {
784 const path = introspect.resolveGlobalCacheDir(arena, environ_map) catch |err| {
785785 fatal("unable to resolve zig cache directory: {t}", .{err});
786786 };
787787 break :d openUnresolved(arena, io, cwd, path, .@"global cache");
......@@ -5713,7 +5713,7 @@ pub fn translateC(
57135713 translated_basename: []const u8,
57145714 owner_mod: *Package.Module,
57155715 prog_node: std.Progress.Node,
5716 env_map: *const std.process.Environ.Map,
5716 environ_map: *const std.process.Environ.Map,
57175717) !CImportResult {
57185718 dev.check(.translate_c_command);
57195719
......@@ -5783,7 +5783,7 @@ pub fn translateC(
57835783 }
57845784
57855785 var stdout: []u8 = undefined;
5786 try @import("main.zig").translateC(gpa, arena, io, argv.items, env_map, prog_node, &stdout);
5786 try @import("main.zig").translateC(gpa, arena, io, argv.items, environ_map, prog_node, &stdout);
57875787
57885788 if (out_dep_path) |dep_file_path| add_deps: {
57895789 if (comp.verbose_cimport) log.info("processing dep file at {s}", .{dep_file_path});
src/introspect.zig+5-5
......@@ -102,25 +102,25 @@ pub fn findZigLibDirFromSelfExe(
102102 return error.FileNotFound;
103103}
104104
105pub fn resolveGlobalCacheDir(arena: Allocator, env_map: *const std.process.Environ.Map) ![]const u8 {
106 if (std.zig.EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map)) |value| return value;
105pub fn resolveGlobalCacheDir(arena: Allocator, environ_map: *const std.process.Environ.Map) ![]const u8 {
106 if (std.zig.EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map)) |value| return value;
107107
108108 const app_name = "zig";
109109
110110 switch (builtin.os.tag) {
111111 .wasi => @compileError("on WASI the global cache dir must be resolved with preopens"),
112112 .windows => {
113 const local_app_data_dir = std.zig.EnvVar.LOCALAPPDATA.get(env_map) orelse
113 const local_app_data_dir = std.zig.EnvVar.LOCALAPPDATA.get(environ_map) orelse
114114 return error.AppDataDirUnavailable;
115115 return Dir.path.join(arena, &.{ local_app_data_dir, app_name });
116116 },
117117 else => {
118 if (std.zig.EnvVar.XDG_CACHE_HOME.get(env_map)) |cache_root| {
118 if (std.zig.EnvVar.XDG_CACHE_HOME.get(environ_map)) |cache_root| {
119119 if (cache_root.len > 0) {
120120 return Dir.path.join(arena, &.{ cache_root, app_name });
121121 }
122122 }
123 if (std.zig.EnvVar.HOME.get(env_map)) |home| {
123 if (std.zig.EnvVar.HOME.get(environ_map)) |home| {
124124 if (home.len > 0) {
125125 return Dir.path.join(arena, &.{ home, ".cache", app_name });
126126 }
src/main.zig+80-80
......@@ -191,7 +191,7 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
191191 fatal("expected command argument", .{});
192192 }
193193
194 var env_map = init.environ.createMap(arena) catch |err| fatal("failed to parse environment: {t}", .{err});
194 var environ_map = init.environ.createMap(arena) catch |err| fatal("failed to parse environment: {t}", .{err});
195195
196196 Compilation.setMainThread();
197197
......@@ -206,14 +206,14 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
206206
207207 if (tracy.enable_allocation) {
208208 var gpa_tracy = tracy.tracyAllocator(gpa);
209 return mainArgs(gpa_tracy.allocator(), arena, io, args, &env_map);
209 return mainArgs(gpa_tracy.allocator(), arena, io, args, &environ_map);
210210 }
211211
212212 if (native_os == .wasi) {
213213 wasi_preopens = try fs.wasi.preopensAlloc(arena);
214214 }
215215
216 return mainArgs(gpa, arena, io, args, &env_map);
216 return mainArgs(gpa, arena, io, args, &environ_map);
217217}
218218
219219fn mainArgs(
......@@ -221,9 +221,9 @@ fn mainArgs(
221221 arena: Allocator,
222222 io: Io,
223223 args: []const [:0]const u8,
224 env_map: *process.Environ.Map,
224 environ_map: *process.Environ.Map,
225225) !void {
226 if (process.can_replace and EnvVar.ZIG_IS_DETECTING_LIBC_PATHS.isSet(env_map)) {
226 if (process.can_replace and EnvVar.ZIG_IS_DETECTING_LIBC_PATHS.isSet(environ_map)) {
227227 dev.check(.cc_command);
228228 // In this case we have accidentally invoked ourselves as "the system C compiler"
229229 // to figure out where libc is installed. This is essentially infinite recursion
......@@ -233,7 +233,7 @@ fn mainArgs(
233233 // why we have this additional environment variable here to check.
234234
235235 const inf_loop_env_key: EnvVar = .ZIG_IS_TRYING_TO_NOT_CALL_ITSELF;
236 if (inf_loop_env_key.isSet(env_map)) {
236 if (inf_loop_env_key.isSet(environ_map)) {
237237 fatal("{s}", .{
238238 "The compilation links against libc, but Zig is unable to provide a libc " ++
239239 "for this operating system, and no --libc " ++
......@@ -242,17 +242,17 @@ fn mainArgs(
242242 "compiler is `zig cc`, so no libc installation was found.",
243243 });
244244 }
245 try env_map.put(@tagName(inf_loop_env_key), "1");
245 try environ_map.put(@tagName(inf_loop_env_key), "1");
246246
247247 // Some programs such as CMake will strip the `cc` and subsequent args from the
248248 // CC environment variable. We detect and support this scenario here because of
249249 // the ZIG_IS_DETECTING_LIBC_PATHS environment variable.
250250 if (mem.eql(u8, args[1], "cc")) {
251 return process.replace(io, .{ .argv = args[1..], .env_map = env_map });
251 return process.replace(io, .{ .argv = args[1..], .environ_map = environ_map });
252252 } else {
253253 const modified_args = try arena.dupe([]const u8, args);
254254 modified_args[0] = "cc";
255 return process.replace(io, .{ .argv = modified_args, .env_map = env_map });
255 return process.replace(io, .{ .argv = modified_args, .environ_map = environ_map });
256256 }
257257 }
258258
......@@ -260,22 +260,22 @@ fn mainArgs(
260260 const cmd_args = args[2..];
261261 if (mem.eql(u8, cmd, "build-exe")) {
262262 dev.check(.build_exe_command);
263 return buildOutputType(gpa, arena, io, args, .{ .build = .Exe }, env_map);
263 return buildOutputType(gpa, arena, io, args, .{ .build = .Exe }, environ_map);
264264 } else if (mem.eql(u8, cmd, "build-lib")) {
265265 dev.check(.build_lib_command);
266 return buildOutputType(gpa, arena, io, args, .{ .build = .Lib }, env_map);
266 return buildOutputType(gpa, arena, io, args, .{ .build = .Lib }, environ_map);
267267 } else if (mem.eql(u8, cmd, "build-obj")) {
268268 dev.check(.build_obj_command);
269 return buildOutputType(gpa, arena, io, args, .{ .build = .Obj }, env_map);
269 return buildOutputType(gpa, arena, io, args, .{ .build = .Obj }, environ_map);
270270 } else if (mem.eql(u8, cmd, "test")) {
271271 dev.check(.test_command);
272 return buildOutputType(gpa, arena, io, args, .zig_test, env_map);
272 return buildOutputType(gpa, arena, io, args, .zig_test, environ_map);
273273 } else if (mem.eql(u8, cmd, "test-obj")) {
274274 dev.check(.test_command);
275 return buildOutputType(gpa, arena, io, args, .zig_test_obj, env_map);
275 return buildOutputType(gpa, arena, io, args, .zig_test_obj, environ_map);
276276 } else if (mem.eql(u8, cmd, "run")) {
277277 dev.check(.run_command);
278 return buildOutputType(gpa, arena, io, args, .run, env_map);
278 return buildOutputType(gpa, arena, io, args, .run, environ_map);
279279 } else if (mem.eql(u8, cmd, "dlltool") or
280280 mem.eql(u8, cmd, "ranlib") or
281281 mem.eql(u8, cmd, "lib") or
......@@ -285,7 +285,7 @@ fn mainArgs(
285285 return process.exit(try llvmArMain(arena, args));
286286 } else if (mem.eql(u8, cmd, "build")) {
287287 dev.check(.build_command);
288 return cmdBuild(gpa, arena, io, cmd_args, env_map);
288 return cmdBuild(gpa, arena, io, cmd_args, environ_map);
289289 } else if (mem.eql(u8, cmd, "clang") or
290290 mem.eql(u8, cmd, "-cc1") or mem.eql(u8, cmd, "-cc1as"))
291291 {
......@@ -299,16 +299,16 @@ fn mainArgs(
299299 return process.exit(try lldMain(arena, args, true));
300300 } else if (mem.eql(u8, cmd, "cc")) {
301301 dev.check(.cc_command);
302 return buildOutputType(gpa, arena, io, args, .cc, env_map);
302 return buildOutputType(gpa, arena, io, args, .cc, environ_map);
303303 } else if (mem.eql(u8, cmd, "c++")) {
304304 dev.check(.cc_command);
305 return buildOutputType(gpa, arena, io, args, .cpp, env_map);
305 return buildOutputType(gpa, arena, io, args, .cpp, environ_map);
306306 } else if (mem.eql(u8, cmd, "translate-c")) {
307307 dev.check(.translate_c_command);
308 return buildOutputType(gpa, arena, io, args, .translate_c, env_map);
308 return buildOutputType(gpa, arena, io, args, .translate_c, environ_map);
309309 } else if (mem.eql(u8, cmd, "rc")) {
310310 const use_server = cmd_args.len > 0 and std.mem.eql(u8, cmd_args[0], "--zig-integration");
311 return jitCmd(gpa, arena, io, cmd_args, env_map, .{
311 return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
312312 .cmd_name = "resinator",
313313 .root_src_path = "resinator/main.zig",
314314 .depend_on_aro = true,
......@@ -319,20 +319,20 @@ fn mainArgs(
319319 dev.check(.fmt_command);
320320 return @import("fmt.zig").run(gpa, arena, io, cmd_args);
321321 } else if (mem.eql(u8, cmd, "objcopy")) {
322 return jitCmd(gpa, arena, io, cmd_args, env_map, .{
322 return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
323323 .cmd_name = "objcopy",
324324 .root_src_path = "objcopy.zig",
325325 });
326326 } else if (mem.eql(u8, cmd, "fetch")) {
327 return cmdFetch(gpa, arena, io, cmd_args, env_map);
327 return cmdFetch(gpa, arena, io, cmd_args, environ_map);
328328 } else if (mem.eql(u8, cmd, "libc")) {
329 return jitCmd(gpa, arena, io, cmd_args, env_map, .{
329 return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
330330 .cmd_name = "libc",
331331 .root_src_path = "libc.zig",
332332 .prepend_zig_lib_dir_path = true,
333333 });
334334 } else if (mem.eql(u8, cmd, "std")) {
335 return jitCmd(gpa, arena, io, cmd_args, env_map, .{
335 return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
336336 .cmd_name = "std",
337337 .root_src_path = "std-docs.zig",
338338 .prepend_zig_lib_dir_path = true,
......@@ -362,11 +362,11 @@ fn mainArgs(
362362 args,
363363 if (native_os == .wasi) wasi_preopens,
364364 &host,
365 env_map,
365 environ_map,
366366 );
367367 return stdout_writer.interface.flush();
368368 } else if (mem.eql(u8, cmd, "reduce")) {
369 return jitCmd(gpa, arena, io, cmd_args, env_map, .{
369 return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
370370 .cmd_name = "reduce",
371371 .root_src_path = "reduce.zig",
372372 });
......@@ -811,7 +811,7 @@ fn buildOutputType(
811811 io: Io,
812812 all_args: []const []const u8,
813813 arg_mode: ArgMode,
814 env_map: *process.Environ.Map,
814 environ_map: *process.Environ.Map,
815815) !void {
816816 var provided_name: ?[]const u8 = null;
817817 var root_src_file: ?[]const u8 = null;
......@@ -824,9 +824,9 @@ fn buildOutputType(
824824 var debug_compile_errors = false;
825825 var debug_incremental = false;
826826 var verbose_link = (native_os != .wasi or builtin.link_libc) and
827 EnvVar.ZIG_VERBOSE_LINK.isSet(env_map);
827 EnvVar.ZIG_VERBOSE_LINK.isSet(environ_map);
828828 var verbose_cc = (native_os != .wasi or builtin.link_libc) and
829 EnvVar.ZIG_VERBOSE_CC.isSet(env_map);
829 EnvVar.ZIG_VERBOSE_CC.isSet(environ_map);
830830 var verbose_air = false;
831831 var verbose_intern_pool = false;
832832 var verbose_generic_instances = false;
......@@ -898,9 +898,9 @@ fn buildOutputType(
898898 var runtime_args_start: ?usize = null;
899899 var test_filters: std.ArrayList([]const u8) = .empty;
900900 var test_runner_path: ?[]const u8 = null;
901 var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(env_map);
902 var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
903 var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map);
901 var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(environ_map);
902 var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
903 var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map);
904904 var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no;
905905 var subsystem: ?std.zig.Subsystem = null;
906906 var major_subsystem_version: ?u16 = null;
......@@ -997,7 +997,7 @@ fn buildOutputType(
997997 .framework_dirs = .{},
998998 .rpath_list = .{},
999999 .each_lib_rpath = null,
1000 .libc_paths_file = EnvVar.ZIG_LIBC.get(env_map),
1000 .libc_paths_file = EnvVar.ZIG_LIBC.get(environ_map),
10011001 .native_system_include_paths = &.{},
10021002 };
10031003 defer create_module.link_inputs.deinit(gpa);
......@@ -1006,9 +1006,9 @@ fn buildOutputType(
10061006 // if set, default the color setting to .off or .on, respectively
10071007 // explicit --color arguments will still override this setting.
10081008 // Disable color on WASI per https://github.com/WebAssembly/WASI/issues/162
1009 var color: Color = if (native_os == .wasi or EnvVar.NO_COLOR.isSet(env_map))
1009 var color: Color = if (native_os == .wasi or EnvVar.NO_COLOR.isSet(environ_map))
10101010 .off
1011 else if (EnvVar.CLICOLOR_FORCE.isSet(env_map))
1011 else if (EnvVar.CLICOLOR_FORCE.isSet(environ_map))
10121012 .on
10131013 else
10141014 .auto;
......@@ -3106,7 +3106,7 @@ fn buildOutputType(
31063106 },
31073107 if (native_os == .wasi) wasi_preopens,
31083108 self_exe_path,
3109 env_map,
3109 environ_map,
31103110 );
31113111 defer dirs.deinit(io);
31123112
......@@ -3118,7 +3118,7 @@ fn buildOutputType(
31183118 create_module.opts.emit_bin = emit_bin != .no;
31193119 create_module.opts.any_c_source_files = create_module.c_source_files.items.len != 0;
31203120
3121 const main_mod = try createModule(gpa, arena, io, &create_module, 0, null, color, env_map);
3121 const main_mod = try createModule(gpa, arena, io, &create_module, 0, null, color, environ_map);
31223122 for (create_module.modules.keys(), create_module.modules.values()) |key, cli_mod| {
31233123 if (cli_mod.resolved == null)
31243124 fatal("module '{s}' declared but not used", .{key});
......@@ -3595,7 +3595,7 @@ fn buildOutputType(
35953595 .global_cc_argv = try cc_argv.toOwnedSlice(arena),
35963596 .file_system_inputs = &file_system_inputs,
35973597 .debug_compiler_runtime_libs = debug_compiler_runtime_libs,
3598 .environ_map = env_map,
3598 .environ_map = environ_map,
35993599 }) catch |err| switch (err) {
36003600 error.CreateFail => switch (create_diag) {
36013601 .cross_libc_unavailable => {
......@@ -3659,7 +3659,7 @@ fn buildOutputType(
36593659 arg_mode,
36603660 all_args,
36613661 runtime_args_start,
3662 env_map,
3662 environ_map,
36633663 );
36643664 return cleanExit(io);
36653665 },
......@@ -3686,7 +3686,7 @@ fn buildOutputType(
36863686 arg_mode,
36873687 all_args,
36883688 runtime_args_start,
3689 env_map,
3689 environ_map,
36903690 );
36913691 return cleanExit(io);
36923692 },
......@@ -3699,7 +3699,7 @@ fn buildOutputType(
36993699 defer root_prog_node.end();
37003700
37013701 if (arg_mode == .translate_c) {
3702 return cmdTranslateC(comp, arena, null, null, root_prog_node, env_map);
3702 return cmdTranslateC(comp, arena, null, null, root_prog_node, environ_map);
37033703 }
37043704
37053705 updateModule(comp, color, root_prog_node) catch |err| switch (err) {
......@@ -3767,7 +3767,7 @@ fn buildOutputType(
37673767 all_args,
37683768 runtime_args_start,
37693769 create_module.resolved_options.link_libc,
3770 env_map,
3770 environ_map,
37713771 );
37723772 }
37733773
......@@ -3823,7 +3823,7 @@ fn createModule(
38233823 index: usize,
38243824 parent: ?*Package.Module,
38253825 color: std.zig.Color,
3826 env_map: *process.Environ.Map,
3826 environ_map: *process.Environ.Map,
38273827) Allocator.Error!*Package.Module {
38283828 const cli_mod = &create_module.modules.values()[index];
38293829 if (cli_mod.resolved) |m| return m;
......@@ -4003,7 +4003,7 @@ fn createModule(
40034003 resolved_target.is_native_os and resolved_target.is_native_abi and
40044004 create_module.want_native_include_dirs)
40054005 {
4006 var paths = std.zig.system.NativePaths.detect(arena, io, target, env_map) catch |err|
4006 var paths = std.zig.system.NativePaths.detect(arena, io, target, environ_map) catch |err|
40074007 fatal("unable to detect native system paths: {t}", .{err});
40084008 for (paths.warnings.items) |warning| {
40094009 warn("{s}", .{warning});
......@@ -4030,7 +4030,7 @@ fn createModule(
40304030 create_module.libc_installation = LibCInstallation.findNative(arena, io, .{
40314031 .verbose = true,
40324032 .target = target,
4033 .env_map = env_map,
4033 .environ_map = environ_map,
40344034 }) catch |err| {
40354035 fatal("unable to find native libc installation: {t}", .{err});
40364036 };
......@@ -4135,7 +4135,7 @@ fn createModule(
41354135 for (cli_mod.deps) |dep| {
41364136 const dep_index = create_module.modules.getIndex(dep.value) orelse
41374137 fatal("module '{s}' depends on non-existent module '{s}'", .{ name, dep.key });
4138 const dep_mod = try createModule(gpa, arena, io, create_module, dep_index, mod, color, env_map);
4138 const dep_mod = try createModule(gpa, arena, io, create_module, dep_index, mod, color, environ_map);
41394139 try mod.deps.put(arena, dep.key, dep_mod);
41404140 }
41414141
......@@ -4157,7 +4157,7 @@ fn serve(
41574157 arg_mode: ArgMode,
41584158 all_args: []const []const u8,
41594159 runtime_args_start: ?usize,
4160 env_map: *process.Environ.Map,
4160 environ_map: *process.Environ.Map,
41614161) !void {
41624162 const gpa = comp.gpa;
41634163 const io = comp.io;
......@@ -4205,7 +4205,7 @@ fn serve(
42054205 defer arena_instance.deinit();
42064206 const arena = arena_instance.allocator();
42074207 var output: Compilation.CImportResult = undefined;
4208 try cmdTranslateC(comp, arena, &output, file_system_inputs, main_progress_node, env_map);
4208 try cmdTranslateC(comp, arena, &output, file_system_inputs, main_progress_node, environ_map);
42094209 defer output.deinit(gpa);
42104210
42114211 if (file_system_inputs.items.len != 0) {
......@@ -4405,7 +4405,7 @@ fn runOrTest(
44054405 all_args: []const []const u8,
44064406 runtime_args_start: ?usize,
44074407 link_libc: bool,
4408 env_map: *process.Environ.Map,
4408 environ_map: *process.Environ.Map,
44094409) !void {
44104410 const raw_emit_bin = comp.emit_bin orelse return;
44114411 const exe_path = switch (comp.cache_use) {
......@@ -4442,14 +4442,14 @@ fn runOrTest(
44424442 if (runtime_args_start) |i| {
44434443 try argv.appendSlice(all_args[i..]);
44444444 }
4445 try env_map.put("ZIG_EXE", self_exe_path);
4445 try environ_map.put("ZIG_EXE", self_exe_path);
44464446
44474447 // We do not execve for tests because if the test fails we want to print
44484448 // the error message and invocation below.
44494449 if (process.can_replace and arg_mode == .run) {
44504450 // process replacement releases the locks; no need to destroy the Compilation here.
44514451 _ = try io.lockStderr(&.{}, .no_color);
4452 const err = process.replace(io, .{ .argv = argv.items, .env_map = env_map });
4452 const err = process.replace(io, .{ .argv = argv.items, .environ_map = environ_map });
44534453 io.unlockStderr();
44544454 try warnAboutForeignBinaries(io, arena, arg_mode, target, link_libc);
44554455 const cmd = try std.mem.join(arena, " ", argv.items);
......@@ -4471,7 +4471,7 @@ fn runOrTest(
44714471
44724472 var child = std.process.spawn(io, .{
44734473 .argv = argv.items,
4474 .env_map = env_map,
4474 .environ_map = environ_map,
44754475 .stdin = .inherit,
44764476 .stdout = .inherit,
44774477 .stderr = .inherit,
......@@ -4626,7 +4626,7 @@ fn cmdTranslateC(
46264626 fancy_output: ?*Compilation.CImportResult,
46274627 file_system_inputs: ?*std.ArrayList(u8),
46284628 prog_node: std.Progress.Node,
4629 env_map: *process.Environ.Map,
4629 environ_map: *process.Environ.Map,
46304630) !void {
46314631 dev.check(.translate_c_command);
46324632
......@@ -4660,7 +4660,7 @@ fn cmdTranslateC(
46604660 translated_basename,
46614661 comp.root_mod,
46624662 prog_node,
4663 env_map,
4663 environ_map,
46644664 );
46654665
46664666 if (result.errors.errorMessageCount() != 0) {
......@@ -4708,11 +4708,11 @@ pub fn translateC(
47084708 arena: Allocator,
47094709 io: Io,
47104710 argv: []const []const u8,
4711 env_map: *const process.Environ.Map,
4711 environ_map: *const process.Environ.Map,
47124712 prog_node: std.Progress.Node,
47134713 capture: ?*[]u8,
47144714) !void {
4715 try jitCmd(gpa, arena, io, argv, env_map, .{
4715 try jitCmd(gpa, arena, io, argv, environ_map, .{
47164716 .cmd_name = "translate-c",
47174717 .root_src_path = "translate-c/main.zig",
47184718 .depend_on_aro = true,
......@@ -4869,21 +4869,21 @@ test sanitizeExampleName {
48694869 try std.testing.expectEqualStrings("test_project", try sanitizeExampleName(arena, "test project"));
48704870}
48714871
4872fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, env_map: *process.Environ.Map) !void {
4872fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, environ_map: *process.Environ.Map) !void {
48734873 dev.check(.build_command);
48744874
48754875 var build_file: ?[]const u8 = null;
4876 var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map);
4877 var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
4878 var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(env_map);
4879 var override_build_runner: ?[]const u8 = EnvVar.ZIG_BUILD_RUNNER.get(env_map);
4876 var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map);
4877 var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
4878 var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(environ_map);
4879 var override_build_runner: ?[]const u8 = EnvVar.ZIG_BUILD_RUNNER.get(environ_map);
48804880 var child_argv = std.array_list.Managed([]const u8).init(arena);
48814881 var reference_trace: ?u32 = null;
48824882 var debug_compile_errors = false;
48834883 var verbose_link = (native_os != .wasi or builtin.link_libc) and
4884 EnvVar.ZIG_VERBOSE_LINK.isSet(env_map);
4884 EnvVar.ZIG_VERBOSE_LINK.isSet(environ_map);
48854885 var verbose_cc = (native_os != .wasi or builtin.link_libc) and
4886 EnvVar.ZIG_VERBOSE_CC.isSet(env_map);
4886 EnvVar.ZIG_VERBOSE_CC.isSet(environ_map);
48874887 var verbose_air = false;
48884888 var verbose_intern_pool = false;
48894889 var verbose_generic_instances = false;
......@@ -5080,7 +5080,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
50805080 }
50815081
50825082 const work_around_btrfs_bug = native_os == .linux and
5083 EnvVar.ZIG_BTRFS_WORKAROUND.isSet(env_map);
5083 EnvVar.ZIG_BTRFS_WORKAROUND.isSet(environ_map);
50845084 const root_prog_node = std.Progress.start(io, .{
50855085 .disable_printing = (color == .off),
50865086 .root_name = "Compile Build Script",
......@@ -5140,7 +5140,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
51405140 } },
51415141 {},
51425142 self_exe_path,
5143 env_map,
5143 environ_map,
51445144 );
51455145 defer dirs.deinit(io);
51465146
......@@ -5243,7 +5243,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
52435243 job_queue.read_only = true;
52445244 cleanup_build_dir = job_queue.global_cache.handle;
52455245 } else {
5246 try http_client.initDefaultProxies(arena, env_map);
5246 try http_client.initDefaultProxies(arena, environ_map);
52475247 }
52485248
52495249 try job_queue.all_fetches.ensureUnusedCapacity(gpa, 1);
......@@ -5397,7 +5397,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
53975397 .cache_mode = .whole,
53985398 .reference_trace = reference_trace,
53995399 .debug_compile_errors = debug_compile_errors,
5400 .environ_map = env_map,
5400 .environ_map = environ_map,
54015401 }) catch |err| switch (err) {
54025402 error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}),
54035403 else => fatal("failed to create compilation: {s}", .{@errorName(err)}),
......@@ -5516,7 +5516,7 @@ fn jitCmd(
55165516 arena: Allocator,
55175517 io: Io,
55185518 args: []const []const u8,
5519 env_map: *const process.Environ.Map,
5519 environ_map: *const process.Environ.Map,
55205520 options: JitCmdOptions,
55215521) !void {
55225522 dev.check(.jit_command);
......@@ -5538,13 +5538,13 @@ fn jitCmd(
55385538 const self_exe_path = process.executablePathAlloc(io, arena) catch |err|
55395539 fatal("unable to find self exe path: {t}", .{err});
55405540
5541 const optimize_mode: std.builtin.OptimizeMode = if (EnvVar.ZIG_DEBUG_CMD.isSet(env_map))
5541 const optimize_mode: std.builtin.OptimizeMode = if (EnvVar.ZIG_DEBUG_CMD.isSet(environ_map))
55425542 .Debug
55435543 else
55445544 .ReleaseFast;
55455545 const strip = optimize_mode != .Debug;
5546 const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map);
5547 const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
5546 const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map);
5547 const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
55485548
55495549 // This `init` calls `fatal` on error.
55505550 var dirs: Compilation.Directories = .init(
......@@ -5555,7 +5555,7 @@ fn jitCmd(
55555555 .global,
55565556 if (native_os == .wasi) wasi_preopens,
55575557 self_exe_path,
5558 env_map,
5558 environ_map,
55595559 );
55605560 defer dirs.deinit(io);
55615561
......@@ -5629,7 +5629,7 @@ fn jitCmd(
56295629 .self_exe_path = self_exe_path,
56305630 .thread_limit = thread_limit,
56315631 .cache_mode = .whole,
5632 .environ_map = env_map,
5632 .environ_map = environ_map,
56335633 }) catch |err| switch (err) {
56345634 error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}),
56355635 else => fatal("failed to create compilation: {s}", .{@errorName(err)}),
......@@ -5676,11 +5676,11 @@ fn jitCmd(
56765676 child_argv.appendSliceAssumeCapacity(args);
56775677
56785678 if (process.can_replace and options.capture == null) {
5679 if (EnvVar.ZIG_DEBUG_CMD.isSet(env_map)) {
5679 if (EnvVar.ZIG_DEBUG_CMD.isSet(environ_map)) {
56805680 const cmd = try std.mem.join(arena, " ", child_argv.items);
56815681 std.debug.print("{s}\n", .{cmd});
56825682 }
5683 const err = process.replace(io, .{ .argv = child_argv.items, .env_map = env_map });
5683 const err = process.replace(io, .{ .argv = child_argv.items, .environ_map = environ_map });
56845684 const cmd = try std.mem.join(arena, " ", child_argv.items);
56855685 fatal("the following command failed to execve with '{t}':\n{s}", .{ err, cmd });
56865686 }
......@@ -6914,15 +6914,15 @@ fn cmdFetch(
69146914 arena: Allocator,
69156915 io: Io,
69166916 args: []const []const u8,
6917 env_map: *process.Environ.Map,
6917 environ_map: *process.Environ.Map,
69186918) !void {
69196919 dev.check(.fetch_command);
69206920
69216921 const color: Color = .auto;
69226922 const work_around_btrfs_bug = native_os == .linux and
6923 EnvVar.ZIG_BTRFS_WORKAROUND.isSet(env_map);
6923 EnvVar.ZIG_BTRFS_WORKAROUND.isSet(environ_map);
69246924 var opt_path_or_url: ?[]const u8 = null;
6925 var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
6925 var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
69266926 var debug_hash: bool = false;
69276927 var save: union(enum) {
69286928 no,
......@@ -6968,7 +6968,7 @@ fn cmdFetch(
69686968 var http_client: std.http.Client = .{ .allocator = gpa, .io = io };
69696969 defer http_client.deinit();
69706970
6971 try http_client.initDefaultProxies(arena, env_map);
6971 try http_client.initDefaultProxies(arena, environ_map);
69726972
69736973 var root_prog_node = std.Progress.start(io, .{
69746974 .root_name = "Fetch",
......@@ -6976,7 +6976,7 @@ fn cmdFetch(
69766976 defer root_prog_node.end();
69776977
69786978 var global_cache_directory: Directory = l: {
6979 const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena, env_map);
6979 const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena, environ_map);
69806980 break :l .{
69816981 .handle = try Io.Dir.cwd().createDirPathOpen(io, p, .{}),
69826982 .path = p,
src/print_env.zig+5-5
......@@ -19,10 +19,10 @@ pub fn cmdEnv(
1919 else => void,
2020 },
2121 host: *const std.Target,
22 env_map: *std.process.Environ.Map,
22 environ_map: *std.process.Environ.Map,
2323) !void {
24 const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map);
25 const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
24 const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map);
25 const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
2626
2727 const self_exe_path = switch (builtin.target.os.tag) {
2828 .wasi => args[0],
......@@ -39,7 +39,7 @@ pub fn cmdEnv(
3939 .global,
4040 if (builtin.target.os.tag == .wasi) wasi_preopens,
4141 if (builtin.target.os.tag != .wasi) self_exe_path,
42 env_map,
42 environ_map,
4343 );
4444 defer dirs.deinit(io);
4545
......@@ -59,7 +59,7 @@ pub fn cmdEnv(
5959 try root.field("target", triple, .{});
6060 var env = try root.beginStructField("env", .{});
6161 inline for (@typeInfo(EnvVar).@"enum".fields) |field| {
62 try env.field(field.name, @field(EnvVar, field.name).get(env_map), .{});
62 try env.field(field.name, @field(EnvVar, field.name).get(environ_map), .{});
6363 }
6464 try env.end();
6565 try root.end();
test/standalone/child_process/main.zig+3-3
......@@ -12,8 +12,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
1212 const process_cwd_path = try std.process.getCwdAlloc(gpa);
1313 defer gpa.free(process_cwd_path);
1414
15 var env_map = try init.environ.createMap(gpa);
16 defer env_map.deinit();
15 var environ_map = try init.environ.createMap(gpa);
16 defer environ_map.deinit();
1717
1818 var it = try init.args.iterateAllocator(gpa);
1919 defer it.deinit();
......@@ -23,7 +23,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
2323 const cwd_path = it.next() orelse break :child_path .{ child_path, false };
2424 // If there is a third argument, it is the current CWD somewhere within the cache directory.
2525 // In that case, modify the child path in order to test spawning a path with a leading `..` component.
26 break :child_path .{ try std.fs.path.relative(gpa, process_cwd_path, &env_map, cwd_path, child_path), true };
26 break :child_path .{ try std.fs.path.relative(gpa, process_cwd_path, &environ_map, cwd_path, child_path), true };
2727 };
2828 defer if (needs_free) gpa.free(child_path);
2929
test/standalone/empty_env/main.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("std");
22
33pub fn main(init: std.process.Init) !void {
4 try std.testing.expectEqual(0, init.env_map.count());
4 try std.testing.expectEqual(0, init.environ_map.count());
55}
test/standalone/env_vars/main.zig+14-14
......@@ -126,26 +126,26 @@ pub fn main(init: std.process.Init) !void {
126126
127127 // Environ.Map
128128 {
129 var env_map = try environ.createMap(allocator);
130 defer env_map.deinit();
129 var environ_map = try environ.createMap(allocator);
130 defer environ_map.deinit();
131131
132 try std.testing.expectEqualSlices(u8, "123", env_map.get("FOO").?);
133 try std.testing.expectEqual(null, env_map.get("FO"));
134 try std.testing.expectEqual(null, env_map.get("FOOO"));
132 try std.testing.expectEqualSlices(u8, "123", environ_map.get("FOO").?);
133 try std.testing.expectEqual(null, environ_map.get("FO"));
134 try std.testing.expectEqual(null, environ_map.get("FOOO"));
135135 if (builtin.os.tag == .windows) {
136 try std.testing.expectEqualSlices(u8, "123", env_map.get("foo").?);
136 try std.testing.expectEqualSlices(u8, "123", environ_map.get("foo").?);
137137 }
138 try std.testing.expectEqualSlices(u8, "ABC=123", env_map.get("EQUALS").?);
139 try std.testing.expectEqual(null, env_map.get("EQUALS=ABC"));
140 try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", env_map.get("КИРиллИЦА").?);
138 try std.testing.expectEqualSlices(u8, "ABC=123", environ_map.get("EQUALS").?);
139 try std.testing.expectEqual(null, environ_map.get("EQUALS=ABC"));
140 try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", environ_map.get("КИРиллИЦА").?);
141141 if (builtin.os.tag == .windows) {
142 try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", env_map.get("кирИЛЛица").?);
142 try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", environ_map.get("кирИЛЛица").?);
143143 }
144 try std.testing.expectEqualSlices(u8, "", env_map.get("NO_VALUE").?);
145 try std.testing.expectEqual(null, env_map.get("NOT_SET"));
144 try std.testing.expectEqualSlices(u8, "", environ_map.get("NO_VALUE").?);
145 try std.testing.expectEqual(null, environ_map.get("NOT_SET"));
146146 if (builtin.os.tag == .windows) {
147 try std.testing.expectEqualSlices(u8, "hi", env_map.get("=HIDDEN").?);
148 try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", env_map.get("INVALID_UTF16_\xed\xa0\x80").?);
147 try std.testing.expectEqualSlices(u8, "hi", environ_map.get("=HIDDEN").?);
148 try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", environ_map.get("INVALID_UTF16_\xed\xa0\x80").?);
149149 }
150150 }
151151}
test/standalone/self_exe_symlink/create-symlink.zig+1-1
......@@ -12,7 +12,7 @@ pub fn main(init: std.process.Init) !void {
1212 const cwd = try std.process.getCwdAlloc(init.arena.allocator());
1313
1414 // If `exe_path` is relative to our cwd, we need to convert it to be relative to the dirname of `symlink_path`.
15 const exe_rel_path = try std.fs.path.relative(gpa, cwd, init.env_map, std.fs.path.dirname(symlink_path) orelse ".", exe_path);
15 const exe_rel_path = try std.fs.path.relative(gpa, cwd, init.environ_map, std.fs.path.dirname(symlink_path) orelse ".", exe_path);
1616 defer gpa.free(exe_rel_path);
1717
1818 try std.Io.Dir.cwd().symLink(io, exe_rel_path, symlink_path, .{});
test/standalone/windows_bat_args/fuzz.zig+1-1
......@@ -94,7 +94,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8
9494 const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");
9595
9696 const result = try std.process.run(gpa, io, .{
97 .env_map = env,
97 .environ_map = env,
9898 .argv = argv,
9999 });
100100 defer gpa.free(result.stdout);
test/standalone/windows_bat_args/test.zig+1-1
......@@ -141,7 +141,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8
141141 const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");
142142
143143 const result = try std.process.run(gpa, io, .{
144 .env_map = env,
144 .environ_map = env,
145145 .argv = argv,
146146 });
147147 defer gpa.free(result.stdout);
test/standalone/windows_paths/test.zig+2-2
......@@ -96,12 +96,12 @@ fn checkRelative(
9696 expected_stdout: []const u8,
9797 argv: []const []const u8,
9898 cwd: ?[]const u8,
99 env_map: ?*const std.process.Environ.Map,
99 environ_map: ?*const std.process.Environ.Map,
100100) !void {
101101 const result = try std.process.run(allocator, io, .{
102102 .argv = argv,
103103 .cwd = cwd,
104 .env_map = env_map,
104 .environ_map = environ_map,
105105 });
106106 defer allocator.free(result.stdout);
107107 defer allocator.free(result.stderr);
tools/doctest.zig+19-19
......@@ -32,10 +32,10 @@ const usage =
3232pub fn main(init: std.process.Init) !void {
3333 const arena = init.arena.allocator();
3434 const io = init.io;
35 const env_map = init.env_map;
35 const environ_map = init.environ_map;
3636 const cwd_path = try std.process.getCwdAlloc(arena);
3737
38 try env_map.put("CLICOLOR_FORCE", "1");
38 try environ_map.put("CLICOLOR_FORCE", "1");
3939
4040 var args_it = try init.minimal.args.iterateAllocator(arena);
4141 if (!args_it.skip()) fatal("missing argv[0]", .{});
......@@ -101,13 +101,13 @@ pub fn main(init: std.process.Init) !void {
101101 out,
102102 code,
103103 tmp_dir_path,
104 try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_path),
105 try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, input_path),
104 try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_path),
105 try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, input_path),
106106 if (opt_zig_lib_dir) |zig_lib_dir|
107 try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_lib_dir)
107 try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_lib_dir)
108108 else
109109 null,
110 env_map,
110 environ_map,
111111 );
112112
113113 try out_file_writer.end();
......@@ -126,7 +126,7 @@ fn printOutput(
126126 input_path: []const u8,
127127 /// Relative to `tmp_dir_path`.
128128 opt_zig_lib_dir: ?[]const u8,
129 env_map: *const process.Environ.Map,
129 environ_map: *const process.Environ.Map,
130130) !void {
131131 const host = try std.zig.system.resolveTargetQuery(io, .{});
132132 const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch);
......@@ -199,7 +199,7 @@ fn printOutput(
199199 const result = try process.run(arena, io, .{
200200 .argv = build_args.items,
201201 .cwd = tmp_dir_path,
202 .env_map = env_map,
202 .environ_map = environ_map,
203203 .max_output_bytes = max_doc_file_size,
204204 });
205205 switch (result.term) {
......@@ -221,7 +221,7 @@ fn printOutput(
221221 try shell_out.writeAll(colored_stderr);
222222 break :code_block;
223223 }
224 const exec_result = run(arena, io, env_map, tmp_dir_path, build_args.items) catch
224 const exec_result = run(arena, io, environ_map, tmp_dir_path, build_args.items) catch
225225 fatal("example failed to compile", .{});
226226
227227 if (code.verbose_cimport) {
......@@ -254,7 +254,7 @@ fn printOutput(
254254 const result = if (expected_outcome == .fail) blk: {
255255 const result = try process.run(arena, io, .{
256256 .argv = run_args,
257 .env_map = env_map,
257 .environ_map = environ_map,
258258 .cwd = tmp_dir_path,
259259 .max_output_bytes = max_doc_file_size,
260260 });
......@@ -271,7 +271,7 @@ fn printOutput(
271271 }
272272 break :blk result;
273273 } else blk: {
274 break :blk run(arena, io, env_map, tmp_dir_path, run_args) catch
274 break :blk run(arena, io, environ_map, tmp_dir_path, run_args) catch
275275 fatal("example crashed", .{});
276276 };
277277
......@@ -340,7 +340,7 @@ fn printOutput(
340340 }
341341 }
342342
343 const result = run(arena, io, env_map, tmp_dir_path, test_args.items) catch
343 const result = run(arena, io, environ_map, tmp_dir_path, test_args.items) catch
344344 fatal("test failed", .{});
345345 const escaped_stderr = try escapeHtml(arena, result.stderr);
346346 const escaped_stdout = try escapeHtml(arena, result.stdout);
......@@ -373,7 +373,7 @@ fn printOutput(
373373 }
374374 const result = try process.run(arena, io, .{
375375 .argv = test_args.items,
376 .env_map = env_map,
376 .environ_map = environ_map,
377377 .cwd = tmp_dir_path,
378378 .max_output_bytes = max_doc_file_size,
379379 });
......@@ -429,7 +429,7 @@ fn printOutput(
429429
430430 const result = try process.run(arena, io, .{
431431 .argv = test_args.items,
432 .env_map = env_map,
432 .environ_map = environ_map,
433433 .cwd = tmp_dir_path,
434434 .max_output_bytes = max_doc_file_size,
435435 });
......@@ -505,7 +505,7 @@ fn printOutput(
505505 if (maybe_error_match) |error_match| {
506506 const result = try process.run(arena, io, .{
507507 .argv = build_args.items,
508 .env_map = env_map,
508 .environ_map = environ_map,
509509 .cwd = tmp_dir_path,
510510 .max_output_bytes = max_doc_file_size,
511511 });
......@@ -531,7 +531,7 @@ fn printOutput(
531531 const colored_stderr = try termColor(arena, escaped_stderr);
532532 try shell_out.print("\n{s} ", .{colored_stderr});
533533 } else {
534 _ = run(arena, io, env_map, tmp_dir_path, build_args.items) catch fatal("example failed to compile", .{});
534 _ = run(arena, io, environ_map, tmp_dir_path, build_args.items) catch fatal("example failed to compile", .{});
535535 }
536536 try shell_out.writeAll("\n");
537537 },
......@@ -590,7 +590,7 @@ fn printOutput(
590590 try test_args.append(option);
591591 try shell_out.print("{s} ", .{option});
592592 }
593 const result = run(arena, io, env_map, tmp_dir_path, test_args.items) catch fatal("test failed", .{});
593 const result = run(arena, io, environ_map, tmp_dir_path, test_args.items) catch fatal("test failed", .{});
594594 const escaped_stderr = try escapeHtml(arena, result.stderr);
595595 const escaped_stdout = try escapeHtml(arena, result.stdout);
596596 try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout });
......@@ -1123,13 +1123,13 @@ fn in(slice: []const u8, number: u8) bool {
11231123fn run(
11241124 allocator: Allocator,
11251125 io: Io,
1126 env_map: *const process.Environ.Map,
1126 environ_map: *const process.Environ.Map,
11271127 cwd: []const u8,
11281128 args: []const []const u8,
11291129) !process.RunResult {
11301130 const result = try process.run(allocator, io, .{
11311131 .argv = args,
1132 .env_map = env_map,
1132 .environ_map = environ_map,
11331133 .cwd = cwd,
11341134 .max_output_bytes = max_doc_file_size,
11351135 });
tools/incr-check.zig+4-4
......@@ -31,7 +31,7 @@ pub fn main(init: std.process.Init) !void {
3131 const fatal = std.process.fatal;
3232 const arena = init.arena.allocator();
3333 const io = init.io;
34 const env_map = init.env_map;
34 const environ_map = init.environ_map;
3535 const cwd_path = try std.process.getCwdAlloc(arena);
3636
3737 var opt_zig_exe: ?[]const u8 = null;
......@@ -113,9 +113,9 @@ pub fn main(init: std.process.Init) !void {
113113 }
114114
115115 // Convert paths to be relative to the cwd of the subprocess.
116 const resolved_zig_exe = try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_exe);
116 const resolved_zig_exe = try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_exe);
117117 const opt_resolved_lib_dir = if (opt_lib_dir) |lib_dir|
118 try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, lib_dir)
118 try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, lib_dir)
119119 else
120120 null;
121121
......@@ -176,7 +176,7 @@ pub fn main(init: std.process.Init) !void {
176176 var cc_child_args: std.ArrayList([]const u8) = .empty;
177177 if (target.backend == .cbe) {
178178 const resolved_cc_zig_exe = if (opt_cc_zig) |cc_zig_exe|
179 try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, cc_zig_exe)
179 try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, cc_zig_exe)
180180 else
181181 resolved_zig_exe;
182182
tools/process_headers.zig+2-2
......@@ -132,7 +132,7 @@ pub fn main(init: std.process.Init) !void {
132132 const io = init.io;
133133 const args = try init.minimal.args.toSlice(arena);
134134 const cwd_path = try std.process.getCwdAlloc(arena);
135 const env_map = init.env_map;
135 const environ_map = init.environ_map;
136136
137137 var search_paths = std.array_list.Managed([]const u8).init(arena);
138138 var opt_out_dir: ?[]const u8 = null;
......@@ -256,7 +256,7 @@ pub fn main(init: std.process.Init) !void {
256256 switch (entry.kind) {
257257 .directory => try dir_stack.append(full_path),
258258 .file, .sym_link => {
259 const rel_path = try Dir.path.relative(arena, cwd_path, env_map, target_include_dir, full_path);
259 const rel_path = try Dir.path.relative(arena, cwd_path, environ_map, target_include_dir, full_path);
260260 const max_size = 2 * 1024 * 1024 * 1024;
261261 const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size));
262262 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
tools/update-linux-headers.zig+2-2
......@@ -145,7 +145,7 @@ pub fn main(init: std.process.Init) !void {
145145 const arena = init.arena.allocator();
146146 const io = init.io;
147147 const args = try init.minimal.args.toSlice(arena);
148 const env_map = init.env_map;
148 const environ_map = init.environ_map;
149149 const cwd = try std.process.getCwdAlloc(arena);
150150
151151 var search_paths = std.array_list.Managed([]const u8).init(arena);
......@@ -209,7 +209,7 @@ pub fn main(init: std.process.Init) !void {
209209 switch (entry.kind) {
210210 .directory => try dir_stack.append(full_path),
211211 .file => {
212 const rel_path = try Dir.path.relative(arena, cwd, env_map, target_include_dir, full_path);
212 const rel_path = try Dir.path.relative(arena, cwd, environ_map, target_include_dir, full_path);
213213 const max_size = 2 * 1024 * 1024 * 1024;
214214 const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size));
215215 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");