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(...@@ -193,14 +193,14 @@ pub fn initDefault(
193 io: Io,193 io: Io,
194 diagnostics: *Diagnostics,194 diagnostics: *Diagnostics,
195 cwd: Io.Dir,195 cwd: Io.Dir,
196 env_map: *const std.process.Environ.Map,196 environ_map: *const std.process.Environ.Map,
197) !Compilation {197) !Compilation {
198 var comp: Compilation = .{198 var comp: Compilation = .{
199 .gpa = gpa,199 .gpa = gpa,
200 .arena = arena,200 .arena = arena,
201 .io = io,201 .io = io,
202 .diagnostics = diagnostics,202 .diagnostics = diagnostics,
203 .environment = try Environment.loadAll(gpa, env_map),203 .environment = try Environment.loadAll(gpa, environ_map),
204 .cwd = cwd,204 .cwd = cwd,
205 };205 };
206 errdefer comp.deinit();206 errdefer comp.deinit();
lib/compiler/build_runner.zig+5-5
...@@ -87,7 +87,7 @@ pub fn main(init: process.Init.Minimal) !void {...@@ -87,7 +87,7 @@ pub fn main(init: process.Init.Minimal) !void {
87 .cwd = try process.getCwdAlloc(single_threaded_arena.allocator()),87 .cwd = try process.getCwdAlloc(single_threaded_arena.allocator()),
88 },88 },
89 .zig_exe = zig_exe,89 .zig_exe = zig_exe,
90 .env_map = try init.environ.createMap(arena),90 .environ_map = try init.environ.createMap(arena),
91 .global_cache_root = global_cache_directory,91 .global_cache_root = global_cache_directory,
92 .zig_lib_directory = zig_lib_directory,92 .zig_lib_directory = zig_lib_directory,
93 .host = .{93 .host = .{
...@@ -130,13 +130,13 @@ pub fn main(init: process.Init.Minimal) !void {...@@ -130,13 +130,13 @@ pub fn main(init: process.Init.Minimal) !void {
130 var debounce_interval_ms: u16 = 50;130 var debounce_interval_ms: u16 = 50;
131 var webui_listen: ?Io.net.IpAddress = null;131 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| {
134 if (std.meta.stringToEnum(ErrorStyle, str)) |style| {134 if (std.meta.stringToEnum(ErrorStyle, str)) |style| {
135 error_style = style;135 error_style = style;
136 }136 }
137 }137 }
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| {
140 if (std.meta.stringToEnum(MultilineErrors, str)) |style| {140 if (std.meta.stringToEnum(MultilineErrors, str)) |style| {
141 multiline_errors = style;141 multiline_errors = style;
142 }142 }
...@@ -433,8 +433,8 @@ pub fn main(init: process.Init.Minimal) !void {...@@ -433,8 +433,8 @@ pub fn main(init: process.Init.Minimal) !void {
433 }433 }
434 }434 }
435435
436 const NO_COLOR = std.zig.EnvVar.NO_COLOR.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.env_map);437 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(&graph.environ_map);
438438
439 graph.stderr_mode = switch (color) {439 graph.stderr_mode = switch (color) {
440 .auto => try .detect(io, .stderr(), NO_COLOR, CLICOLOR_FORCE),440 .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 {...@@ -29,7 +29,7 @@ pub fn main(init: std.process.Init) !void {
29 const gpa = init.gpa;29 const gpa = init.gpa;
30 const io = init.io;30 const io = init.io;
31 const args = try init.minimal.args.toSlice(arena);31 const args = try init.minimal.args.toSlice(arena);
32 const env_map = init.env_map;32 const environ_map = init.environ_map;
3333
34 const zig_lib_directory = args[1];34 const zig_lib_directory = args[1];
3535
...@@ -92,7 +92,7 @@ pub fn main(init: std.process.Init) !void {...@@ -92,7 +92,7 @@ pub fn main(init: std.process.Init) !void {
92 is_native_abi,92 is_native_abi,
93 true,93 true,
94 libc_installation,94 libc_installation,
95 env_map,95 environ_map,
96 ) catch |err| {96 ) catch |err| {
97 const zig_target = try target.zigTriple(arena);97 const zig_target = try target.zigTriple(arena);
98 fatal("unable to detect libc for target {s}: {t}", .{ zig_target, err });98 fatal("unable to detect libc for target {s}: {t}", .{ zig_target, err });
...@@ -123,7 +123,7 @@ pub fn main(init: std.process.Init) !void {...@@ -123,7 +123,7 @@ pub fn main(init: std.process.Init) !void {
123 var libc = LibCInstallation.findNative(gpa, io, .{123 var libc = LibCInstallation.findNative(gpa, io, .{
124 .verbose = true,124 .verbose = true,
125 .target = &target,125 .target = &target,
126 .env_map = env_map,126 .environ_map = environ_map,
127 }) catch |err| {127 }) catch |err| {
128 fatal("unable to detect native libc: {t}", .{err});128 fatal("unable to detect native libc: {t}", .{err});
129 };129 };
lib/compiler/resinator/compile.zig+2-2
...@@ -80,7 +80,7 @@ pub const Dependencies = struct {...@@ -80,7 +80,7 @@ pub const Dependencies = struct {
80 }80 }
81};81};
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 {
84 var lexer = lex.Lexer.init(source, .{84 var lexer = lex.Lexer.init(source, .{
85 .default_code_page = options.default_code_page,85 .default_code_page = options.default_code_page,
86 .source_mappings = options.source_mappings,86 .source_mappings = options.source_mappings,
...@@ -148,7 +148,7 @@ pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io...@@ -148,7 +148,7 @@ pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io
148 try search_dirs.append(allocator, .{ .dir = dir, .path = try allocator.dupe(u8, system_include_path) });148 try search_dirs.append(allocator, .{ .dir = dir, .path = try allocator.dupe(u8, system_include_path) });
149 }149 }
150 if (!options.ignore_include_env_var) {150 if (!options.ignore_include_env_var) {
151 const INCLUDE = env_map.get("INCLUDE") orelse "";151 const INCLUDE = environ_map.get("INCLUDE") orelse "";
152152
153 // The only precedence here is llvm-rc which also uses the platform-specific153 // The only precedence here is llvm-rc which also uses the platform-specific
154 // delimiter. There's no precedence set by `rc.exe` since it's Windows-only.154 // 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 {...@@ -24,8 +24,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
24 defer std.debug.assert(debug_allocator.deinit() == .ok);24 defer std.debug.assert(debug_allocator.deinit() == .ok);
25 const gpa = debug_allocator.allocator();25 const gpa = debug_allocator.allocator();
2626
27 var env_map = try init.environ.createMap(gpa);27 var environ_map = try init.environ.createMap(gpa);
28 defer env_map.deinit();28 defer environ_map.deinit();
2929
30 var threaded: std.Io.Threaded = .init(gpa, .{30 var threaded: std.Io.Threaded = .init(gpa, .{
31 .environ = init.environ,31 .environ = init.environ,
...@@ -151,8 +151,8 @@ pub fn main(init: std.process.Init.Minimal) !void {...@@ -151,8 +151,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
151 defer argv.deinit(aro_arena);151 defer argv.deinit(aro_arena);
152152
153 try argv.append(aro_arena, "arocc"); // dummy command name153 try argv.append(aro_arena, "arocc"); // dummy command name
154 const resolved_include_paths = try include_paths.get(&error_handler, &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, &env_map);155 try preprocess.appendAroArgs(aro_arena, &argv, options, resolved_include_paths, &environ_map);
156 try argv.append(aro_arena, switch (options.input_source) {156 try argv.append(aro_arena, switch (options.input_source) {
157 .stdio => "-",157 .stdio => "-",
158 .filename => |filename| filename,158 .filename => |filename| filename,
...@@ -286,7 +286,7 @@ pub fn main(init: std.process.Init.Minimal) !void {...@@ -286,7 +286,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
286 .dependencies = maybe_dependencies,286 .dependencies = maybe_dependencies,
287 .ignore_include_env_var = options.ignore_include_env_var,287 .ignore_include_env_var = options.ignore_include_env_var,
288 .extra_include_paths = options.extra_include_paths.items,288 .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),
290 .default_language_id = options.default_language_id,290 .default_language_id = options.default_language_id,
291 .default_code_page = default_code_page,291 .default_code_page = default_code_page,
292 .disjoint_code_page = has_disjoint_code_page,292 .disjoint_code_page = has_disjoint_code_page,
...@@ -295,7 +295,7 @@ pub fn main(init: std.process.Init.Minimal) !void {...@@ -295,7 +295,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
295 .max_string_literal_codepoints = options.max_string_literal_codepoints,295 .max_string_literal_codepoints = options.max_string_literal_codepoints,
296 .silent_duplicate_control_ids = options.silent_duplicate_control_ids,296 .silent_duplicate_control_ids = options.silent_duplicate_control_ids,
297 .warn_instead_of_error_on_invalid_code_page = options.warn_instead_of_error_on_invalid_code_page,297 .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) {
299 error.ParseError, error.CompileError => {299 error.ParseError, error.CompileError => {
300 try error_handler.emitDiagnostics(gpa, Io.Dir.cwd(), final_input, &diagnostics, mapping_results.mappings);300 try error_handler.emitDiagnostics(gpa, Io.Dir.cwd(), final_input, &diagnostics, mapping_results.mappings);
301 // Delete the output file on error301 // Delete the output file on error
...@@ -545,7 +545,7 @@ const LazyIncludePaths = struct {...@@ -545,7 +545,7 @@ const LazyIncludePaths = struct {
545 pub fn get(545 pub fn get(
546 self: *LazyIncludePaths,546 self: *LazyIncludePaths,
547 error_handler: *ErrorHandler,547 error_handler: *ErrorHandler,
548 env_map: *const std.process.Environ.Map,548 environ_map: *const std.process.Environ.Map,
549 ) ![]const []const u8 {549 ) ![]const []const u8 {
550 const io = self.io;550 const io = self.io;
551551
...@@ -558,7 +558,7 @@ const LazyIncludePaths = struct {...@@ -558,7 +558,7 @@ const LazyIncludePaths = struct {
558 self.auto_includes_option,558 self.auto_includes_option,
559 self.zig_lib_dir,559 self.zig_lib_dir,
560 self.target_machine_type,560 self.target_machine_type,
561 env_map,561 environ_map,
562 ) catch |err| switch (err) {562 ) catch |err| switch (err) {
563 error.OutOfMemory => |e| return e,563 error.OutOfMemory => |e| return e,
564 else => |e| {564 else => |e| {
...@@ -586,7 +586,7 @@ fn getIncludePaths(...@@ -586,7 +586,7 @@ fn getIncludePaths(
586 auto_includes_option: cli.Options.AutoIncludes,586 auto_includes_option: cli.Options.AutoIncludes,
587 zig_lib_dir: []const u8,587 zig_lib_dir: []const u8,
588 target_machine_type: std.coff.IMAGE.FILE.MACHINE,588 target_machine_type: std.coff.IMAGE.FILE.MACHINE,
589 env_map: *const std.process.Environ.Map,589 environ_map: *const std.process.Environ.Map,
590) ![]const []const u8 {590) ![]const []const u8 {
591 if (auto_includes_option == .none) return &[_][]const u8{};591 if (auto_includes_option == .none) return &[_][]const u8{};
592592
...@@ -667,7 +667,7 @@ fn getIncludePaths(...@@ -667,7 +667,7 @@ fn getIncludePaths(
667 is_native_abi,667 is_native_abi,
668 true,668 true,
669 null,669 null,
670 env_map,670 environ_map,
671 ) catch |err| switch (err) {671 ) catch |err| switch (err) {
672 error.OutOfMemory => |e| return e,672 error.OutOfMemory => |e| return e,
673 else => return error.MingwIncludesNotFound,673 else => return error.MingwIncludesNotFound,
lib/compiler/resinator/preprocess.zig+2-2
...@@ -86,7 +86,7 @@ fn hasAnyErrors(comp: *aro.Compilation) bool {...@@ -86,7 +86,7 @@ fn hasAnyErrors(comp: *aro.Compilation) bool {
8686
87/// `arena` is used for temporary -D argument strings and the INCLUDE environment variable.87/// `arena` is used for temporary -D argument strings and the INCLUDE environment variable.
88/// The arena should be kept alive at least as long as `argv`.88/// 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 {
90 try argv.appendSlice(arena, &.{90 try argv.appendSlice(arena, &.{
91 "-E",91 "-E",
92 "--comments",92 "--comments",
...@@ -109,7 +109,7 @@ pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options...@@ -109,7 +109,7 @@ pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options
109 }109 }
110110
111 if (!options.ignore_include_env_var) {111 if (!options.ignore_include_env_var) {
112 const INCLUDE = env_map.get("INCLUDE") orelse "";112 const INCLUDE = environ_map.get("INCLUDE") orelse "";
113113
114 // The only precedence here is llvm-rc which also uses the platform-specific114 // The only precedence here is llvm-rc which also uses the platform-specific
115 // delimiter. There's no precedence set by `rc.exe` since it's Windows-only.115 // 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 {...@@ -13,7 +13,7 @@ pub fn main(init: std.process.Init) u8 {
13 const gpa = init.gpa;13 const gpa = init.gpa;
14 const arena = init.arena.allocator();14 const arena = init.arena.allocator();
15 const io = init.io;15 const io = init.io;
16 const env_map = init.env_map;16 const environ_map = init.environ_map;
1717
18 const args = init.minimal.args.toSlice(arena) catch {18 const args = init.minimal.args.toSlice(arena) catch {
19 std.debug.print("ran out of memory allocating arguments\n", .{});19 std.debug.print("ran out of memory allocating arguments\n", .{});
...@@ -26,8 +26,8 @@ pub fn main(init: std.process.Init) u8 {...@@ -26,8 +26,8 @@ pub fn main(init: std.process.Init) u8 {
26 zig_integration = true;26 zig_integration = true;
27 }27 }
2828
29 const NO_COLOR = std.zig.EnvVar.NO_COLOR.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(env_map);30 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(environ_map);
3131
32 var stderr_buf: [1024]u8 = undefined;32 var stderr_buf: [1024]u8 = undefined;
33 var stderr = Io.File.stderr().writer(io, &stderr_buf);33 var stderr = Io.File.stderr().writer(io, &stderr_buf);
...@@ -42,7 +42,7 @@ pub fn main(init: std.process.Init) u8 {...@@ -42,7 +42,7 @@ pub fn main(init: std.process.Init) u8 {
42 };42 };
43 defer diagnostics.deinit();43 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) {
46 error.OutOfMemory => {46 error.OutOfMemory => {
47 std.debug.print("ran out of memory initializing C compilation\n", .{});47 std.debug.print("ran out of memory initializing C compilation\n", .{});
48 if (fast_exit) process.exit(1);48 if (fast_exit) process.exit(1);
lib/std/Build.zig+6-7
...@@ -12,7 +12,6 @@ const StringHashMap = std.StringHashMap;...@@ -12,7 +12,6 @@ const StringHashMap = std.StringHashMap;
12const Allocator = std.mem.Allocator;12const Allocator = std.mem.Allocator;
13const Target = std.Target;13const Target = std.Target;
14const process = std.process;14const process = std.process;
15const EnvMap = std.process.Environ.Map;
16const File = std.Io.File;15const File = std.Io.File;
17const Sha256 = std.crypto.hash.sha2.Sha256;16const Sha256 = std.crypto.hash.sha2.Sha256;
18const ArrayList = std.ArrayList;17const ArrayList = std.ArrayList;
...@@ -118,7 +117,7 @@ pub const Graph = struct {...@@ -118,7 +117,7 @@ pub const Graph = struct {
118 debug_compiler_runtime_libs: bool = false,117 debug_compiler_runtime_libs: bool = false,
119 cache: Cache,118 cache: Cache,
120 zig_exe: [:0]const u8,119 zig_exe: [:0]const u8,
121 env_map: EnvMap,120 environ_map: process.Environ.Map,
122 global_cache_root: Cache.Directory,121 global_cache_root: Cache.Directory,
123 zig_lib_directory: Cache.Directory,122 zig_lib_directory: Cache.Directory,
124 needed_lazy_dependencies: std.StringArrayHashMapUnmanaged(void) = .empty,123 needed_lazy_dependencies: std.StringArrayHashMapUnmanaged(void) = .empty,
...@@ -289,7 +288,7 @@ pub fn create(...@@ -289,7 +288,7 @@ pub fn create(
289 .lib_dir = undefined,288 .lib_dir = undefined,
290 .exe_dir = undefined,289 .exe_dir = undefined,
291 .h_dir = undefined,290 .h_dir = undefined,
292 .dest_dir = graph.env_map.get("DESTDIR"),291 .dest_dir = graph.environ_map.get("DESTDIR"),
293 .install_tls = .{292 .install_tls = .{
294 .step = .init(.{293 .step = .init(.{
295 .id = TopLevelStep.base_id,294 .id = TopLevelStep.base_id,
...@@ -1772,7 +1771,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {...@@ -1772,7 +1771,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
1772 }1771 }
17731772
1774 if (builtin.os.tag == .windows) {1773 if (builtin.os.tag == .windows) {
1775 if (b.graph.env_map.get("PATHEXT")) |PATHEXT| {1774 if (b.graph.environ_map.get("PATHEXT")) |PATHEXT| {
1776 var it = mem.tokenizeScalar(u8, PATHEXT, fs.path.delimiter);1775 var it = mem.tokenizeScalar(u8, PATHEXT, fs.path.delimiter);
17771776
1778 while (it.next()) |ext| {1777 while (it.next()) |ext| {
...@@ -1803,7 +1802,7 @@ pub fn findProgram(b: *Build, names: []const []const u8, paths: []const []const...@@ -1803,7 +1802,7 @@ pub fn findProgram(b: *Build, names: []const []const u8, paths: []const []const
1803 return tryFindProgram(b, b.pathJoin(&.{ search_prefix, "bin", name })) orelse continue;1802 return tryFindProgram(b, b.pathJoin(&.{ search_prefix, "bin", name })) orelse continue;
1804 }1803 }
1805 }1804 }
1806 if (b.graph.env_map.get("PATH")) |PATH| {1805 if (b.graph.environ_map.get("PATH")) |PATH| {
1807 for (names) |name| {1806 for (names) |name| {
1808 if (fs.path.isAbsolute(name)) {1807 if (fs.path.isAbsolute(name)) {
1809 return name;1808 return name;
...@@ -1840,11 +1839,11 @@ pub fn runAllowFail(...@@ -1840,11 +1839,11 @@ pub fn runAllowFail(
1840 const io = graph.io;1839 const io = graph.io;
18411840
1842 const max_output_size = 400 * 1024;1841 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
1845 var child = try std.process.spawn(io, .{1844 var child = try std.process.spawn(io, .{
1846 .argv = argv,1845 .argv = argv,
1847 .env_map = &graph.env_map,1846 .environ_map = &graph.environ_map,
1848 .stdin = .ignore,1847 .stdin = .ignore,
1849 .stdout = .pipe,1848 .stdout = .pipe,
1850 .stderr = stderr_behavior,1849 .stderr = stderr_behavior,
lib/std/Build/Step.zig+3-3
...@@ -362,7 +362,7 @@ pub fn captureChildProcess(...@@ -362,7 +362,7 @@ pub fn captureChildProcess(
362362
363 const result = std.process.run(arena, io, .{363 const result = std.process.run(arena, io, .{
364 .argv = argv,364 .argv = argv,
365 .env_map = &graph.env_map,365 .environ_map = &graph.environ_map,
366 .progress_node = progress_node,366 .progress_node = progress_node,
367 }) catch |err| return s.fail("failed to run {s}: {t}", .{ argv[0], err });367 }) catch |err| return s.fail("failed to run {s}: {t}", .{ argv[0], err });
368368
...@@ -453,7 +453,7 @@ pub fn evalZigProcess(...@@ -453,7 +453,7 @@ pub fn evalZigProcess(
453453
454 zp.child = std.process.spawn(io, .{454 zp.child = std.process.spawn(io, .{
455 .argv = argv,455 .argv = argv,
456 .env_map = &b.graph.env_map,456 .environ_map = &b.graph.environ_map,
457 .stdin = .pipe,457 .stdin = .pipe,
458 .stdout = .pipe,458 .stdout = .pipe,
459 .stderr = .pipe,459 .stderr = .pipe,
...@@ -702,7 +702,7 @@ pub fn handleVerbose2(...@@ -702,7 +702,7 @@ pub fn handleVerbose2(
702 // stderr before spawning them.702 // stderr before spawning them.
703 const text = try allocPrintCmd(b.allocator, opt_cwd, if (opt_env) |env| .{703 const text = try allocPrintCmd(b.allocator, opt_cwd, if (opt_env) |env| .{
704 .child = env,704 .child = env,
705 .parent = &graph.env_map,705 .parent = &graph.environ_map,
706 } else null, argv);706 } else null, argv);
707 std.debug.print("{s}\n", .{text});707 std.debug.print("{s}\n", .{text});
708 }708 }
lib/std/Build/Step/Compile.zig+2-2
...@@ -741,7 +741,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {...@@ -741,7 +741,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
741 };741 };
742742
743 var code: u8 = undefined;743 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";
745 const stdout = if (b.runAllowFail(&[_][]const u8{745 const stdout = if (b.runAllowFail(&[_][]const u8{
746 pkg_config_exe,746 pkg_config_exe,
747 pkg_name,747 pkg_name,
...@@ -1846,7 +1846,7 @@ pub fn doAtomicSymLinks(...@@ -1846,7 +1846,7 @@ pub fn doAtomicSymLinks(
1846}1846}
18471847
1848fn execPkgConfigList(b: *std.Build, out_code: *u8) (PkgConfigError || RunError)![]const PkgConfigPkg {1848fn 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";
1850 const stdout = try b.runAllowFail(&[_][]const u8{ pkg_config_exe, "--list-all" }, out_code, .ignore);1850 const stdout = try b.runAllowFail(&[_][]const u8{ pkg_config_exe, "--list-all" }, out_code, .ignore);
1851 var list = std.array_list.Managed(PkgConfigPkg).init(b.allocator);1851 var list = std.array_list.Managed(PkgConfigPkg).init(b.allocator);
1852 errdefer list.deinit();1852 errdefer list.deinit();
lib/std/Build/Step/Options.zig+1-1
...@@ -550,7 +550,7 @@ test Options {...@@ -550,7 +550,7 @@ test Options {
550 .cwd = cwd,550 .cwd = cwd,
551 },551 },
552 .zig_exe = "test",552 .zig_exe = "test",
553 .env_map = std.process.Environ.Map.init(arena.allocator()),553 .environ_map = std.process.Environ.Map.init(arena.allocator()),
554 .global_cache_root = .{ .path = "test", .handle = Io.Dir.cwd() },554 .global_cache_root = .{ .path = "test", .handle = Io.Dir.cwd() },
555 .host = .{555 .host = .{
556 .query = .{},556 .query = .{},
lib/std/Build/Step/Run.zig+34-34
...@@ -23,7 +23,7 @@ argv: std.ArrayList(Arg),...@@ -23,7 +23,7 @@ argv: std.ArrayList(Arg),
23cwd: ?Build.LazyPath,23cwd: ?Build.LazyPath,
2424
25/// Override this field to modify the environment, or use setEnvironmentVariable25/// Override this field to modify the environment, or use setEnvironmentVariable
26env_map: ?*EnvMap,26environ_map: ?*EnvMap,
2727
28/// Controls the `NO_COLOR` and `CLICOLOR_FORCE` environment variables.28/// Controls the `NO_COLOR` and `CLICOLOR_FORCE` environment variables.
29color: Color = .auto,29color: Color = .auto,
...@@ -215,7 +215,7 @@ pub fn create(owner: *std.Build, name: []const u8) *Run {...@@ -215,7 +215,7 @@ pub fn create(owner: *std.Build, name: []const u8) *Run {
215 }),215 }),
216 .argv = .{},216 .argv = .{},
217 .cwd = null,217 .cwd = null,
218 .env_map = null,218 .environ_map = null,
219 .disable_zig_progress = false,219 .disable_zig_progress = false,
220 .stdio = .infer_from_args,220 .stdio = .infer_from_args,
221 .stdin = .none,221 .stdin = .none,
...@@ -540,12 +540,12 @@ pub fn clearEnvironment(run: *Run) void {...@@ -540,12 +540,12 @@ pub fn clearEnvironment(run: *Run) void {
540 const b = run.step.owner;540 const b = run.step.owner;
541 const new_env_map = b.allocator.create(EnvMap) catch @panic("OOM");541 const new_env_map = b.allocator.create(EnvMap) catch @panic("OOM");
542 new_env_map.* = .init(b.allocator);542 new_env_map.* = .init(b.allocator);
543 run.env_map = new_env_map;543 run.environ_map = new_env_map;
544}544}
545545
546pub fn addPathDir(run: *Run, search_path: []const u8) void {546pub fn addPathDir(run: *Run, search_path: []const u8) void {
547 const b = run.step.owner;547 const b = run.step.owner;
548 const env_map = getEnvMapInternal(run);548 const environ_map = getEnvMapInternal(run);
549549
550 const use_wine = b.enable_wine and b.graph.host.result.os.tag != .windows and use_wine: switch (run.argv.items[0]) {550 const use_wine = b.enable_wine and b.graph.host.result.os.tag != .windows and use_wine: switch (run.argv.items[0]) {
551 .artifact => |p| p.artifact.rootModuleTarget().os.tag == .windows,551 .artifact => |p| p.artifact.rootModuleTarget().os.tag == .windows,
...@@ -562,7 +562,7 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {...@@ -562,7 +562,7 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {
562 .output_file, .output_directory => false,562 .output_file, .output_directory => false,
563 };563 };
564 const key = if (use_wine) "WINEPATH" else "PATH";564 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
567 if (prev_path) |pp| {567 if (prev_path) |pp| {
568 const new_path = b.fmt("{s}{c}{s}", .{568 const new_path = b.fmt("{s}{c}{s}", .{
...@@ -570,9 +570,9 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {...@@ -570,9 +570,9 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {
570 if (use_wine) Dir.path.delimiter_windows else Dir.path.delimiter,570 if (use_wine) Dir.path.delimiter_windows else Dir.path.delimiter,
571 search_path,571 search_path,
572 });572 });
573 env_map.put(key, new_path) catch @panic("OOM");573 environ_map.put(key, new_path) catch @panic("OOM");
574 } else {574 } 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");
576 }576 }
577}577}
578578
...@@ -583,18 +583,18 @@ pub fn getEnvMap(run: *Run) *EnvMap {...@@ -583,18 +583,18 @@ pub fn getEnvMap(run: *Run) *EnvMap {
583fn getEnvMapInternal(run: *Run) *EnvMap {583fn getEnvMapInternal(run: *Run) *EnvMap {
584 const graph = run.step.owner.graph;584 const graph = run.step.owner.graph;
585 const arena = graph.arena;585 const arena = graph.arena;
586 return run.env_map orelse {586 return run.environ_map orelse {
587 const cloned_map = arena.create(EnvMap) catch @panic("OOM");587 const cloned_map = arena.create(EnvMap) catch @panic("OOM");
588 cloned_map.* = graph.env_map.clone(arena) catch @panic("OOM");588 cloned_map.* = graph.environ_map.clone(arena) catch @panic("OOM");
589 run.env_map = cloned_map;589 run.environ_map = cloned_map;
590 return cloned_map;590 return cloned_map;
591 };591 };
592}592}
593593
594pub fn setEnvironmentVariable(run: *Run, key: []const u8, value: []const u8) void {594pub fn setEnvironmentVariable(run: *Run, key: []const u8, value: []const u8) void {
595 const env_map = run.getEnvMap();595 const environ_map = run.getEnvMap();
596 // This data structure already dupes keys and values.596 // 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");
598}598}
599599
600pub fn removeEnvironmentVariable(run: *Run, key: []const u8) void {600pub fn removeEnvironmentVariable(run: *Run, key: []const u8) void {
...@@ -762,7 +762,7 @@ fn convertPathArg(run: *Run, path: Build.Cache.Path) []const u8 {...@@ -762,7 +762,7 @@ fn convertPathArg(run: *Run, path: Build.Cache.Path) []const u8 {
762 const child_lazy_cwd = run.cwd orelse break :rel path_str;762 const child_lazy_cwd = run.cwd orelse break :rel path_str;
763 const child_cwd = child_lazy_cwd.getPath3(b, &run.step).toString(arena) catch @panic("OOM");763 const child_cwd = child_lazy_cwd.getPath3(b, &run.step).toString(arena) catch @panic("OOM");
764 // Convert it from relative to *our* cwd, to relative to the *child's* cwd.764 // 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");
766 };766 };
767 // Not every path can be made relative, e.g. if the path and the child cwd are on different767 // Not every path can be made relative, e.g. if the path and the child cwd are on different
768 // disk designators on Windows. In that case, `relative` will return an absolute path which we can768 // 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 {...@@ -794,8 +794,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
794 var man = b.graph.cache.obtain();794 var man = b.graph.cache.obtain();
795 defer man.deinit();795 defer man.deinit();
796796
797 if (run.env_map) |env_map| {797 if (run.environ_map) |environ_map| {
798 for (env_map.keys(), env_map.values()) |key, value| {798 for (environ_map.keys(), environ_map.values()) |key, value| {
799 man.hash.addBytes(key);799 man.hash.addBytes(key);
800 man.hash.addBytes(value);800 man.hash.addBytes(value);
801 }801 }
...@@ -1222,7 +1222,7 @@ fn runCommand(...@@ -1222,7 +1222,7 @@ fn runCommand(
1222 const cwd: ?[]const u8 = if (run.cwd) |lazy_cwd| lazy_cwd.getPath2(b, step) else null;1222 const cwd: ?[]const u8 = if (run.cwd) |lazy_cwd| lazy_cwd.getPath2(b, step) else null;
12231223
1224 try step.handleChildProcUnsupported();1224 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
1227 const allow_skip = switch (run.stdio) {1227 const allow_skip = switch (run.stdio) {
1228 .check, .zig_test => run.skip_foreign_checks,1228 .check, .zig_test => run.skip_foreign_checks,
...@@ -1232,13 +1232,13 @@ fn runCommand(...@@ -1232,13 +1232,13 @@ fn runCommand(
1232 var interp_argv = std.array_list.Managed([]const u8).init(b.allocator);1232 var interp_argv = std.array_list.Managed([]const u8).init(b.allocator);
1233 defer interp_argv.deinit();1233 defer interp_argv.deinit();
12341234
1235 var env_map: EnvMap = env: {1235 var environ_map: EnvMap = env: {
1236 const orig = run.env_map orelse &b.graph.env_map;1236 const orig = run.environ_map orelse &b.graph.environ_map;
1237 break :env try orig.clone(gpa);1237 break :env try orig.clone(gpa);
1238 };1238 };
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: {
1242 // InvalidExe: cpu arch mismatch1242 // InvalidExe: cpu arch mismatch
1243 // FileNotFound: can happen with a wrong dynamic linker path1243 // FileNotFound: can happen with a wrong dynamic linker path
1244 if (err == error.InvalidExe or err == error.FileNotFound) interpret: {1244 if (err == error.InvalidExe or err == error.FileNotFound) interpret: {
...@@ -1274,8 +1274,8 @@ fn runCommand(...@@ -1274,8 +1274,8 @@ fn runCommand(
12741274
1275 // Wine's excessive stderr logging is only situationally helpful. Disable it by default, but1275 // Wine's excessive stderr logging is only situationally helpful. Disable it by default, but
1276 // allow the user to override it (e.g. with `WINEDEBUG=err+all`) if desired.1276 // allow the user to override it (e.g. with `WINEDEBUG=err+all`) if desired.
1277 if (env_map.get("WINEDEBUG") == null) {1277 if (environ_map.get("WINEDEBUG") == null) {
1278 try env_map.put("WINEDEBUG", "-all");1278 try environ_map.put("WINEDEBUG", "-all");
1279 }1279 }
1280 } else {1280 } else {
1281 return failForeign(run, "-fwine", argv[0], exe);1281 return failForeign(run, "-fwine", argv[0], exe);
...@@ -1372,9 +1372,9 @@ fn runCommand(...@@ -1372,9 +1372,9 @@ fn runCommand(
13721372
1373 gpa.free(step.result_failed_command.?);1373 gpa.free(step.result_failed_command.?);
1374 step.result_failed_command = null;1374 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| {
1378 if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped;1378 if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped;
1379 if (e == error.MakeFailed) return error.MakeFailed; // error already reported1379 if (e == error.MakeFailed) return error.MakeFailed; // error already reported
1380 return step.fail("unable to spawn interpreter {s}: {s}", .{1380 return step.fail("unable to spawn interpreter {s}: {s}", .{
...@@ -1529,7 +1529,7 @@ const EvalGenericResult = struct {...@@ -1529,7 +1529,7 @@ const EvalGenericResult = struct {
1529fn spawnChildAndCollect(1529fn spawnChildAndCollect(
1530 run: *Run,1530 run: *Run,
1531 argv: []const []const u8,1531 argv: []const []const u8,
1532 env_map: *EnvMap,1532 environ_map: *EnvMap,
1533 has_side_effects: bool,1533 has_side_effects: bool,
1534 options: Step.MakeOptions,1534 options: Step.MakeOptions,
1535 fuzz_context: ?FuzzContext,1535 fuzz_context: ?FuzzContext,
...@@ -1548,14 +1548,14 @@ fn spawnChildAndCollect(...@@ -1548,14 +1548,14 @@ fn spawnChildAndCollect(
1548 // If an error occurs, it's caused by this command:1548 // If an error occurs, it's caused by this command:
1549 assert(run.step.result_failed_command == null);1549 assert(run.step.result_failed_command == null);
1550 run.step.result_failed_command = try Step.allocPrintCmd(options.gpa, child_cwd, .{1550 run.step.result_failed_command = try Step.allocPrintCmd(options.gpa, child_cwd, .{
1551 .child = env_map,1551 .child = environ_map,
1552 .parent = &graph.env_map,1552 .parent = &graph.environ_map,
1553 }, argv);1553 }, argv);
15541554
1555 var spawn_options: process.SpawnOptions = .{1555 var spawn_options: process.SpawnOptions = .{
1556 .argv = argv,1556 .argv = argv,
1557 .cwd = child_cwd,1557 .cwd = child_cwd,
1558 .env_map = env_map,1558 .environ_map = environ_map,
1559 .request_resource_usage_statistics = true,1559 .request_resource_usage_statistics = true,
1560 .stdin = if (run.stdin != .none) s: {1560 .stdin = if (run.stdin != .none) s: {
1561 assert(run.stdio != .inherit);1561 assert(run.stdio != .inherit);
...@@ -1595,7 +1595,7 @@ fn spawnChildAndCollect(...@@ -1595,7 +1595,7 @@ fn spawnChildAndCollect(
1595 break :m stderr.terminal_mode;1595 break :m stderr.terminal_mode;
1596 } else .no_color;1596 } else .no_color;
1597 defer if (inherit) io.unlockStderr();1597 defer if (inherit) io.unlockStderr();
1598 try setColorEnvironmentVariables(run, env_map, terminal_mode);1598 try setColorEnvironmentVariables(run, environ_map, terminal_mode);
1599 var timer = try std.time.Timer.start();1599 var timer = try std.time.Timer.start();
1600 const res = try evalGeneric(run, spawn_options);1600 const res = try evalGeneric(run, spawn_options);
1601 run.step.result_duration_ns = timer.read();1601 run.step.result_duration_ns = timer.read();
...@@ -1603,16 +1603,16 @@ fn spawnChildAndCollect(...@@ -1603,16 +1603,16 @@ fn spawnChildAndCollect(
1603 }1603 }
1604}1604}
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 {
1607 color: switch (run.color) {1607 color: switch (run.color) {
1608 .manual => {},1608 .manual => {},
1609 .enable => {1609 .enable => {
1610 try env_map.put("CLICOLOR_FORCE", "1");1610 try environ_map.put("CLICOLOR_FORCE", "1");
1611 _ = env_map.swapRemove("NO_COLOR");1611 _ = environ_map.swapRemove("NO_COLOR");
1612 },1612 },
1613 .disable => {1613 .disable => {
1614 try env_map.put("NO_COLOR", "1");1614 try environ_map.put("NO_COLOR", "1");
1615 _ = env_map.swapRemove("CLICOLOR_FORCE");1615 _ = environ_map.swapRemove("CLICOLOR_FORCE");
1616 },1616 },
1617 .inherit => switch (terminal_mode) {1617 .inherit => switch (terminal_mode) {
1618 .no_color, .windows_api => continue :color .disable,1618 .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...@@ -568,7 +568,7 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
568568
569 var child = try std.process.spawn(io, .{569 var child = try std.process.spawn(io, .{
570 .argv = argv.items,570 .argv = argv.items,
571 .env_map = &graph.env_map,571 .environ_map = &graph.environ_map,
572 .stdin = .pipe,572 .stdin = .pipe,
573 .stdout = .pipe,573 .stdout = .pipe,
574 .stderr = .pipe,574 .stderr = .pipe,
lib/std/Io/Threaded.zig+3-3
...@@ -12887,8 +12887,8 @@ fn spawnPosix(t: *Threaded, options: process.SpawnOptions) process.SpawnError!Sp...@@ -12887,8 +12887,8 @@ fn spawnPosix(t: *Threaded, options: process.SpawnOptions) process.SpawnError!Sp
1288712887
12888 const envp: [*:null]const ?[*:0]const u8 = m: {12888 const envp: [*:null]const ?[*:0]const u8 = m: {
12889 const prog_fd: i32 = if (prog_pipe[1] == -1) -1 else prog_fileno;12889 const prog_fd: i32 = if (prog_pipe[1] == -1) -1 else prog_fileno;
12890 if (options.env_map) |env_map| {12890 if (options.environ_map) |environ_map| {
12891 break :m (try env_map.createBlockPosix(arena, .{12891 break :m (try environ_map.createBlockPosix(arena, .{
12892 .zig_progress_fd = prog_fd,12892 .zig_progress_fd = prog_fd,
12893 })).ptr;12893 })).ptr;
12894 }12894 }
...@@ -13436,7 +13436,7 @@ fn processSpawnWindows(userdata: ?*anyopaque, options: process.SpawnOptions) pro...@@ -13436,7 +13436,7 @@ fn processSpawnWindows(userdata: ?*anyopaque, options: process.SpawnOptions) pro
13436 const cwd_w = if (options.cwd) |cwd| try std.unicode.wtf8ToWtf16LeAllocZ(arena, cwd) else null;13436 const cwd_w = if (options.cwd) |cwd| try std.unicode.wtf8ToWtf16LeAllocZ(arena, cwd) else null;
13437 const cwd_w_ptr = if (cwd_w) |cwd| cwd.ptr else null;13437 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;
13440 const envp_ptr = if (maybe_envp_buf) |envp_buf| envp_buf.ptr else null;13440 const envp_ptr = if (maybe_envp_buf) |envp_buf| envp_buf.ptr else null;
1344113441
13442 const app_name_wtf8 = options.argv[0];13442 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 {...@@ -1506,16 +1506,16 @@ fn testBasenameWindows(input: []const u8, expected_output: []const u8) !void {
1506/// on each), a zero-length string is returned.1506/// on each), a zero-length string is returned.
1507///1507///
1508/// See `relativePosix` and `relativeWindows` for operating system specific1508/// 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.
1510pub fn relative(1510pub fn relative(
1511 gpa: Allocator,1511 gpa: Allocator,
1512 cwd: []const u8,1512 cwd: []const u8,
1513 env_map: ?*const std.process.Environ.Map,1513 environ_map: ?*const std.process.Environ.Map,
1514 from: []const u8,1514 from: []const u8,
1515 to: []const u8,1515 to: []const u8,
1516) Allocator.Error![]u8 {1516) Allocator.Error![]u8 {
1517 if (native_os == .windows) {1517 if (native_os == .windows) {
1518 return relativeWindows(gpa, cwd, env_map, from, to);1518 return relativeWindows(gpa, cwd, environ_map, from, to);
1519 } else {1519 } else {
1520 return relativePosix(gpa, cwd, from, to);1520 return relativePosix(gpa, cwd, from, to);
1521 }1521 }
...@@ -1536,12 +1536,12 @@ pub fn relative(...@@ -1536,12 +1536,12 @@ pub fn relative(
1536/// Per-drive CWDs are stored in special semi-hidden environment variables of1536/// Per-drive CWDs are stored in special semi-hidden environment variables of
1537/// the format `=<drive-letter>:`, e.g. `=C:`. This type of CWD is purely a1537/// the format `=<drive-letter>:`, e.g. `=C:`. This type of CWD is purely a
1538/// shell concept, so there's no guarantee that it'll be set or that it'll even1538/// 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` is1539/// be accurate. This is the only reason for the `environ_map` parameter. `null` is
1540/// treated equivalent to the environment variable missing.1540/// treated equivalent to the environment variable missing.
1541pub fn relativeWindows(1541pub fn relativeWindows(
1542 gpa: Allocator,1542 gpa: Allocator,
1543 cwd: []const u8,1543 cwd: []const u8,
1544 env_map: ?*const std.process.Environ.Map,1544 environ_map: ?*const std.process.Environ.Map,
1545 from: []const u8,1545 from: []const u8,
1546 to: []const u8,1546 to: []const u8,
1547) Allocator.Error![]u8 {1547) Allocator.Error![]u8 {
...@@ -1565,13 +1565,13 @@ pub fn relativeWindows(...@@ -1565,13 +1565,13 @@ pub fn relativeWindows(
1565 };1565 };
15661566
1567 if (result_is_always_to) {1567 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);
1569 }1569 }
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);
1572 defer gpa.free(resolved_from);1572 defer gpa.free(resolved_from);
1573 var clean_up_resolved_to = true;1573 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);
1575 defer if (clean_up_resolved_to) gpa.free(resolved_to);1575 defer if (clean_up_resolved_to) gpa.free(resolved_to);
15761576
1577 const parsed_resolved_from = parsePathWindows(u8, resolved_from);1577 const parsed_resolved_from = parsePathWindows(u8, resolved_from);
...@@ -1637,7 +1637,7 @@ pub fn relativeWindows(...@@ -1637,7 +1637,7 @@ pub fn relativeWindows(
1637fn windowsResolveAgainstCwd(1637fn windowsResolveAgainstCwd(
1638 gpa: Allocator,1638 gpa: Allocator,
1639 cwd: []const u8,1639 cwd: []const u8,
1640 env_map: ?*const std.process.Environ.Map,1640 environ_map: ?*const std.process.Environ.Map,
1641 path: []const u8,1641 path: []const u8,
1642 parsed: WindowsPath2(u8),1642 parsed: WindowsPath2(u8),
1643) ![]u8 {1643) ![]u8 {
...@@ -1679,7 +1679,7 @@ fn windowsResolveAgainstCwd(...@@ -1679,7 +1679,7 @@ fn windowsResolveAgainstCwd(
1679 if (drive_letters_match)1679 if (drive_letters_match)
1680 break :drive_cwd cwd;1680 break :drive_cwd cwd;
16811681
1682 if (env_map) |m| {1682 if (environ_map) |m| {
1683 if (m.get(&.{ '=', parsed.root[0], ':' })) |v| {1683 if (m.get(&.{ '=', parsed.root[0], ':' })) |v| {
1684 break :drive_cwd try temp_allocator.dupe(u8, v);1684 break :drive_cwd try temp_allocator.dupe(u8, v);
1685 }1685 }
lib/std/http/Client.zig+5-5
...@@ -1307,7 +1307,7 @@ pub fn deinit(client: *Client) void {...@@ -1307,7 +1307,7 @@ pub fn deinit(client: *Client) void {
1307/// Asserts the client has no active connections.1307/// Asserts the client has no active connections.
1308/// Uses `arena` for a few small allocations that must outlive the client, or1308/// Uses `arena` for a few small allocations that must outlive the client, or
1309/// at least until those fields are set to different values.1309/// 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 {
1311 // Prevent any new connections from being created.1311 // Prevent any new connections from being created.
1312 client.connection_pool.mutex.lock();1312 client.connection_pool.mutex.lock();
1313 defer client.connection_pool.mutex.unlock();1313 defer client.connection_pool.mutex.unlock();
...@@ -1315,13 +1315,13 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce...@@ -1315,13 +1315,13 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce
1315 assert(client.connection_pool.used.first == null); // There are active requests.1315 assert(client.connection_pool.used.first == null); // There are active requests.
13161316
1317 if (client.http_proxy == null) {1317 if (client.http_proxy == null) {
1318 client.http_proxy = try createProxyFromEnvVar(arena, env_map, &.{1318 client.http_proxy = try createProxyFromEnvVar(arena, environ_map, &.{
1319 "http_proxy", "HTTP_PROXY", "all_proxy", "ALL_PROXY",1319 "http_proxy", "HTTP_PROXY", "all_proxy", "ALL_PROXY",
1320 });1320 });
1321 }1321 }
13221322
1323 if (client.https_proxy == null) {1323 if (client.https_proxy == null) {
1324 client.https_proxy = try createProxyFromEnvVar(arena, env_map, &.{1324 client.https_proxy = try createProxyFromEnvVar(arena, environ_map, &.{
1325 "https_proxy", "HTTPS_PROXY", "all_proxy", "ALL_PROXY",1325 "https_proxy", "HTTPS_PROXY", "all_proxy", "ALL_PROXY",
1326 });1326 });
1327 }1327 }
...@@ -1329,11 +1329,11 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce...@@ -1329,11 +1329,11 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce
13291329
1330fn createProxyFromEnvVar(1330fn createProxyFromEnvVar(
1331 arena: Allocator,1331 arena: Allocator,
1332 env_map: *std.process.Environ.Map,1332 environ_map: *std.process.Environ.Map,
1333 env_var_names: []const []const u8,1333 env_var_names: []const []const u8,
1334) !?*Proxy {1334) !?*Proxy {
1335 const content = for (env_var_names) |name| {1335 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;
1337 if (content.len == 0) continue;1337 if (content.len == 0) continue;
1338 break content;1338 break content;
1339 } else return null;1339 } else return null;
lib/std/process.zig+5-5
...@@ -46,7 +46,7 @@ pub const Init = struct {...@@ -46,7 +46,7 @@ pub const Init = struct {
46 /// configuration. Debug mode will set up leak checking.46 /// configuration. Debug mode will set up leak checking.
47 io: Io,47 io: Io,
48 /// Environment variables, initialized with `gpa`. Not threadsafe.48 /// Environment variables, initialized with `gpa`. Not threadsafe.
49 env_map: *Environ.Map,49 environ_map: *Environ.Map,
5050
51 /// Alternative to `Init` as the first parameter of the main function.51 /// Alternative to `Init` as the first parameter of the main function.
52 pub const Minimal = struct {52 pub const Minimal = struct {
...@@ -295,7 +295,7 @@ pub const ReplaceOptions = struct {...@@ -295,7 +295,7 @@ pub const ReplaceOptions = struct {
295 arg0_expand: ArgExpansion = .no_expand,295 arg0_expand: ArgExpansion = .no_expand,
296 /// Replaces the environment when provided. The PATH value from here is296 /// Replaces the environment when provided. The PATH value from here is
297 /// never used to resolve `argv[0]`.297 /// never used to resolve `argv[0]`.
298 env_map: ?*const Environ.Map = null,298 environ_map: ?*const Environ.Map = null,
299};299};
300300
301/// Replaces the current process image with the executed process. If this301/// Replaces the current process image with the executed process. If this
...@@ -377,7 +377,7 @@ pub const SpawnOptions = struct {...@@ -377,7 +377,7 @@ pub const SpawnOptions = struct {
377 /// Replaces the child environment when provided. The PATH value from here377 /// Replaces the child environment when provided. The PATH value from here
378 /// is not used to resolve `argv[0]`; that resolution always uses parent378 /// is not used to resolve `argv[0]`; that resolution always uses parent
379 /// environment.379 /// environment.
380 env_map: ?*const Environ.Map = null,380 environ_map: ?*const Environ.Map = null,
381 expand_arg0: ArgExpansion = .no_expand,381 expand_arg0: ArgExpansion = .no_expand,
382 /// When populated, a pipe will be created for the child process to382 /// When populated, a pipe will be created for the child process to
383 /// communicate progress back to the parent. The file descriptor of the383 /// communicate progress back to the parent. The file descriptor of the
...@@ -475,7 +475,7 @@ pub const RunOptions = struct {...@@ -475,7 +475,7 @@ pub const RunOptions = struct {
475 /// Replaces the child environment when provided. The PATH value from here475 /// Replaces the child environment when provided. The PATH value from here
476 /// is not used to resolve `argv[0]`; that resolution always uses parent476 /// is not used to resolve `argv[0]`; that resolution always uses parent
477 /// environment.477 /// environment.
478 env_map: ?*const Environ.Map = null,478 environ_map: ?*const Environ.Map = null,
479 expand_arg0: ArgExpansion = .no_expand,479 expand_arg0: ArgExpansion = .no_expand,
480 /// When populated, a pipe will be created for the child process to480 /// When populated, a pipe will be created for the child process to
481 /// communicate progress back to the parent. The file descriptor of the481 /// 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 {...@@ -505,7 +505,7 @@ pub fn run(gpa: Allocator, io: Io, options: RunOptions) RunError!RunResult {
505 .argv = options.argv,505 .argv = options.argv,
506 .cwd = options.cwd,506 .cwd = options.cwd,
507 .cwd_dir = options.cwd_dir,507 .cwd_dir = options.cwd_dir,
508 .env_map = options.env_map,508 .environ_map = options.environ_map,
509 .expand_arg0 = options.expand_arg0,509 .expand_arg0 = options.expand_arg0,
510 .progress_node = options.progress_node,510 .progress_node = options.progress_node,
511 .create_no_window = options.create_no_window,511 .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...@@ -699,9 +699,9 @@ inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.B
699 });699 });
700 defer threaded.deinit();700 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|
703 std.process.fatal("failed to parse environment variables: {t}", .{err});703 std.process.fatal("failed to parse environment variables: {t}", .{err});
704 defer env_map.deinit();704 defer environ_map.deinit();
705705
706 return wrapMain(root.main(.{706 return wrapMain(root.main(.{
707 .minimal = .{707 .minimal = .{
...@@ -711,7 +711,7 @@ inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.B...@@ -711,7 +711,7 @@ inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.B
711 .arena = &arena_allocator,711 .arena = &arena_allocator,
712 .gpa = gpa,712 .gpa = gpa,
713 .io = threaded.io(),713 .io = threaded.io(),
714 .env_map = &env_map,714 .environ_map = &environ_map,
715 }));715 }));
716}716}
717717
lib/std/zig/LibCDirs.zig+3-3
...@@ -28,7 +28,7 @@ pub fn detect(...@@ -28,7 +28,7 @@ pub fn detect(
28 is_native_abi: bool,28 is_native_abi: bool,
29 link_libc: bool,29 link_libc: bool,
30 libc_installation: ?*const LibCInstallation,30 libc_installation: ?*const LibCInstallation,
31 env_map: *const std.process.Environ.Map,31 environ_map: *const std.process.Environ.Map,
32) LibCInstallation.FindError!LibCDirs {32) LibCInstallation.FindError!LibCDirs {
33 if (!link_libc) {33 if (!link_libc) {
34 return .{34 return .{
...@@ -50,7 +50,7 @@ pub fn detect(...@@ -50,7 +50,7 @@ pub fn detect(
50 const libc = try arena.create(LibCInstallation);50 const libc = try arena.create(LibCInstallation);
51 libc.* = LibCInstallation.findNative(arena, io, .{51 libc.* = LibCInstallation.findNative(arena, io, .{
52 .target = target,52 .target = target,
53 .env_map = env_map,53 .environ_map = environ_map,
54 }) catch |err| switch (err) {54 }) catch |err| switch (err) {
55 error.CCompilerExitCode,55 error.CCompilerExitCode,
56 error.CCompilerCrashed,56 error.CCompilerCrashed,
...@@ -91,7 +91,7 @@ pub fn detect(...@@ -91,7 +91,7 @@ pub fn detect(
91 libc.* = try LibCInstallation.findNative(arena, io, .{91 libc.* = try LibCInstallation.findNative(arena, io, .{
92 .verbose = true,92 .verbose = true,
93 .target = target,93 .target = target,
94 .env_map = env_map,94 .environ_map = environ_map,
95 });95 });
96 return detectFromInstallation(arena, target, libc);96 return detectFromInstallation(arena, target, libc);
97 }97 }
lib/std/zig/LibCInstallation.zig+20-20
...@@ -168,7 +168,7 @@ pub fn render(self: LibCInstallation, out: *std.Io.Writer) !void {...@@ -168,7 +168,7 @@ pub fn render(self: LibCInstallation, out: *std.Io.Writer) !void {
168168
169pub const FindNativeOptions = struct {169pub const FindNativeOptions = struct {
170 target: *const std.Target,170 target: *const std.Target,
171 env_map: *const Environ.Map,171 environ_map: *const Environ.Map,
172172
173 /// If enabled, will print human-friendly errors to stderr.173 /// If enabled, will print human-friendly errors to stderr.
174 verbose: bool = false,174 verbose: bool = false,
...@@ -193,7 +193,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib...@@ -193,7 +193,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
193 });193 });
194 return self;194 return self;
195 } else if (is_windows) {195 } 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) {
197 error.NotFound => return error.WindowsSdkNotFound,197 error.NotFound => return error.WindowsSdkNotFound,
198 error.PathTooLong => return error.WindowsSdkNotFound,198 error.PathTooLong => return error.WindowsSdkNotFound,
199 error.OutOfMemory => return error.OutOfMemory,199 error.OutOfMemory => return error.OutOfMemory,
...@@ -240,17 +240,17 @@ pub fn deinit(self: *LibCInstallation, allocator: Allocator) void {...@@ -240,17 +240,17 @@ pub fn deinit(self: *LibCInstallation, allocator: Allocator) void {
240240
241fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {241fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {
242 // Detect infinite loops.242 // Detect infinite loops.
243 var env_map = try args.env_map.clone(gpa);243 var environ_map = try args.environ_map.clone(gpa);
244 defer env_map.deinit();244 defer environ_map.deinit();
245 const skip_cc_env_var = if (env_map.get(inf_loop_env_key)) |phase| blk: {245 const skip_cc_env_var = if (environ_map.get(inf_loop_env_key)) |phase| blk: {
246 if (std.mem.eql(u8, phase, "1")) {246 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");
248 break :blk true;248 break :blk true;
249 } else {249 } else {
250 return error.ZigIsTheCCompiler;250 return error.ZigIsTheCCompiler;
251 }251 }
252 } else blk: {252 } else blk: {
253 try env_map.put(inf_loop_env_key, "1");253 try environ_map.put(inf_loop_env_key, "1");
254 break :blk false;254 break :blk false;
255 };255 };
256256
...@@ -259,7 +259,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar...@@ -259,7 +259,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar
259 var argv = std.array_list.Managed([]const u8).init(gpa);259 var argv = std.array_list.Managed([]const u8).init(gpa);
260 defer argv.deinit();260 defer argv.deinit();
261261
262 try appendCcExe(&argv, skip_cc_env_var, &env_map);262 try appendCcExe(&argv, skip_cc_env_var, &environ_map);
263 try argv.appendSlice(&.{263 try argv.appendSlice(&.{
264 "-E",264 "-E",
265 "-Wp,-v",265 "-Wp,-v",
...@@ -270,7 +270,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar...@@ -270,7 +270,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar
270 const run_res = std.process.run(gpa, io, .{270 const run_res = std.process.run(gpa, io, .{
271 .max_output_bytes = 1024 * 1024,271 .max_output_bytes = 1024 * 1024,
272 .argv = argv.items,272 .argv = argv.items,
273 .env_map = &env_map,273 .environ_map = &environ_map,
274 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path274 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path
275 // to their own executable, without even bothering to resolve PATH. This results in the message:275 // to their own executable, without even bothering to resolve PATH. This results in the message:
276 // error: unable to execute command: Executable "" doesn't exist!276 // error: unable to execute command: Executable "" doesn't exist!
...@@ -446,7 +446,7 @@ fn findNativeCrtDirWindows(...@@ -446,7 +446,7 @@ fn findNativeCrtDirWindows(
446446
447fn findNativeCrtDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {447fn findNativeCrtDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {
448 self.crt_dir = try ccPrintFileName(gpa, io, .{448 self.crt_dir = try ccPrintFileName(gpa, io, .{
449 .env_map = args.env_map,449 .environ_map = args.environ_map,
450 .search_basename = switch (args.target.os.tag) {450 .search_basename = switch (args.target.os.tag) {
451 .linux => if (args.target.abi.isAndroid()) "crtbegin_dynamic.o" else "crt1.o",451 .linux => if (args.target.abi.isAndroid()) "crtbegin_dynamic.o" else "crt1.o",
452 else => "crt1.o",452 else => "crt1.o",
...@@ -551,7 +551,7 @@ fn findNativeMsvcLibDir(...@@ -551,7 +551,7 @@ fn findNativeMsvcLibDir(
551}551}
552552
553pub const CCPrintFileNameOptions = struct {553pub const CCPrintFileNameOptions = struct {
554 env_map: *const Environ.Map,554 environ_map: *const Environ.Map,
555 search_basename: []const u8,555 search_basename: []const u8,
556 want_dirname: enum { full_path, only_dir },556 want_dirname: enum { full_path, only_dir },
557 verbose: bool = false,557 verbose: bool = false,
...@@ -560,17 +560,17 @@ pub const CCPrintFileNameOptions = struct {...@@ -560,17 +560,17 @@ pub const CCPrintFileNameOptions = struct {
560/// caller owns returned memory560/// caller owns returned memory
561fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {561fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {
562 // Detect infinite loops.562 // Detect infinite loops.
563 var env_map = try args.env_map.clone(gpa);563 var environ_map = try args.environ_map.clone(gpa);
564 defer env_map.deinit();564 defer environ_map.deinit();
565 const skip_cc_env_var = if (env_map.get(inf_loop_env_key)) |phase| blk: {565 const skip_cc_env_var = if (environ_map.get(inf_loop_env_key)) |phase| blk: {
566 if (std.mem.eql(u8, phase, "1")) {566 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");
568 break :blk true;568 break :blk true;
569 } else {569 } else {
570 return error.ZigIsTheCCompiler;570 return error.ZigIsTheCCompiler;
571 }571 }
572 } else blk: {572 } else blk: {
573 try env_map.put(inf_loop_env_key, "1");573 try environ_map.put(inf_loop_env_key, "1");
574 break :blk false;574 break :blk false;
575 };575 };
576576
...@@ -580,13 +580,13 @@ fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {...@@ -580,13 +580,13 @@ fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {
580 const arg1 = try std.fmt.allocPrint(gpa, "-print-file-name={s}", .{args.search_basename});580 const arg1 = try std.fmt.allocPrint(gpa, "-print-file-name={s}", .{args.search_basename});
581 defer gpa.free(arg1);581 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);
584 try argv.append(arg1);584 try argv.append(arg1);
585585
586 const run_res = std.process.run(gpa, io, .{586 const run_res = std.process.run(gpa, io, .{
587 .max_output_bytes = 1024 * 1024,587 .max_output_bytes = 1024 * 1024,
588 .argv = argv.items,588 .argv = argv.items,
589 .env_map = &env_map,589 .environ_map = &environ_map,
590 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path590 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path
591 // to their own executable, without even bothering to resolve PATH. This results in the message:591 // to their own executable, without even bothering to resolve PATH. This results in the message:
592 // error: unable to execute command: Executable "" doesn't exist!592 // error: unable to execute command: Executable "" doesn't exist!
...@@ -669,7 +669,7 @@ const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS";...@@ -669,7 +669,7 @@ const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS";
669fn appendCcExe(669fn appendCcExe(
670 args: *std.array_list.Managed([]const u8),670 args: *std.array_list.Managed([]const u8),
671 skip_cc_env_var: bool,671 skip_cc_env_var: bool,
672 env_map: *const Environ.Map,672 environ_map: *const Environ.Map,
673) !void {673) !void {
674 const default_cc_exe = if (is_windows) "cc.exe" else "cc";674 const default_cc_exe = if (is_windows) "cc.exe" else "cc";
675 try args.ensureUnusedCapacity(1);675 try args.ensureUnusedCapacity(1);
...@@ -677,7 +677,7 @@ fn appendCcExe(...@@ -677,7 +677,7 @@ fn appendCcExe(
677 args.appendAssumeCapacity(default_cc_exe);677 args.appendAssumeCapacity(default_cc_exe);
678 return;678 return;
679 }679 }
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 {
681 args.appendAssumeCapacity(default_cc_exe);681 args.appendAssumeCapacity(default_cc_exe);
682 return;682 return;
683 };683 };
lib/std/zig/WindowsSdk.zig+14-14
...@@ -29,7 +29,7 @@ pub fn find(...@@ -29,7 +29,7 @@ pub fn find(
29 gpa: Allocator,29 gpa: Allocator,
30 io: Io,30 io: Io,
31 arch: std.Target.Cpu.Arch,31 arch: std.Target.Cpu.Arch,
32 env_map: *const Environ.Map,32 environ_map: *const Environ.Map,
33) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk {33) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk {
34 if (builtin.os.tag != .windows) return error.NotFound;34 if (builtin.os.tag != .windows) return error.NotFound;
3535
...@@ -55,7 +55,7 @@ pub fn find(...@@ -55,7 +55,7 @@ pub fn find(
55 };55 };
56 errdefer if (windows81sdk) |*w| w.free(gpa);56 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) {
59 error.MsvcLibDirNotFound => null,59 error.MsvcLibDirNotFound => null,
60 error.OutOfMemory => return error.OutOfMemory,60 error.OutOfMemory => return error.OutOfMemory,
61 };61 };
...@@ -680,7 +680,7 @@ const MsvcLibDir = struct {...@@ -680,7 +680,7 @@ const MsvcLibDir = struct {
680 fn findInstancesDir(680 fn findInstancesDir(
681 gpa: Allocator,681 gpa: Allocator,
682 io: Io,682 io: Io,
683 env_map: *const Environ.Map,683 environ_map: *const Environ.Map,
684 ) error{ OutOfMemory, PathNotFound }!Dir {684 ) error{ OutOfMemory, PathNotFound }!Dir {
685 // First, try getting the packages cache path from the registry.685 // First, try getting the packages cache path from the registry.
686 // This only seems to exist when the path is different from the default.686 // This only seems to exist when the path is different from the default.
...@@ -701,7 +701,7 @@ const MsvcLibDir = struct {...@@ -701,7 +701,7 @@ const MsvcLibDir = struct {
701 // If that can't be found, fall back to manually appending701 // If that can't be found, fall back to manually appending
702 // `Microsoft\VisualStudio\Packages\_Instances` to %PROGRAMDATA%702 // `Microsoft\VisualStudio\Packages\_Instances` to %PROGRAMDATA%
703 method3: {703 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
706 if (!Dir.path.isAbsolute(program_data)) break :method3;706 if (!Dir.path.isAbsolute(program_data)) break :method3;
707707
...@@ -765,13 +765,13 @@ const MsvcLibDir = struct {...@@ -765,13 +765,13 @@ const MsvcLibDir = struct {
765 gpa: Allocator,765 gpa: Allocator,
766 io: Io,766 io: Io,
767 arch: std.Target.Cpu.Arch,767 arch: std.Target.Cpu.Arch,
768 env_map: *const Environ.Map,768 environ_map: *const Environ.Map,
769 ) error{ OutOfMemory, PathNotFound }![]const u8 {769 ) error{ OutOfMemory, PathNotFound }![]const u8 {
770 // Typically `%PROGRAMDATA%\Microsoft\VisualStudio\Packages\_Instances`770 // Typically `%PROGRAMDATA%\Microsoft\VisualStudio\Packages\_Instances`
771 // This will contain directories with names of instance IDs like 80a758ca,771 // This will contain directories with names of instance IDs like 80a758ca,
772 // which will contain `state.json` files that have the version and772 // which will contain `state.json` files that have the version and
773 // installation directory.773 // installation directory.
774 var instances_dir = try findInstancesDir(gpa, io, env_map);774 var instances_dir = try findInstancesDir(gpa, io, environ_map);
775 defer instances_dir.close(io);775 defer instances_dir.close(io);
776776
777 var state_subpath_buf: [Dir.max_name_bytes + 32]u8 = undefined;777 var state_subpath_buf: [Dir.max_name_bytes + 32]u8 = undefined;
...@@ -872,12 +872,12 @@ const MsvcLibDir = struct {...@@ -872,12 +872,12 @@ const MsvcLibDir = struct {
872 gpa: Allocator,872 gpa: Allocator,
873 io: Io,873 io: Io,
874 arch: std.Target.Cpu.Arch,874 arch: std.Target.Cpu.Arch,
875 env_map: *const Environ.Map,875 environ_map: *const Environ.Map,
876 ) error{ OutOfMemory, PathNotFound }![]const u8 {876 ) error{ OutOfMemory, PathNotFound }![]const u8 {
877877
878 // %localappdata%\Microsoft\VisualStudio\878 // %localappdata%\Microsoft\VisualStudio\
879 // %appdata%\Local\Microsoft\VisualStudio\879 // %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;
881 const visualstudio_folder_path = try Dir.path.join(gpa, &.{881 const visualstudio_folder_path = try Dir.path.join(gpa, &.{
882 local_app_data_path, "Microsoft\\VisualStudio\\",882 local_app_data_path, "Microsoft\\VisualStudio\\",
883 });883 });
...@@ -968,11 +968,11 @@ const MsvcLibDir = struct {...@@ -968,11 +968,11 @@ const MsvcLibDir = struct {
968 gpa: Allocator,968 gpa: Allocator,
969 io: Io,969 io: Io,
970 arch: std.Target.Cpu.Arch,970 arch: std.Target.Cpu.Arch,
971 env_map: *const Environ.Map,971 environ_map: *const Environ.Map,
972 ) error{ OutOfMemory, PathNotFound }![]const u8 {972 ) error{ OutOfMemory, PathNotFound }![]const u8 {
973 var base_path: std.array_list.Managed(u8) = base_path: {973 var base_path: std.array_list.Managed(u8) = base_path: {
974 try_env: {974 try_env: {
975 if (env_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| {975 if (environ_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| {
976 if (VS140COMNTOOLS.len < "C:\\Common7\\Tools".len) break :try_env;976 if (VS140COMNTOOLS.len < "C:\\Common7\\Tools".len) break :try_env;
977 if (!Dir.path.isAbsolute(VS140COMNTOOLS)) break :try_env;977 if (!Dir.path.isAbsolute(VS140COMNTOOLS)) break :try_env;
978 var list = std.array_list.Managed(u8).init(gpa);978 var list = std.array_list.Managed(u8).init(gpa);
...@@ -1046,13 +1046,13 @@ const MsvcLibDir = struct {...@@ -1046,13 +1046,13 @@ const MsvcLibDir = struct {
1046 gpa: Allocator,1046 gpa: Allocator,
1047 io: Io,1047 io: Io,
1048 arch: std.Target.Cpu.Arch,1048 arch: std.Target.Cpu.Arch,
1049 env_map: *const Environ.Map,1049 environ_map: *const Environ.Map,
1050 ) error{ OutOfMemory, MsvcLibDirNotFound }![]const u8 {1050 ) 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) {
1052 error.OutOfMemory => return error.OutOfMemory,1052 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) {
1054 error.OutOfMemory => return error.OutOfMemory,1054 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) {
1056 error.OutOfMemory => return error.OutOfMemory,1056 error.OutOfMemory => return error.OutOfMemory,
1057 error.PathNotFound => return error.MsvcLibDirNotFound,1057 error.PathNotFound => return error.MsvcLibDirNotFound,
1058 },1058 },
lib/std/zig/system/NativePaths.zig+8-8
...@@ -18,12 +18,12 @@ pub fn detect(...@@ -18,12 +18,12 @@ pub fn detect(
18 arena: Allocator,18 arena: Allocator,
19 io: Io,19 io: Io,
20 native_target: *const std.Target,20 native_target: *const std.Target,
21 env_map: *process.Environ.Map,21 environ_map: *process.Environ.Map,
22) !NativePaths {22) !NativePaths {
23 var self: NativePaths = .{ .arena = arena };23 var self: NativePaths = .{ .arena = arena };
24 var is_nix = false;24 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| {
27 is_nix = true;27 is_nix = true;
28 var it = mem.tokenizeScalar(u8, nix_cflags_compile, ' ');28 var it = mem.tokenizeScalar(u8, nix_cflags_compile, ' ');
29 while (true) {29 while (true) {
...@@ -49,7 +49,7 @@ pub fn detect(...@@ -49,7 +49,7 @@ pub fn detect(
49 }49 }
50 }50 }
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| {
53 is_nix = true;53 is_nix = true;
54 var it = mem.tokenizeScalar(u8, nix_ldflags, ' ');54 var it = mem.tokenizeScalar(u8, nix_ldflags, ' ');
55 while (true) {55 while (true) {
...@@ -78,7 +78,7 @@ pub fn detect(...@@ -78,7 +78,7 @@ pub fn detect(
78 }78 }
79 }79 }
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| {
82 is_nix = true;82 is_nix = true;
83 var it = mem.tokenizeScalar(u8, nix_cflags_link, ' ');83 var it = mem.tokenizeScalar(u8, nix_cflags_link, ' ');
84 while (true) {84 while (true) {
...@@ -121,7 +121,7 @@ pub fn detect(...@@ -121,7 +121,7 @@ pub fn detect(
121 }121 }
122122
123 // Check for homebrew paths123 // 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| {
125 try self.addLibDir(try std.fs.path.join(arena, &.{ prefix, "/lib" }));125 try self.addLibDir(try std.fs.path.join(arena, &.{ prefix, "/lib" }));
126 try self.addIncludeDir(try std.fs.path.join(arena, &.{ prefix, "/include" }));126 try self.addIncludeDir(try std.fs.path.join(arena, &.{ prefix, "/include" }));
127 }127 }
...@@ -177,21 +177,21 @@ pub fn detect(...@@ -177,21 +177,21 @@ pub fn detect(
177177
178 // Distros like guix don't use FHS, so they rely on environment178 // Distros like guix don't use FHS, so they rely on environment
179 // variables to search for headers and libraries.179 // 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| {
181 var it = mem.tokenizeScalar(u8, c_include_path, ':');181 var it = mem.tokenizeScalar(u8, c_include_path, ':');
182 while (it.next()) |dir| {182 while (it.next()) |dir| {
183 try self.addIncludeDir(dir);183 try self.addIncludeDir(dir);
184 }184 }
185 }185 }
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| {
188 var it = mem.tokenizeScalar(u8, cplus_include_path, ':');188 var it = mem.tokenizeScalar(u8, cplus_include_path, ':');
189 while (it.next()) |dir| {189 while (it.next()) |dir| {
190 try self.addIncludeDir(dir);190 try self.addIncludeDir(dir);
191 }191 }
192 }192 }
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| {
195 var it = mem.tokenizeScalar(u8, library_path, ':');195 var it = mem.tokenizeScalar(u8, library_path, ':');
196 while (it.next()) |dir| {196 while (it.next()) |dir| {
197 try self.addLibDir(dir);197 try self.addLibDir(dir);
src/Compilation.zig+4-4
...@@ -762,7 +762,7 @@ pub const Directories = struct {...@@ -762,7 +762,7 @@ pub const Directories = struct {
762 .wasi => void,762 .wasi => void,
763 else => []const u8,763 else => []const u8,
764 },764 },
765 env_map: *const std.process.Environ.Map,765 environ_map: *const std.process.Environ.Map,
766 ) Directories {766 ) Directories {
767 const wasi = builtin.target.os.tag == .wasi;767 const wasi = builtin.target.os.tag == .wasi;
768768
...@@ -781,7 +781,7 @@ pub const Directories = struct {...@@ -781,7 +781,7 @@ pub const Directories = struct {
781 const global_cache: Cache.Directory = d: {781 const global_cache: Cache.Directory = d: {
782 if (override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache");782 if (override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache");
783 if (wasi) break :d openWasiPreopen(wasi_preopens, "/cache");783 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| {
785 fatal("unable to resolve zig cache directory: {t}", .{err});785 fatal("unable to resolve zig cache directory: {t}", .{err});
786 };786 };
787 break :d openUnresolved(arena, io, cwd, path, .@"global cache");787 break :d openUnresolved(arena, io, cwd, path, .@"global cache");
...@@ -5713,7 +5713,7 @@ pub fn translateC(...@@ -5713,7 +5713,7 @@ pub fn translateC(
5713 translated_basename: []const u8,5713 translated_basename: []const u8,
5714 owner_mod: *Package.Module,5714 owner_mod: *Package.Module,
5715 prog_node: std.Progress.Node,5715 prog_node: std.Progress.Node,
5716 env_map: *const std.process.Environ.Map,5716 environ_map: *const std.process.Environ.Map,
5717) !CImportResult {5717) !CImportResult {
5718 dev.check(.translate_c_command);5718 dev.check(.translate_c_command);
57195719
...@@ -5783,7 +5783,7 @@ pub fn translateC(...@@ -5783,7 +5783,7 @@ pub fn translateC(
5783 }5783 }
57845784
5785 var stdout: []u8 = undefined;5785 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
5788 if (out_dep_path) |dep_file_path| add_deps: {5788 if (out_dep_path) |dep_file_path| add_deps: {
5789 if (comp.verbose_cimport) log.info("processing dep file at {s}", .{dep_file_path});5789 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(...@@ -102,25 +102,25 @@ pub fn findZigLibDirFromSelfExe(
102 return error.FileNotFound;102 return error.FileNotFound;
103}103}
104104
105pub fn resolveGlobalCacheDir(arena: Allocator, env_map: *const std.process.Environ.Map) ![]const u8 {105pub fn resolveGlobalCacheDir(arena: Allocator, environ_map: *const std.process.Environ.Map) ![]const u8 {
106 if (std.zig.EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map)) |value| return value;106 if (std.zig.EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map)) |value| return value;
107107
108 const app_name = "zig";108 const app_name = "zig";
109109
110 switch (builtin.os.tag) {110 switch (builtin.os.tag) {
111 .wasi => @compileError("on WASI the global cache dir must be resolved with preopens"),111 .wasi => @compileError("on WASI the global cache dir must be resolved with preopens"),
112 .windows => {112 .windows => {
113 const local_app_data_dir = std.zig.EnvVar.LOCALAPPDATA.get(env_map) orelse113 const local_app_data_dir = std.zig.EnvVar.LOCALAPPDATA.get(environ_map) orelse
114 return error.AppDataDirUnavailable;114 return error.AppDataDirUnavailable;
115 return Dir.path.join(arena, &.{ local_app_data_dir, app_name });115 return Dir.path.join(arena, &.{ local_app_data_dir, app_name });
116 },116 },
117 else => {117 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| {
119 if (cache_root.len > 0) {119 if (cache_root.len > 0) {
120 return Dir.path.join(arena, &.{ cache_root, app_name });120 return Dir.path.join(arena, &.{ cache_root, app_name });
121 }121 }
122 }122 }
123 if (std.zig.EnvVar.HOME.get(env_map)) |home| {123 if (std.zig.EnvVar.HOME.get(environ_map)) |home| {
124 if (home.len > 0) {124 if (home.len > 0) {
125 return Dir.path.join(arena, &.{ home, ".cache", app_name });125 return Dir.path.join(arena, &.{ home, ".cache", app_name });
126 }126 }
src/main.zig+80-80
...@@ -191,7 +191,7 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {...@@ -191,7 +191,7 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
191 fatal("expected command argument", .{});191 fatal("expected command argument", .{});
192 }192 }
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
196 Compilation.setMainThread();196 Compilation.setMainThread();
197197
...@@ -206,14 +206,14 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {...@@ -206,14 +206,14 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
206206
207 if (tracy.enable_allocation) {207 if (tracy.enable_allocation) {
208 var gpa_tracy = tracy.tracyAllocator(gpa);208 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);
210 }210 }
211211
212 if (native_os == .wasi) {212 if (native_os == .wasi) {
213 wasi_preopens = try fs.wasi.preopensAlloc(arena);213 wasi_preopens = try fs.wasi.preopensAlloc(arena);
214 }214 }
215215
216 return mainArgs(gpa, arena, io, args, &env_map);216 return mainArgs(gpa, arena, io, args, &environ_map);
217}217}
218218
219fn mainArgs(219fn mainArgs(
...@@ -221,9 +221,9 @@ fn mainArgs(...@@ -221,9 +221,9 @@ fn mainArgs(
221 arena: Allocator,221 arena: Allocator,
222 io: Io,222 io: Io,
223 args: []const [:0]const u8,223 args: []const [:0]const u8,
224 env_map: *process.Environ.Map,224 environ_map: *process.Environ.Map,
225) !void {225) !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)) {
227 dev.check(.cc_command);227 dev.check(.cc_command);
228 // In this case we have accidentally invoked ourselves as "the system C compiler"228 // In this case we have accidentally invoked ourselves as "the system C compiler"
229 // to figure out where libc is installed. This is essentially infinite recursion229 // to figure out where libc is installed. This is essentially infinite recursion
...@@ -233,7 +233,7 @@ fn mainArgs(...@@ -233,7 +233,7 @@ fn mainArgs(
233 // why we have this additional environment variable here to check.233 // why we have this additional environment variable here to check.
234234
235 const inf_loop_env_key: EnvVar = .ZIG_IS_TRYING_TO_NOT_CALL_ITSELF;235 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)) {
237 fatal("{s}", .{237 fatal("{s}", .{
238 "The compilation links against libc, but Zig is unable to provide a libc " ++238 "The compilation links against libc, but Zig is unable to provide a libc " ++
239 "for this operating system, and no --libc " ++239 "for this operating system, and no --libc " ++
...@@ -242,17 +242,17 @@ fn mainArgs(...@@ -242,17 +242,17 @@ fn mainArgs(
242 "compiler is `zig cc`, so no libc installation was found.",242 "compiler is `zig cc`, so no libc installation was found.",
243 });243 });
244 }244 }
245 try env_map.put(@tagName(inf_loop_env_key), "1");245 try environ_map.put(@tagName(inf_loop_env_key), "1");
246246
247 // Some programs such as CMake will strip the `cc` and subsequent args from the247 // Some programs such as CMake will strip the `cc` and subsequent args from the
248 // CC environment variable. We detect and support this scenario here because of248 // CC environment variable. We detect and support this scenario here because of
249 // the ZIG_IS_DETECTING_LIBC_PATHS environment variable.249 // the ZIG_IS_DETECTING_LIBC_PATHS environment variable.
250 if (mem.eql(u8, args[1], "cc")) {250 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 });
252 } else {252 } else {
253 const modified_args = try arena.dupe([]const u8, args);253 const modified_args = try arena.dupe([]const u8, args);
254 modified_args[0] = "cc";254 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 });
256 }256 }
257 }257 }
258258
...@@ -260,22 +260,22 @@ fn mainArgs(...@@ -260,22 +260,22 @@ fn mainArgs(
260 const cmd_args = args[2..];260 const cmd_args = args[2..];
261 if (mem.eql(u8, cmd, "build-exe")) {261 if (mem.eql(u8, cmd, "build-exe")) {
262 dev.check(.build_exe_command);262 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);
264 } else if (mem.eql(u8, cmd, "build-lib")) {264 } else if (mem.eql(u8, cmd, "build-lib")) {
265 dev.check(.build_lib_command);265 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);
267 } else if (mem.eql(u8, cmd, "build-obj")) {267 } else if (mem.eql(u8, cmd, "build-obj")) {
268 dev.check(.build_obj_command);268 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);
270 } else if (mem.eql(u8, cmd, "test")) {270 } else if (mem.eql(u8, cmd, "test")) {
271 dev.check(.test_command);271 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);
273 } else if (mem.eql(u8, cmd, "test-obj")) {273 } else if (mem.eql(u8, cmd, "test-obj")) {
274 dev.check(.test_command);274 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);
276 } else if (mem.eql(u8, cmd, "run")) {276 } else if (mem.eql(u8, cmd, "run")) {
277 dev.check(.run_command);277 dev.check(.run_command);
278 return buildOutputType(gpa, arena, io, args, .run, env_map);278 return buildOutputType(gpa, arena, io, args, .run, environ_map);
279 } else if (mem.eql(u8, cmd, "dlltool") or279 } else if (mem.eql(u8, cmd, "dlltool") or
280 mem.eql(u8, cmd, "ranlib") or280 mem.eql(u8, cmd, "ranlib") or
281 mem.eql(u8, cmd, "lib") or281 mem.eql(u8, cmd, "lib") or
...@@ -285,7 +285,7 @@ fn mainArgs(...@@ -285,7 +285,7 @@ fn mainArgs(
285 return process.exit(try llvmArMain(arena, args));285 return process.exit(try llvmArMain(arena, args));
286 } else if (mem.eql(u8, cmd, "build")) {286 } else if (mem.eql(u8, cmd, "build")) {
287 dev.check(.build_command);287 dev.check(.build_command);
288 return cmdBuild(gpa, arena, io, cmd_args, env_map);288 return cmdBuild(gpa, arena, io, cmd_args, environ_map);
289 } else if (mem.eql(u8, cmd, "clang") or289 } else if (mem.eql(u8, cmd, "clang") or
290 mem.eql(u8, cmd, "-cc1") or mem.eql(u8, cmd, "-cc1as"))290 mem.eql(u8, cmd, "-cc1") or mem.eql(u8, cmd, "-cc1as"))
291 {291 {
...@@ -299,16 +299,16 @@ fn mainArgs(...@@ -299,16 +299,16 @@ fn mainArgs(
299 return process.exit(try lldMain(arena, args, true));299 return process.exit(try lldMain(arena, args, true));
300 } else if (mem.eql(u8, cmd, "cc")) {300 } else if (mem.eql(u8, cmd, "cc")) {
301 dev.check(.cc_command);301 dev.check(.cc_command);
302 return buildOutputType(gpa, arena, io, args, .cc, env_map);302 return buildOutputType(gpa, arena, io, args, .cc, environ_map);
303 } else if (mem.eql(u8, cmd, "c++")) {303 } else if (mem.eql(u8, cmd, "c++")) {
304 dev.check(.cc_command);304 dev.check(.cc_command);
305 return buildOutputType(gpa, arena, io, args, .cpp, env_map);305 return buildOutputType(gpa, arena, io, args, .cpp, environ_map);
306 } else if (mem.eql(u8, cmd, "translate-c")) {306 } else if (mem.eql(u8, cmd, "translate-c")) {
307 dev.check(.translate_c_command);307 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);
309 } else if (mem.eql(u8, cmd, "rc")) {309 } else if (mem.eql(u8, cmd, "rc")) {
310 const use_server = cmd_args.len > 0 and std.mem.eql(u8, cmd_args[0], "--zig-integration");310 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, .{
312 .cmd_name = "resinator",312 .cmd_name = "resinator",
313 .root_src_path = "resinator/main.zig",313 .root_src_path = "resinator/main.zig",
314 .depend_on_aro = true,314 .depend_on_aro = true,
...@@ -319,20 +319,20 @@ fn mainArgs(...@@ -319,20 +319,20 @@ fn mainArgs(
319 dev.check(.fmt_command);319 dev.check(.fmt_command);
320 return @import("fmt.zig").run(gpa, arena, io, cmd_args);320 return @import("fmt.zig").run(gpa, arena, io, cmd_args);
321 } else if (mem.eql(u8, cmd, "objcopy")) {321 } 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, .{
323 .cmd_name = "objcopy",323 .cmd_name = "objcopy",
324 .root_src_path = "objcopy.zig",324 .root_src_path = "objcopy.zig",
325 });325 });
326 } else if (mem.eql(u8, cmd, "fetch")) {326 } 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);
328 } else if (mem.eql(u8, cmd, "libc")) {328 } 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, .{
330 .cmd_name = "libc",330 .cmd_name = "libc",
331 .root_src_path = "libc.zig",331 .root_src_path = "libc.zig",
332 .prepend_zig_lib_dir_path = true,332 .prepend_zig_lib_dir_path = true,
333 });333 });
334 } else if (mem.eql(u8, cmd, "std")) {334 } 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, .{
336 .cmd_name = "std",336 .cmd_name = "std",
337 .root_src_path = "std-docs.zig",337 .root_src_path = "std-docs.zig",
338 .prepend_zig_lib_dir_path = true,338 .prepend_zig_lib_dir_path = true,
...@@ -362,11 +362,11 @@ fn mainArgs(...@@ -362,11 +362,11 @@ fn mainArgs(
362 args,362 args,
363 if (native_os == .wasi) wasi_preopens,363 if (native_os == .wasi) wasi_preopens,
364 &host,364 &host,
365 env_map,365 environ_map,
366 );366 );
367 return stdout_writer.interface.flush();367 return stdout_writer.interface.flush();
368 } else if (mem.eql(u8, cmd, "reduce")) {368 } 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, .{
370 .cmd_name = "reduce",370 .cmd_name = "reduce",
371 .root_src_path = "reduce.zig",371 .root_src_path = "reduce.zig",
372 });372 });
...@@ -811,7 +811,7 @@ fn buildOutputType(...@@ -811,7 +811,7 @@ fn buildOutputType(
811 io: Io,811 io: Io,
812 all_args: []const []const u8,812 all_args: []const []const u8,
813 arg_mode: ArgMode,813 arg_mode: ArgMode,
814 env_map: *process.Environ.Map,814 environ_map: *process.Environ.Map,
815) !void {815) !void {
816 var provided_name: ?[]const u8 = null;816 var provided_name: ?[]const u8 = null;
817 var root_src_file: ?[]const u8 = null;817 var root_src_file: ?[]const u8 = null;
...@@ -824,9 +824,9 @@ fn buildOutputType(...@@ -824,9 +824,9 @@ fn buildOutputType(
824 var debug_compile_errors = false;824 var debug_compile_errors = false;
825 var debug_incremental = false;825 var debug_incremental = false;
826 var verbose_link = (native_os != .wasi or builtin.link_libc) and826 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);
828 var verbose_cc = (native_os != .wasi or builtin.link_libc) and828 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);
830 var verbose_air = false;830 var verbose_air = false;
831 var verbose_intern_pool = false;831 var verbose_intern_pool = false;
832 var verbose_generic_instances = false;832 var verbose_generic_instances = false;
...@@ -898,9 +898,9 @@ fn buildOutputType(...@@ -898,9 +898,9 @@ fn buildOutputType(
898 var runtime_args_start: ?usize = null;898 var runtime_args_start: ?usize = null;
899 var test_filters: std.ArrayList([]const u8) = .empty;899 var test_filters: std.ArrayList([]const u8) = .empty;
900 var test_runner_path: ?[]const u8 = null;900 var test_runner_path: ?[]const u8 = null;
901 var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_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(env_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(env_map);903 var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map);
904 var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no;904 var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no;
905 var subsystem: ?std.zig.Subsystem = null;905 var subsystem: ?std.zig.Subsystem = null;
906 var major_subsystem_version: ?u16 = null;906 var major_subsystem_version: ?u16 = null;
...@@ -997,7 +997,7 @@ fn buildOutputType(...@@ -997,7 +997,7 @@ fn buildOutputType(
997 .framework_dirs = .{},997 .framework_dirs = .{},
998 .rpath_list = .{},998 .rpath_list = .{},
999 .each_lib_rpath = null,999 .each_lib_rpath = null,
1000 .libc_paths_file = EnvVar.ZIG_LIBC.get(env_map),1000 .libc_paths_file = EnvVar.ZIG_LIBC.get(environ_map),
1001 .native_system_include_paths = &.{},1001 .native_system_include_paths = &.{},
1002 };1002 };
1003 defer create_module.link_inputs.deinit(gpa);1003 defer create_module.link_inputs.deinit(gpa);
...@@ -1006,9 +1006,9 @@ fn buildOutputType(...@@ -1006,9 +1006,9 @@ fn buildOutputType(
1006 // if set, default the color setting to .off or .on, respectively1006 // if set, default the color setting to .off or .on, respectively
1007 // explicit --color arguments will still override this setting.1007 // explicit --color arguments will still override this setting.
1008 // Disable color on WASI per https://github.com/WebAssembly/WASI/issues/1621008 // 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))
1010 .off1010 .off
1011 else if (EnvVar.CLICOLOR_FORCE.isSet(env_map))1011 else if (EnvVar.CLICOLOR_FORCE.isSet(environ_map))
1012 .on1012 .on
1013 else1013 else
1014 .auto;1014 .auto;
...@@ -3106,7 +3106,7 @@ fn buildOutputType(...@@ -3106,7 +3106,7 @@ fn buildOutputType(
3106 },3106 },
3107 if (native_os == .wasi) wasi_preopens,3107 if (native_os == .wasi) wasi_preopens,
3108 self_exe_path,3108 self_exe_path,
3109 env_map,3109 environ_map,
3110 );3110 );
3111 defer dirs.deinit(io);3111 defer dirs.deinit(io);
31123112
...@@ -3118,7 +3118,7 @@ fn buildOutputType(...@@ -3118,7 +3118,7 @@ fn buildOutputType(
3118 create_module.opts.emit_bin = emit_bin != .no;3118 create_module.opts.emit_bin = emit_bin != .no;
3119 create_module.opts.any_c_source_files = create_module.c_source_files.items.len != 0;3119 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);
3122 for (create_module.modules.keys(), create_module.modules.values()) |key, cli_mod| {3122 for (create_module.modules.keys(), create_module.modules.values()) |key, cli_mod| {
3123 if (cli_mod.resolved == null)3123 if (cli_mod.resolved == null)
3124 fatal("module '{s}' declared but not used", .{key});3124 fatal("module '{s}' declared but not used", .{key});
...@@ -3595,7 +3595,7 @@ fn buildOutputType(...@@ -3595,7 +3595,7 @@ fn buildOutputType(
3595 .global_cc_argv = try cc_argv.toOwnedSlice(arena),3595 .global_cc_argv = try cc_argv.toOwnedSlice(arena),
3596 .file_system_inputs = &file_system_inputs,3596 .file_system_inputs = &file_system_inputs,
3597 .debug_compiler_runtime_libs = debug_compiler_runtime_libs,3597 .debug_compiler_runtime_libs = debug_compiler_runtime_libs,
3598 .environ_map = env_map,3598 .environ_map = environ_map,
3599 }) catch |err| switch (err) {3599 }) catch |err| switch (err) {
3600 error.CreateFail => switch (create_diag) {3600 error.CreateFail => switch (create_diag) {
3601 .cross_libc_unavailable => {3601 .cross_libc_unavailable => {
...@@ -3659,7 +3659,7 @@ fn buildOutputType(...@@ -3659,7 +3659,7 @@ fn buildOutputType(
3659 arg_mode,3659 arg_mode,
3660 all_args,3660 all_args,
3661 runtime_args_start,3661 runtime_args_start,
3662 env_map,3662 environ_map,
3663 );3663 );
3664 return cleanExit(io);3664 return cleanExit(io);
3665 },3665 },
...@@ -3686,7 +3686,7 @@ fn buildOutputType(...@@ -3686,7 +3686,7 @@ fn buildOutputType(
3686 arg_mode,3686 arg_mode,
3687 all_args,3687 all_args,
3688 runtime_args_start,3688 runtime_args_start,
3689 env_map,3689 environ_map,
3690 );3690 );
3691 return cleanExit(io);3691 return cleanExit(io);
3692 },3692 },
...@@ -3699,7 +3699,7 @@ fn buildOutputType(...@@ -3699,7 +3699,7 @@ fn buildOutputType(
3699 defer root_prog_node.end();3699 defer root_prog_node.end();
37003700
3701 if (arg_mode == .translate_c) {3701 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);
3703 }3703 }
37043704
3705 updateModule(comp, color, root_prog_node) catch |err| switch (err) {3705 updateModule(comp, color, root_prog_node) catch |err| switch (err) {
...@@ -3767,7 +3767,7 @@ fn buildOutputType(...@@ -3767,7 +3767,7 @@ fn buildOutputType(
3767 all_args,3767 all_args,
3768 runtime_args_start,3768 runtime_args_start,
3769 create_module.resolved_options.link_libc,3769 create_module.resolved_options.link_libc,
3770 env_map,3770 environ_map,
3771 );3771 );
3772 }3772 }
37733773
...@@ -3823,7 +3823,7 @@ fn createModule(...@@ -3823,7 +3823,7 @@ fn createModule(
3823 index: usize,3823 index: usize,
3824 parent: ?*Package.Module,3824 parent: ?*Package.Module,
3825 color: std.zig.Color,3825 color: std.zig.Color,
3826 env_map: *process.Environ.Map,3826 environ_map: *process.Environ.Map,
3827) Allocator.Error!*Package.Module {3827) Allocator.Error!*Package.Module {
3828 const cli_mod = &create_module.modules.values()[index];3828 const cli_mod = &create_module.modules.values()[index];
3829 if (cli_mod.resolved) |m| return m;3829 if (cli_mod.resolved) |m| return m;
...@@ -4003,7 +4003,7 @@ fn createModule(...@@ -4003,7 +4003,7 @@ fn createModule(
4003 resolved_target.is_native_os and resolved_target.is_native_abi and4003 resolved_target.is_native_os and resolved_target.is_native_abi and
4004 create_module.want_native_include_dirs)4004 create_module.want_native_include_dirs)
4005 {4005 {
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|
4007 fatal("unable to detect native system paths: {t}", .{err});4007 fatal("unable to detect native system paths: {t}", .{err});
4008 for (paths.warnings.items) |warning| {4008 for (paths.warnings.items) |warning| {
4009 warn("{s}", .{warning});4009 warn("{s}", .{warning});
...@@ -4030,7 +4030,7 @@ fn createModule(...@@ -4030,7 +4030,7 @@ fn createModule(
4030 create_module.libc_installation = LibCInstallation.findNative(arena, io, .{4030 create_module.libc_installation = LibCInstallation.findNative(arena, io, .{
4031 .verbose = true,4031 .verbose = true,
4032 .target = target,4032 .target = target,
4033 .env_map = env_map,4033 .environ_map = environ_map,
4034 }) catch |err| {4034 }) catch |err| {
4035 fatal("unable to find native libc installation: {t}", .{err});4035 fatal("unable to find native libc installation: {t}", .{err});
4036 };4036 };
...@@ -4135,7 +4135,7 @@ fn createModule(...@@ -4135,7 +4135,7 @@ fn createModule(
4135 for (cli_mod.deps) |dep| {4135 for (cli_mod.deps) |dep| {
4136 const dep_index = create_module.modules.getIndex(dep.value) orelse4136 const dep_index = create_module.modules.getIndex(dep.value) orelse
4137 fatal("module '{s}' depends on non-existent module '{s}'", .{ name, dep.key });4137 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);
4139 try mod.deps.put(arena, dep.key, dep_mod);4139 try mod.deps.put(arena, dep.key, dep_mod);
4140 }4140 }
41414141
...@@ -4157,7 +4157,7 @@ fn serve(...@@ -4157,7 +4157,7 @@ fn serve(
4157 arg_mode: ArgMode,4157 arg_mode: ArgMode,
4158 all_args: []const []const u8,4158 all_args: []const []const u8,
4159 runtime_args_start: ?usize,4159 runtime_args_start: ?usize,
4160 env_map: *process.Environ.Map,4160 environ_map: *process.Environ.Map,
4161) !void {4161) !void {
4162 const gpa = comp.gpa;4162 const gpa = comp.gpa;
4163 const io = comp.io;4163 const io = comp.io;
...@@ -4205,7 +4205,7 @@ fn serve(...@@ -4205,7 +4205,7 @@ fn serve(
4205 defer arena_instance.deinit();4205 defer arena_instance.deinit();
4206 const arena = arena_instance.allocator();4206 const arena = arena_instance.allocator();
4207 var output: Compilation.CImportResult = undefined;4207 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);
4209 defer output.deinit(gpa);4209 defer output.deinit(gpa);
42104210
4211 if (file_system_inputs.items.len != 0) {4211 if (file_system_inputs.items.len != 0) {
...@@ -4405,7 +4405,7 @@ fn runOrTest(...@@ -4405,7 +4405,7 @@ fn runOrTest(
4405 all_args: []const []const u8,4405 all_args: []const []const u8,
4406 runtime_args_start: ?usize,4406 runtime_args_start: ?usize,
4407 link_libc: bool,4407 link_libc: bool,
4408 env_map: *process.Environ.Map,4408 environ_map: *process.Environ.Map,
4409) !void {4409) !void {
4410 const raw_emit_bin = comp.emit_bin orelse return;4410 const raw_emit_bin = comp.emit_bin orelse return;
4411 const exe_path = switch (comp.cache_use) {4411 const exe_path = switch (comp.cache_use) {
...@@ -4442,14 +4442,14 @@ fn runOrTest(...@@ -4442,14 +4442,14 @@ fn runOrTest(
4442 if (runtime_args_start) |i| {4442 if (runtime_args_start) |i| {
4443 try argv.appendSlice(all_args[i..]);4443 try argv.appendSlice(all_args[i..]);
4444 }4444 }
4445 try env_map.put("ZIG_EXE", self_exe_path);4445 try environ_map.put("ZIG_EXE", self_exe_path);
44464446
4447 // We do not execve for tests because if the test fails we want to print4447 // We do not execve for tests because if the test fails we want to print
4448 // the error message and invocation below.4448 // the error message and invocation below.
4449 if (process.can_replace and arg_mode == .run) {4449 if (process.can_replace and arg_mode == .run) {
4450 // process replacement releases the locks; no need to destroy the Compilation here.4450 // process replacement releases the locks; no need to destroy the Compilation here.
4451 _ = try io.lockStderr(&.{}, .no_color);4451 _ = 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 });
4453 io.unlockStderr();4453 io.unlockStderr();
4454 try warnAboutForeignBinaries(io, arena, arg_mode, target, link_libc);4454 try warnAboutForeignBinaries(io, arena, arg_mode, target, link_libc);
4455 const cmd = try std.mem.join(arena, " ", argv.items);4455 const cmd = try std.mem.join(arena, " ", argv.items);
...@@ -4471,7 +4471,7 @@ fn runOrTest(...@@ -4471,7 +4471,7 @@ fn runOrTest(
44714471
4472 var child = std.process.spawn(io, .{4472 var child = std.process.spawn(io, .{
4473 .argv = argv.items,4473 .argv = argv.items,
4474 .env_map = env_map,4474 .environ_map = environ_map,
4475 .stdin = .inherit,4475 .stdin = .inherit,
4476 .stdout = .inherit,4476 .stdout = .inherit,
4477 .stderr = .inherit,4477 .stderr = .inherit,
...@@ -4626,7 +4626,7 @@ fn cmdTranslateC(...@@ -4626,7 +4626,7 @@ fn cmdTranslateC(
4626 fancy_output: ?*Compilation.CImportResult,4626 fancy_output: ?*Compilation.CImportResult,
4627 file_system_inputs: ?*std.ArrayList(u8),4627 file_system_inputs: ?*std.ArrayList(u8),
4628 prog_node: std.Progress.Node,4628 prog_node: std.Progress.Node,
4629 env_map: *process.Environ.Map,4629 environ_map: *process.Environ.Map,
4630) !void {4630) !void {
4631 dev.check(.translate_c_command);4631 dev.check(.translate_c_command);
46324632
...@@ -4660,7 +4660,7 @@ fn cmdTranslateC(...@@ -4660,7 +4660,7 @@ fn cmdTranslateC(
4660 translated_basename,4660 translated_basename,
4661 comp.root_mod,4661 comp.root_mod,
4662 prog_node,4662 prog_node,
4663 env_map,4663 environ_map,
4664 );4664 );
46654665
4666 if (result.errors.errorMessageCount() != 0) {4666 if (result.errors.errorMessageCount() != 0) {
...@@ -4708,11 +4708,11 @@ pub fn translateC(...@@ -4708,11 +4708,11 @@ pub fn translateC(
4708 arena: Allocator,4708 arena: Allocator,
4709 io: Io,4709 io: Io,
4710 argv: []const []const u8,4710 argv: []const []const u8,
4711 env_map: *const process.Environ.Map,4711 environ_map: *const process.Environ.Map,
4712 prog_node: std.Progress.Node,4712 prog_node: std.Progress.Node,
4713 capture: ?*[]u8,4713 capture: ?*[]u8,
4714) !void {4714) !void {
4715 try jitCmd(gpa, arena, io, argv, env_map, .{4715 try jitCmd(gpa, arena, io, argv, environ_map, .{
4716 .cmd_name = "translate-c",4716 .cmd_name = "translate-c",
4717 .root_src_path = "translate-c/main.zig",4717 .root_src_path = "translate-c/main.zig",
4718 .depend_on_aro = true,4718 .depend_on_aro = true,
...@@ -4869,21 +4869,21 @@ test sanitizeExampleName {...@@ -4869,21 +4869,21 @@ test sanitizeExampleName {
4869 try std.testing.expectEqualStrings("test_project", try sanitizeExampleName(arena, "test project"));4869 try std.testing.expectEqualStrings("test_project", try sanitizeExampleName(arena, "test project"));
4870}4870}
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 {
4873 dev.check(.build_command);4873 dev.check(.build_command);
48744874
4875 var build_file: ?[]const u8 = null;4875 var build_file: ?[]const u8 = null;
4876 var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.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(env_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(env_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(env_map);4879 var override_build_runner: ?[]const u8 = EnvVar.ZIG_BUILD_RUNNER.get(environ_map);
4880 var child_argv = std.array_list.Managed([]const u8).init(arena);4880 var child_argv = std.array_list.Managed([]const u8).init(arena);
4881 var reference_trace: ?u32 = null;4881 var reference_trace: ?u32 = null;
4882 var debug_compile_errors = false;4882 var debug_compile_errors = false;
4883 var verbose_link = (native_os != .wasi or builtin.link_libc) and4883 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);
4885 var verbose_cc = (native_os != .wasi or builtin.link_libc) and4885 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);
4887 var verbose_air = false;4887 var verbose_air = false;
4888 var verbose_intern_pool = false;4888 var verbose_intern_pool = false;
4889 var verbose_generic_instances = false;4889 var verbose_generic_instances = false;
...@@ -5080,7 +5080,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,...@@ -5080,7 +5080,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
5080 }5080 }
50815081
5082 const work_around_btrfs_bug = native_os == .linux and5082 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);
5084 const root_prog_node = std.Progress.start(io, .{5084 const root_prog_node = std.Progress.start(io, .{
5085 .disable_printing = (color == .off),5085 .disable_printing = (color == .off),
5086 .root_name = "Compile Build Script",5086 .root_name = "Compile Build Script",
...@@ -5140,7 +5140,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,...@@ -5140,7 +5140,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
5140 } },5140 } },
5141 {},5141 {},
5142 self_exe_path,5142 self_exe_path,
5143 env_map,5143 environ_map,
5144 );5144 );
5145 defer dirs.deinit(io);5145 defer dirs.deinit(io);
51465146
...@@ -5243,7 +5243,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,...@@ -5243,7 +5243,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
5243 job_queue.read_only = true;5243 job_queue.read_only = true;
5244 cleanup_build_dir = job_queue.global_cache.handle;5244 cleanup_build_dir = job_queue.global_cache.handle;
5245 } else {5245 } else {
5246 try http_client.initDefaultProxies(arena, env_map);5246 try http_client.initDefaultProxies(arena, environ_map);
5247 }5247 }
52485248
5249 try job_queue.all_fetches.ensureUnusedCapacity(gpa, 1);5249 try job_queue.all_fetches.ensureUnusedCapacity(gpa, 1);
...@@ -5397,7 +5397,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,...@@ -5397,7 +5397,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
5397 .cache_mode = .whole,5397 .cache_mode = .whole,
5398 .reference_trace = reference_trace,5398 .reference_trace = reference_trace,
5399 .debug_compile_errors = debug_compile_errors,5399 .debug_compile_errors = debug_compile_errors,
5400 .environ_map = env_map,5400 .environ_map = environ_map,
5401 }) catch |err| switch (err) {5401 }) catch |err| switch (err) {
5402 error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}),5402 error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}),
5403 else => fatal("failed to create compilation: {s}", .{@errorName(err)}),5403 else => fatal("failed to create compilation: {s}", .{@errorName(err)}),
...@@ -5516,7 +5516,7 @@ fn jitCmd(...@@ -5516,7 +5516,7 @@ fn jitCmd(
5516 arena: Allocator,5516 arena: Allocator,
5517 io: Io,5517 io: Io,
5518 args: []const []const u8,5518 args: []const []const u8,
5519 env_map: *const process.Environ.Map,5519 environ_map: *const process.Environ.Map,
5520 options: JitCmdOptions,5520 options: JitCmdOptions,
5521) !void {5521) !void {
5522 dev.check(.jit_command);5522 dev.check(.jit_command);
...@@ -5538,13 +5538,13 @@ fn jitCmd(...@@ -5538,13 +5538,13 @@ fn jitCmd(
5538 const self_exe_path = process.executablePathAlloc(io, arena) catch |err|5538 const self_exe_path = process.executablePathAlloc(io, arena) catch |err|
5539 fatal("unable to find self exe path: {t}", .{err});5539 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))
5542 .Debug5542 .Debug
5543 else5543 else
5544 .ReleaseFast;5544 .ReleaseFast;
5545 const strip = optimize_mode != .Debug;5545 const strip = optimize_mode != .Debug;
5546 const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_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(env_map);5547 const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
55485548
5549 // This `init` calls `fatal` on error.5549 // This `init` calls `fatal` on error.
5550 var dirs: Compilation.Directories = .init(5550 var dirs: Compilation.Directories = .init(
...@@ -5555,7 +5555,7 @@ fn jitCmd(...@@ -5555,7 +5555,7 @@ fn jitCmd(
5555 .global,5555 .global,
5556 if (native_os == .wasi) wasi_preopens,5556 if (native_os == .wasi) wasi_preopens,
5557 self_exe_path,5557 self_exe_path,
5558 env_map,5558 environ_map,
5559 );5559 );
5560 defer dirs.deinit(io);5560 defer dirs.deinit(io);
55615561
...@@ -5629,7 +5629,7 @@ fn jitCmd(...@@ -5629,7 +5629,7 @@ fn jitCmd(
5629 .self_exe_path = self_exe_path,5629 .self_exe_path = self_exe_path,
5630 .thread_limit = thread_limit,5630 .thread_limit = thread_limit,
5631 .cache_mode = .whole,5631 .cache_mode = .whole,
5632 .environ_map = env_map,5632 .environ_map = environ_map,
5633 }) catch |err| switch (err) {5633 }) catch |err| switch (err) {
5634 error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}),5634 error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}),
5635 else => fatal("failed to create compilation: {s}", .{@errorName(err)}),5635 else => fatal("failed to create compilation: {s}", .{@errorName(err)}),
...@@ -5676,11 +5676,11 @@ fn jitCmd(...@@ -5676,11 +5676,11 @@ fn jitCmd(
5676 child_argv.appendSliceAssumeCapacity(args);5676 child_argv.appendSliceAssumeCapacity(args);
56775677
5678 if (process.can_replace and options.capture == null) {5678 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)) {
5680 const cmd = try std.mem.join(arena, " ", child_argv.items);5680 const cmd = try std.mem.join(arena, " ", child_argv.items);
5681 std.debug.print("{s}\n", .{cmd});5681 std.debug.print("{s}\n", .{cmd});
5682 }5682 }
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 });
5684 const cmd = try std.mem.join(arena, " ", child_argv.items);5684 const cmd = try std.mem.join(arena, " ", child_argv.items);
5685 fatal("the following command failed to execve with '{t}':\n{s}", .{ err, cmd });5685 fatal("the following command failed to execve with '{t}':\n{s}", .{ err, cmd });
5686 }5686 }
...@@ -6914,15 +6914,15 @@ fn cmdFetch(...@@ -6914,15 +6914,15 @@ fn cmdFetch(
6914 arena: Allocator,6914 arena: Allocator,
6915 io: Io,6915 io: Io,
6916 args: []const []const u8,6916 args: []const []const u8,
6917 env_map: *process.Environ.Map,6917 environ_map: *process.Environ.Map,
6918) !void {6918) !void {
6919 dev.check(.fetch_command);6919 dev.check(.fetch_command);
69206920
6921 const color: Color = .auto;6921 const color: Color = .auto;
6922 const work_around_btrfs_bug = native_os == .linux and6922 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);
6924 var opt_path_or_url: ?[]const u8 = null;6924 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);
6926 var debug_hash: bool = false;6926 var debug_hash: bool = false;
6927 var save: union(enum) {6927 var save: union(enum) {
6928 no,6928 no,
...@@ -6968,7 +6968,7 @@ fn cmdFetch(...@@ -6968,7 +6968,7 @@ fn cmdFetch(
6968 var http_client: std.http.Client = .{ .allocator = gpa, .io = io };6968 var http_client: std.http.Client = .{ .allocator = gpa, .io = io };
6969 defer http_client.deinit();6969 defer http_client.deinit();
69706970
6971 try http_client.initDefaultProxies(arena, env_map);6971 try http_client.initDefaultProxies(arena, environ_map);
69726972
6973 var root_prog_node = std.Progress.start(io, .{6973 var root_prog_node = std.Progress.start(io, .{
6974 .root_name = "Fetch",6974 .root_name = "Fetch",
...@@ -6976,7 +6976,7 @@ fn cmdFetch(...@@ -6976,7 +6976,7 @@ fn cmdFetch(
6976 defer root_prog_node.end();6976 defer root_prog_node.end();
69776977
6978 var global_cache_directory: Directory = l: {6978 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);
6980 break :l .{6980 break :l .{
6981 .handle = try Io.Dir.cwd().createDirPathOpen(io, p, .{}),6981 .handle = try Io.Dir.cwd().createDirPathOpen(io, p, .{}),
6982 .path = p,6982 .path = p,
src/print_env.zig+5-5
...@@ -19,10 +19,10 @@ pub fn cmdEnv(...@@ -19,10 +19,10 @@ pub fn cmdEnv(
19 else => void,19 else => void,
20 },20 },
21 host: *const std.Target,21 host: *const std.Target,
22 env_map: *std.process.Environ.Map,22 environ_map: *std.process.Environ.Map,
23) !void {23) !void {
24 const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_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(env_map);25 const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
2626
27 const self_exe_path = switch (builtin.target.os.tag) {27 const self_exe_path = switch (builtin.target.os.tag) {
28 .wasi => args[0],28 .wasi => args[0],
...@@ -39,7 +39,7 @@ pub fn cmdEnv(...@@ -39,7 +39,7 @@ pub fn cmdEnv(
39 .global,39 .global,
40 if (builtin.target.os.tag == .wasi) wasi_preopens,40 if (builtin.target.os.tag == .wasi) wasi_preopens,
41 if (builtin.target.os.tag != .wasi) self_exe_path,41 if (builtin.target.os.tag != .wasi) self_exe_path,
42 env_map,42 environ_map,
43 );43 );
44 defer dirs.deinit(io);44 defer dirs.deinit(io);
4545
...@@ -59,7 +59,7 @@ pub fn cmdEnv(...@@ -59,7 +59,7 @@ pub fn cmdEnv(
59 try root.field("target", triple, .{});59 try root.field("target", triple, .{});
60 var env = try root.beginStructField("env", .{});60 var env = try root.beginStructField("env", .{});
61 inline for (@typeInfo(EnvVar).@"enum".fields) |field| {61 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), .{});
63 }63 }
64 try env.end();64 try env.end();
65 try root.end();65 try root.end();
test/standalone/child_process/main.zig+3-3
...@@ -12,8 +12,8 @@ pub fn main(init: std.process.Init.Minimal) !void {...@@ -12,8 +12,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
12 const process_cwd_path = try std.process.getCwdAlloc(gpa);12 const process_cwd_path = try std.process.getCwdAlloc(gpa);
13 defer gpa.free(process_cwd_path);13 defer gpa.free(process_cwd_path);
1414
15 var env_map = try init.environ.createMap(gpa);15 var environ_map = try init.environ.createMap(gpa);
16 defer env_map.deinit();16 defer environ_map.deinit();
1717
18 var it = try init.args.iterateAllocator(gpa);18 var it = try init.args.iterateAllocator(gpa);
19 defer it.deinit();19 defer it.deinit();
...@@ -23,7 +23,7 @@ pub fn main(init: std.process.Init.Minimal) !void {...@@ -23,7 +23,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
23 const cwd_path = it.next() orelse break :child_path .{ child_path, false };23 const cwd_path = it.next() orelse break :child_path .{ child_path, false };
24 // If there is a third argument, it is the current CWD somewhere within the cache directory.24 // If there is a third argument, it is the current CWD somewhere within the cache directory.
25 // In that case, modify the child path in order to test spawning a path with a leading `..` component.25 // 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 };
27 };27 };
28 defer if (needs_free) gpa.free(child_path);28 defer if (needs_free) gpa.free(child_path);
2929
test/standalone/empty_env/main.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn main(init: std.process.Init) !void {3pub 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());
5}5}
test/standalone/env_vars/main.zig+14-14
...@@ -126,26 +126,26 @@ pub fn main(init: std.process.Init) !void {...@@ -126,26 +126,26 @@ pub fn main(init: std.process.Init) !void {
126126
127 // Environ.Map127 // Environ.Map
128 {128 {
129 var env_map = try environ.createMap(allocator);129 var environ_map = try environ.createMap(allocator);
130 defer env_map.deinit();130 defer environ_map.deinit();
131131
132 try std.testing.expectEqualSlices(u8, "123", env_map.get("FOO").?);132 try std.testing.expectEqualSlices(u8, "123", environ_map.get("FOO").?);
133 try std.testing.expectEqual(null, env_map.get("FO"));133 try std.testing.expectEqual(null, environ_map.get("FO"));
134 try std.testing.expectEqual(null, env_map.get("FOOO"));134 try std.testing.expectEqual(null, environ_map.get("FOOO"));
135 if (builtin.os.tag == .windows) {135 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").?);
137 }137 }
138 try std.testing.expectEqualSlices(u8, "ABC=123", env_map.get("EQUALS").?);138 try std.testing.expectEqualSlices(u8, "ABC=123", environ_map.get("EQUALS").?);
139 try std.testing.expectEqual(null, env_map.get("EQUALS=ABC"));139 try std.testing.expectEqual(null, environ_map.get("EQUALS=ABC"));
140 try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", env_map.get("КИРиллИЦА").?);140 try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", environ_map.get("КИРиллИЦА").?);
141 if (builtin.os.tag == .windows) {141 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("кирИЛЛица").?);
143 }143 }
144 try std.testing.expectEqualSlices(u8, "", env_map.get("NO_VALUE").?);144 try std.testing.expectEqualSlices(u8, "", environ_map.get("NO_VALUE").?);
145 try std.testing.expectEqual(null, env_map.get("NOT_SET"));145 try std.testing.expectEqual(null, environ_map.get("NOT_SET"));
146 if (builtin.os.tag == .windows) {146 if (builtin.os.tag == .windows) {
147 try std.testing.expectEqualSlices(u8, "hi", env_map.get("=HIDDEN").?);147 try std.testing.expectEqualSlices(u8, "hi", environ_map.get("=HIDDEN").?);
148 try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", env_map.get("INVALID_UTF16_\xed\xa0\x80").?);148 try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", environ_map.get("INVALID_UTF16_\xed\xa0\x80").?);
149 }149 }
150 }150 }
151}151}
test/standalone/self_exe_symlink/create-symlink.zig+1-1
...@@ -12,7 +12,7 @@ pub fn main(init: std.process.Init) !void {...@@ -12,7 +12,7 @@ pub fn main(init: std.process.Init) !void {
12 const cwd = try std.process.getCwdAlloc(init.arena.allocator());12 const cwd = try std.process.getCwdAlloc(init.arena.allocator());
1313
14 // If `exe_path` is relative to our cwd, we need to convert it to be relative to the dirname of `symlink_path`.14 // 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);
16 defer gpa.free(exe_rel_path);16 defer gpa.free(exe_rel_path);
1717
18 try std.Io.Dir.cwd().symLink(io, exe_rel_path, symlink_path, .{});18 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...@@ -94,7 +94,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8
94 const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");94 const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");
9595
96 const result = try std.process.run(gpa, io, .{96 const result = try std.process.run(gpa, io, .{
97 .env_map = env,97 .environ_map = env,
98 .argv = argv,98 .argv = argv,
99 });99 });
100 defer gpa.free(result.stdout);100 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...@@ -141,7 +141,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8
141 const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");141 const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");
142142
143 const result = try std.process.run(gpa, io, .{143 const result = try std.process.run(gpa, io, .{
144 .env_map = env,144 .environ_map = env,
145 .argv = argv,145 .argv = argv,
146 });146 });
147 defer gpa.free(result.stdout);147 defer gpa.free(result.stdout);
test/standalone/windows_paths/test.zig+2-2
...@@ -96,12 +96,12 @@ fn checkRelative(...@@ -96,12 +96,12 @@ fn checkRelative(
96 expected_stdout: []const u8,96 expected_stdout: []const u8,
97 argv: []const []const u8,97 argv: []const []const u8,
98 cwd: ?[]const u8,98 cwd: ?[]const u8,
99 env_map: ?*const std.process.Environ.Map,99 environ_map: ?*const std.process.Environ.Map,
100) !void {100) !void {
101 const result = try std.process.run(allocator, io, .{101 const result = try std.process.run(allocator, io, .{
102 .argv = argv,102 .argv = argv,
103 .cwd = cwd,103 .cwd = cwd,
104 .env_map = env_map,104 .environ_map = environ_map,
105 });105 });
106 defer allocator.free(result.stdout);106 defer allocator.free(result.stdout);
107 defer allocator.free(result.stderr);107 defer allocator.free(result.stderr);
tools/doctest.zig+19-19
...@@ -32,10 +32,10 @@ const usage =...@@ -32,10 +32,10 @@ const usage =
32pub fn main(init: std.process.Init) !void {32pub fn main(init: std.process.Init) !void {
33 const arena = init.arena.allocator();33 const arena = init.arena.allocator();
34 const io = init.io;34 const io = init.io;
35 const env_map = init.env_map;35 const environ_map = init.environ_map;
36 const cwd_path = try std.process.getCwdAlloc(arena);36 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
40 var args_it = try init.minimal.args.iterateAllocator(arena);40 var args_it = try init.minimal.args.iterateAllocator(arena);
41 if (!args_it.skip()) fatal("missing argv[0]", .{});41 if (!args_it.skip()) fatal("missing argv[0]", .{});
...@@ -101,13 +101,13 @@ pub fn main(init: std.process.Init) !void {...@@ -101,13 +101,13 @@ pub fn main(init: std.process.Init) !void {
101 out,101 out,
102 code,102 code,
103 tmp_dir_path,103 tmp_dir_path,
104 try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_path),104 try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_path),
105 try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, input_path),105 try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, input_path),
106 if (opt_zig_lib_dir) |zig_lib_dir|106 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)
108 else108 else
109 null,109 null,
110 env_map,110 environ_map,
111 );111 );
112112
113 try out_file_writer.end();113 try out_file_writer.end();
...@@ -126,7 +126,7 @@ fn printOutput(...@@ -126,7 +126,7 @@ fn printOutput(
126 input_path: []const u8,126 input_path: []const u8,
127 /// Relative to `tmp_dir_path`.127 /// Relative to `tmp_dir_path`.
128 opt_zig_lib_dir: ?[]const u8,128 opt_zig_lib_dir: ?[]const u8,
129 env_map: *const process.Environ.Map,129 environ_map: *const process.Environ.Map,
130) !void {130) !void {
131 const host = try std.zig.system.resolveTargetQuery(io, .{});131 const host = try std.zig.system.resolveTargetQuery(io, .{});
132 const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch);132 const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch);
...@@ -199,7 +199,7 @@ fn printOutput(...@@ -199,7 +199,7 @@ fn printOutput(
199 const result = try process.run(arena, io, .{199 const result = try process.run(arena, io, .{
200 .argv = build_args.items,200 .argv = build_args.items,
201 .cwd = tmp_dir_path,201 .cwd = tmp_dir_path,
202 .env_map = env_map,202 .environ_map = environ_map,
203 .max_output_bytes = max_doc_file_size,203 .max_output_bytes = max_doc_file_size,
204 });204 });
205 switch (result.term) {205 switch (result.term) {
...@@ -221,7 +221,7 @@ fn printOutput(...@@ -221,7 +221,7 @@ fn printOutput(
221 try shell_out.writeAll(colored_stderr);221 try shell_out.writeAll(colored_stderr);
222 break :code_block;222 break :code_block;
223 }223 }
224 const exec_result = run(arena, io, env_map, tmp_dir_path, build_args.items) catch224 const exec_result = run(arena, io, environ_map, tmp_dir_path, build_args.items) catch
225 fatal("example failed to compile", .{});225 fatal("example failed to compile", .{});
226226
227 if (code.verbose_cimport) {227 if (code.verbose_cimport) {
...@@ -254,7 +254,7 @@ fn printOutput(...@@ -254,7 +254,7 @@ fn printOutput(
254 const result = if (expected_outcome == .fail) blk: {254 const result = if (expected_outcome == .fail) blk: {
255 const result = try process.run(arena, io, .{255 const result = try process.run(arena, io, .{
256 .argv = run_args,256 .argv = run_args,
257 .env_map = env_map,257 .environ_map = environ_map,
258 .cwd = tmp_dir_path,258 .cwd = tmp_dir_path,
259 .max_output_bytes = max_doc_file_size,259 .max_output_bytes = max_doc_file_size,
260 });260 });
...@@ -271,7 +271,7 @@ fn printOutput(...@@ -271,7 +271,7 @@ fn printOutput(
271 }271 }
272 break :blk result;272 break :blk result;
273 } else blk: {273 } else blk: {
274 break :blk run(arena, io, env_map, tmp_dir_path, run_args) catch274 break :blk run(arena, io, environ_map, tmp_dir_path, run_args) catch
275 fatal("example crashed", .{});275 fatal("example crashed", .{});
276 };276 };
277277
...@@ -340,7 +340,7 @@ fn printOutput(...@@ -340,7 +340,7 @@ fn printOutput(
340 }340 }
341 }341 }
342342
343 const result = run(arena, io, env_map, tmp_dir_path, test_args.items) catch343 const result = run(arena, io, environ_map, tmp_dir_path, test_args.items) catch
344 fatal("test failed", .{});344 fatal("test failed", .{});
345 const escaped_stderr = try escapeHtml(arena, result.stderr);345 const escaped_stderr = try escapeHtml(arena, result.stderr);
346 const escaped_stdout = try escapeHtml(arena, result.stdout);346 const escaped_stdout = try escapeHtml(arena, result.stdout);
...@@ -373,7 +373,7 @@ fn printOutput(...@@ -373,7 +373,7 @@ fn printOutput(
373 }373 }
374 const result = try process.run(arena, io, .{374 const result = try process.run(arena, io, .{
375 .argv = test_args.items,375 .argv = test_args.items,
376 .env_map = env_map,376 .environ_map = environ_map,
377 .cwd = tmp_dir_path,377 .cwd = tmp_dir_path,
378 .max_output_bytes = max_doc_file_size,378 .max_output_bytes = max_doc_file_size,
379 });379 });
...@@ -429,7 +429,7 @@ fn printOutput(...@@ -429,7 +429,7 @@ fn printOutput(
429429
430 const result = try process.run(arena, io, .{430 const result = try process.run(arena, io, .{
431 .argv = test_args.items,431 .argv = test_args.items,
432 .env_map = env_map,432 .environ_map = environ_map,
433 .cwd = tmp_dir_path,433 .cwd = tmp_dir_path,
434 .max_output_bytes = max_doc_file_size,434 .max_output_bytes = max_doc_file_size,
435 });435 });
...@@ -505,7 +505,7 @@ fn printOutput(...@@ -505,7 +505,7 @@ fn printOutput(
505 if (maybe_error_match) |error_match| {505 if (maybe_error_match) |error_match| {
506 const result = try process.run(arena, io, .{506 const result = try process.run(arena, io, .{
507 .argv = build_args.items,507 .argv = build_args.items,
508 .env_map = env_map,508 .environ_map = environ_map,
509 .cwd = tmp_dir_path,509 .cwd = tmp_dir_path,
510 .max_output_bytes = max_doc_file_size,510 .max_output_bytes = max_doc_file_size,
511 });511 });
...@@ -531,7 +531,7 @@ fn printOutput(...@@ -531,7 +531,7 @@ fn printOutput(
531 const colored_stderr = try termColor(arena, escaped_stderr);531 const colored_stderr = try termColor(arena, escaped_stderr);
532 try shell_out.print("\n{s} ", .{colored_stderr});532 try shell_out.print("\n{s} ", .{colored_stderr});
533 } else {533 } 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", .{});
535 }535 }
536 try shell_out.writeAll("\n");536 try shell_out.writeAll("\n");
537 },537 },
...@@ -590,7 +590,7 @@ fn printOutput(...@@ -590,7 +590,7 @@ fn printOutput(
590 try test_args.append(option);590 try test_args.append(option);
591 try shell_out.print("{s} ", .{option});591 try shell_out.print("{s} ", .{option});
592 }592 }
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", .{});
594 const escaped_stderr = try escapeHtml(arena, result.stderr);594 const escaped_stderr = try escapeHtml(arena, result.stderr);
595 const escaped_stdout = try escapeHtml(arena, result.stdout);595 const escaped_stdout = try escapeHtml(arena, result.stdout);
596 try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout });596 try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout });
...@@ -1123,13 +1123,13 @@ fn in(slice: []const u8, number: u8) bool {...@@ -1123,13 +1123,13 @@ fn in(slice: []const u8, number: u8) bool {
1123fn run(1123fn run(
1124 allocator: Allocator,1124 allocator: Allocator,
1125 io: Io,1125 io: Io,
1126 env_map: *const process.Environ.Map,1126 environ_map: *const process.Environ.Map,
1127 cwd: []const u8,1127 cwd: []const u8,
1128 args: []const []const u8,1128 args: []const []const u8,
1129) !process.RunResult {1129) !process.RunResult {
1130 const result = try process.run(allocator, io, .{1130 const result = try process.run(allocator, io, .{
1131 .argv = args,1131 .argv = args,
1132 .env_map = env_map,1132 .environ_map = environ_map,
1133 .cwd = cwd,1133 .cwd = cwd,
1134 .max_output_bytes = max_doc_file_size,1134 .max_output_bytes = max_doc_file_size,
1135 });1135 });
tools/incr-check.zig+4-4
...@@ -31,7 +31,7 @@ pub fn main(init: std.process.Init) !void {...@@ -31,7 +31,7 @@ pub fn main(init: std.process.Init) !void {
31 const fatal = std.process.fatal;31 const fatal = std.process.fatal;
32 const arena = init.arena.allocator();32 const arena = init.arena.allocator();
33 const io = init.io;33 const io = init.io;
34 const env_map = init.env_map;34 const environ_map = init.environ_map;
35 const cwd_path = try std.process.getCwdAlloc(arena);35 const cwd_path = try std.process.getCwdAlloc(arena);
3636
37 var opt_zig_exe: ?[]const u8 = null;37 var opt_zig_exe: ?[]const u8 = null;
...@@ -113,9 +113,9 @@ pub fn main(init: std.process.Init) !void {...@@ -113,9 +113,9 @@ pub fn main(init: std.process.Init) !void {
113 }113 }
114114
115 // Convert paths to be relative to the cwd of the subprocess.115 // 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);
117 const opt_resolved_lib_dir = if (opt_lib_dir) |lib_dir|117 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)
119 else119 else
120 null;120 null;
121121
...@@ -176,7 +176,7 @@ pub fn main(init: std.process.Init) !void {...@@ -176,7 +176,7 @@ pub fn main(init: std.process.Init) !void {
176 var cc_child_args: std.ArrayList([]const u8) = .empty;176 var cc_child_args: std.ArrayList([]const u8) = .empty;
177 if (target.backend == .cbe) {177 if (target.backend == .cbe) {
178 const resolved_cc_zig_exe = if (opt_cc_zig) |cc_zig_exe|178 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)
180 else180 else
181 resolved_zig_exe;181 resolved_zig_exe;
182182
tools/process_headers.zig+2-2
...@@ -132,7 +132,7 @@ pub fn main(init: std.process.Init) !void {...@@ -132,7 +132,7 @@ pub fn main(init: std.process.Init) !void {
132 const io = init.io;132 const io = init.io;
133 const args = try init.minimal.args.toSlice(arena);133 const args = try init.minimal.args.toSlice(arena);
134 const cwd_path = try std.process.getCwdAlloc(arena);134 const cwd_path = try std.process.getCwdAlloc(arena);
135 const env_map = init.env_map;135 const environ_map = init.environ_map;
136136
137 var search_paths = std.array_list.Managed([]const u8).init(arena);137 var search_paths = std.array_list.Managed([]const u8).init(arena);
138 var opt_out_dir: ?[]const u8 = null;138 var opt_out_dir: ?[]const u8 = null;
...@@ -256,7 +256,7 @@ pub fn main(init: std.process.Init) !void {...@@ -256,7 +256,7 @@ pub fn main(init: std.process.Init) !void {
256 switch (entry.kind) {256 switch (entry.kind) {
257 .directory => try dir_stack.append(full_path),257 .directory => try dir_stack.append(full_path),
258 .file, .sym_link => {258 .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);
260 const max_size = 2 * 1024 * 1024 * 1024;260 const max_size = 2 * 1024 * 1024 * 1024;
261 const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size));261 const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size));
262 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");262 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 {...@@ -145,7 +145,7 @@ pub fn main(init: std.process.Init) !void {
145 const arena = init.arena.allocator();145 const arena = init.arena.allocator();
146 const io = init.io;146 const io = init.io;
147 const args = try init.minimal.args.toSlice(arena);147 const args = try init.minimal.args.toSlice(arena);
148 const env_map = init.env_map;148 const environ_map = init.environ_map;
149 const cwd = try std.process.getCwdAlloc(arena);149 const cwd = try std.process.getCwdAlloc(arena);
150150
151 var search_paths = std.array_list.Managed([]const u8).init(arena);151 var search_paths = std.array_list.Managed([]const u8).init(arena);
...@@ -209,7 +209,7 @@ pub fn main(init: std.process.Init) !void {...@@ -209,7 +209,7 @@ pub fn main(init: std.process.Init) !void {
209 switch (entry.kind) {209 switch (entry.kind) {
210 .directory => try dir_stack.append(full_path),210 .directory => try dir_stack.append(full_path),
211 .file => {211 .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);
213 const max_size = 2 * 1024 * 1024 * 1024;213 const max_size = 2 * 1024 * 1024 * 1024;
214 const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size));214 const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size));
215 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");215 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");