authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 13:23:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:36-07:00
log1aa65d094ec737a140d7ab60e1b2af62144edd6a
tree92fb8756cf3ca97dd1ae55e3fe0b8cdf2a55ba2f
parent9eb85c4e5eb65ae987463af33ca24225f12b3a8b

Maker.Step.Run: leak into global arena less

There are still some uses: - fuzzing - generated paths (will require adjusting all step logic) - Step.result_stderr

2 files changed, 70 insertions(+), 80 deletions(-)

lib/compiler/Maker/Step.zig+1-1
......@@ -73,7 +73,7 @@ comptime {
7373 // Common cache line size is 128. This check prevents accidentally crossing
7474 // an additional cache line. In the future it might be nice to try to fit
7575 // this struct in 128 bytes or less.
76 assert(@sizeOf(@This()) <= 128 * 4);
76 assert(@sizeOf(@This()) <= 128 * 3);
7777}
7878
7979pub const Extended = union(enum) {
lib/compiler/Maker/Step/Run.zig+69-79
......@@ -13,6 +13,7 @@ const assert = std.debug.assert;
1313const mem = std.mem;
1414const process = std.process;
1515const allocPrint = std.fmt.allocPrint;
16const Allocator = std.mem.Allocator;
1617
1718const Step = @import("../Step.zig");
1819const Maker = @import("../../Maker.zig");
......@@ -28,13 +29,6 @@ cached_test_metadata: ?CachedTestMetadata = null,
2829/// executable that contains fuzz tests.
2930rebuilt_executable: ?Path = null,
3031
31/// Persisted to reuse memory on subsequent calls to `make`.
32argv: std.ArrayList([]const u8) = .empty,
33/// Persisted to reuse memory on subsequent calls to `make`.
34output_placeholders: std.ArrayList(IndexedOutput) = .empty,
35/// Persisted to reuse memory on subsequent calls to `make`.
36environ_map: std.process.Environ.Map = .{ .array_hash_map = .empty, .allocator = undefined },
37
3832pub fn make(
3933 run: *Run,
4034 run_index: Configuration.Step.Index,
......@@ -45,16 +39,17 @@ pub fn make(
4539 const gpa = maker.gpa;
4640 const step = maker.stepByIndex(run_index);
4741 const io = graph.io;
48 const arena = graph.arena; // TODO don't leak into the process arena
4942 const conf = &maker.scanned_config.configuration;
5043 const conf_step = run_index.ptr(conf);
5144 const conf_run = conf_step.extended.get(conf.extra).run;
52 const argv_list = &run.argv;
53 const output_placeholders = &run.output_placeholders;
5445 const cache_root = graph.local_cache_root;
5546
56 argv_list.clearRetainingCapacity();
57 output_placeholders.clearRetainingCapacity();
47 var arena_allocator: std.heap.ArenaAllocator = .init(gpa);
48 defer arena_allocator.deinit();
49 const arena = arena_allocator.allocator();
50
51 var argv_list: std.ArrayList([]const u8) = .empty;
52 var output_placeholders: std.ArrayList(IndexedOutput) = .empty;
5853
5954 var man = graph.cache.obtain();
6055 defer man.deinit();
......@@ -89,7 +84,7 @@ pub fn make(
8984 const suffix = if (arg.suffix.value) |p| p.slice(conf) else "";
9085 const file_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index);
9186 argv_list.appendAssumeCapacity(try mem.concat(arena, u8, &.{
92 prefix, try convertPathArg(run_index, maker, file_path), suffix,
87 prefix, try convertPathArg(arena, run_index, maker, file_path), suffix,
9388 }));
9489 man.hash.addBytesZ(prefix);
9590 man.hash.addBytesZ(suffix);
......@@ -100,7 +95,7 @@ pub fn make(
10095 const suffix = if (arg.suffix.value) |p| p.slice(conf) else "";
10196 const file_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index);
10297 const resolved_arg = try mem.concat(arena, u8, &.{
103 prefix, try convertPathArg(run_index, maker, file_path), suffix,
98 prefix, try convertPathArg(arena, run_index, maker, file_path), suffix,
10499 });
105100 argv_list.appendAssumeCapacity(resolved_arg);
106101 man.hash.addBytes(resolved_arg);
......@@ -144,7 +139,7 @@ pub fn make(
144139 const file_path = producer_make_comp.installed_path orelse maker.generatedPath(producer.generated_bin.value.?).*;
145140
146141 argv_list.appendAssumeCapacity(try mem.concat(arena, u8, &.{
147 prefix, try convertPathArg(run_index, maker, file_path), suffix,
142 prefix, try convertPathArg(arena, run_index, maker, file_path), suffix,
148143 }));
149144
150145 _ = try man.addFilePath(file_path, null);
......@@ -183,7 +178,7 @@ pub fn make(
183178
184179 man.hash.add(conf_run.flags.test_runner_mode);
185180 if (conf_run.flags.test_runner_mode) {
186 const cache_dir_string = try convertPathArg(run_index, maker, .{ .root_dir = cache_root });
181 const cache_dir_string = try convertPathArg(arena, run_index, maker, .{ .root_dir = cache_root });
187182
188183 try argv_list.ensureUnusedCapacity(gpa, 3);
189184 argv_list.appendAssumeCapacity(try allocPrint(arena, "--cache-dir={s}", .{cache_dir_string}));
......@@ -259,8 +254,8 @@ pub fn make(
259254 const digest = if (has_side_effects) man.hash.final() else man.final();
260255 const output_dir_path = "o" ++ Dir.path.sep_str ++ &digest;
261256 try populateGeneratedStdIo(maker, &conf_run, cache_root, &digest);
262 try populateGeneratedPathsCreateDirs(run, run_index, maker, output_dir_path);
263 try runCommand(run, run_index, maker, progress_node, argv_list.items, has_side_effects, output_dir_path, null);
257 try populateGeneratedPathsCreateDirs(arena, run_index, maker, output_dir_path, output_placeholders.items, argv_list.items);
258 try runCommand(arena, run, run_index, maker, progress_node, argv_list.items, has_side_effects, output_dir_path, null);
264259 if (!has_side_effects) try step.writeManifestAndWatch(maker, &man);
265260 return;
266261 }
......@@ -270,8 +265,8 @@ pub fn make(
270265 io.random(@ptrCast(&rand_int));
271266 const tmp_dir_path = "tmp" ++ Dir.path.sep_str ++ std.fmt.hex(rand_int);
272267
273 try populateGeneratedPathsCreateDirs(run, run_index, maker, tmp_dir_path);
274 try runCommand(run, run_index, maker, progress_node, argv_list.items, has_side_effects, tmp_dir_path, null);
268 try populateGeneratedPathsCreateDirs(arena, run_index, maker, tmp_dir_path, output_placeholders.items, argv_list.items);
269 try runCommand(arena, run, run_index, maker, progress_node, argv_list.items, has_side_effects, tmp_dir_path, null);
275270
276271 for (output_placeholders.items) |placeholder| {
277272 const arg = placeholder.arg_index.get(conf);
......@@ -341,6 +336,7 @@ pub fn make(
341336/// * A test (or a response from the test runner) times out
342337/// * The wait fails, indicating the child closed stdout and stderr
343338fn waitZigTest(
339 arena: Allocator,
344340 run: *Run,
345341 run_index: Configuration.Step.Index,
346342 maker: *Maker,
......@@ -363,7 +359,6 @@ fn waitZigTest(
363359 const graph = maker.graph;
364360 const gpa = maker.gpa;
365361 const io = graph.io;
366 const arena = graph.arena; // TODO don't leak into the process arena
367362 const step = maker.stepByIndex(run_index);
368363
369364 var sub_prog_node: ?std.Progress.Node = null;
......@@ -715,7 +710,7 @@ const FuzzTestRunner = struct {
715710 }
716711 }
717712
718 fn listen(f: *FuzzTestRunner) !void {
713 fn listen(f: *FuzzTestRunner, arena: Allocator) !void {
719714 const maker = f.ctx.fuzz.maker;
720715 const graph = maker.graph;
721716 const io = graph.io;
......@@ -739,7 +734,7 @@ const FuzzTestRunner = struct {
739734 else => |read_e| return read_e,
740735 }),
741736 2 => try f.completeStderrRead(id, result.file_read_streaming catch |e| switch (e) {
742 error.EndOfStream => return f.instanceEos(id),
737 error.EndOfStream => return f.instanceEos(arena, id),
743738 else => |read_e| return read_e,
744739 }),
745740 else => unreachable,
......@@ -901,7 +896,7 @@ const FuzzTestRunner = struct {
901896 } });
902897 }
903898
904 fn instanceEos(f: *FuzzTestRunner, id: u32) !void {
899 fn instanceEos(f: *FuzzTestRunner, arena: Allocator, id: u32) !void {
905900 const maker = f.ctx.fuzz.maker;
906901 const instance = &f.instances[id];
907902 const run_index = f.run_index;
......@@ -914,7 +909,7 @@ const FuzzTestRunner = struct {
914909 instance.child.stdin = null;
915910 const term = try instance.child.wait(io);
916911 if (!termMatches(.{ .exited = 0 }, term)) {
917 step.result_stderr = try f.mergedStderr();
912 step.result_stderr = try f.mergedStderr(arena);
918913 try f.saveCrash(id, term);
919914 return step.fail(maker, "test process unexpectedly {f}", .{fmtTerm(term)});
920915 }
......@@ -1057,11 +1052,7 @@ const FuzzTestRunner = struct {
10571052 }
10581053 }
10591054
1060 fn mergedStderr(f: *FuzzTestRunner) std.mem.Allocator.Error![]const u8 {
1061 const maker = f.ctx.fuzz.maker;
1062 const graph = maker.graph;
1063 const arena = graph.arena; // TODO don't leak into the process arena
1064
1055 fn mergedStderr(f: *FuzzTestRunner, arena: Allocator) Allocator.Error![]const u8 {
10651056 // Collect any available stderr
10661057 while (f.batch.next()) |completion| {
10671058 if (completion.index % 3 != 2) continue;
......@@ -1092,12 +1083,13 @@ fn evalFuzzTest(
10921083 var f: FuzzTestRunner = try .init(run, run_index, fuzz_context, progress_node, spawn_options);
10931084 defer f.deinit();
10941085 try f.startInstances();
1095 try f.listen();
1086 try f.listen(fuzz_context.fuzz.maker.graph.arena);
10961087}
10971088
10981089const StdioPollEnum = enum { stdout, stderr };
10991090
11001091fn evalZigTest(
1092 arena: Allocator,
11011093 run: *Run,
11021094 run_index: Configuration.Step.Index,
11031095 maker: *Maker,
......@@ -1113,7 +1105,6 @@ fn evalZigTest(
11131105 const graph = maker.graph;
11141106 const gpa = maker.gpa;
11151107 const io = graph.io;
1116 const arena = graph.arena; // TODO don't leak into the process arena
11171108 const step = maker.stepByIndex(run_index);
11181109
11191110 // We will update this every time a child runs.
......@@ -1146,6 +1137,7 @@ fn evalZigTest(
11461137 };
11471138
11481139 switch (try waitZigTest(
1140 arena,
11491141 run,
11501142 run_index,
11511143 maker,
......@@ -1380,13 +1372,13 @@ fn sendRunFuzzTestMessage(
13801372}
13811373
13821374fn evalGeneric(
1375 arena: Allocator,
13831376 run_index: Configuration.Step.Index,
13841377 maker: *Maker,
13851378 spawn_options: process.SpawnOptions,
13861379) !EvalGenericResult {
13871380 const graph = maker.graph;
13881381 const io = graph.io;
1389 const arena = graph.arena; // TODO don't leak into the process arena
13901382 const gpa = maker.gpa;
13911383 const conf = &maker.scanned_config.configuration;
13921384 const conf_step = run_index.ptr(conf);
......@@ -1520,15 +1512,17 @@ pub fn rerunInFuzzMode(
15201512 const graph = maker.graph;
15211513 const step = maker.stepByIndex(run_index);
15221514 const io = graph.io;
1523 const arena = graph.arena; // TODO don't leak into the process arena
15241515 const gpa = maker.gpa;
15251516 const conf = &maker.scanned_config.configuration;
15261517 const conf_step = run_index.ptr(conf);
15271518 const conf_run = conf_step.extended.get(conf.extra).run;
1528 const argv_list = &run.argv;
15291519 const cache_root = graph.local_cache_root;
15301520
1531 argv_list.clearRetainingCapacity();
1521 var arena_allocator: std.heap.ArenaAllocator = .init(gpa);
1522 defer arena_allocator.deinit();
1523 const arena = arena_allocator.allocator();
1524
1525 var argv_list: std.ArrayList([]const u8) = .empty;
15321526
15331527 for (conf_run.args.slice) |arg_index| {
15341528 const arg = arg_index.get(conf);
......@@ -1543,7 +1537,7 @@ pub fn rerunInFuzzMode(
15431537 const suffix = if (arg.suffix.value) |p| p.slice(conf) else "";
15441538 const file_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index);
15451539 argv_list.appendAssumeCapacity(try mem.concat(arena, u8, &.{
1546 prefix, try convertPathArg(run_index, maker, file_path), suffix,
1540 prefix, try convertPathArg(arena, run_index, maker, file_path), suffix,
15471541 }));
15481542 },
15491543 .path_directory => {
......@@ -1551,7 +1545,7 @@ pub fn rerunInFuzzMode(
15511545 const suffix = if (arg.suffix.value) |p| p.slice(conf) else "";
15521546 const file_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index);
15531547 const resolved_arg = try mem.concat(arena, u8, &.{
1554 prefix, try convertPathArg(run_index, maker, file_path), suffix,
1548 prefix, try convertPathArg(arena, run_index, maker, file_path), suffix,
15551549 });
15561550 argv_list.appendAssumeCapacity(resolved_arg);
15571551 },
......@@ -1593,7 +1587,7 @@ pub fn rerunInFuzzMode(
15931587 producer_make_comp.installed_path orelse
15941588 maker.generatedPath(producer.generated_bin.value.?).*;
15951589 argv_list.appendAssumeCapacity(try mem.concat(arena, u8, &.{
1596 prefix, try convertPathArg(run_index, maker, file_path), suffix,
1590 prefix, try convertPathArg(arena, run_index, maker, file_path), suffix,
15971591 }));
15981592 },
15991593 .output_file => unreachable,
......@@ -1603,7 +1597,7 @@ pub fn rerunInFuzzMode(
16031597 }
16041598
16051599 if (conf_run.flags.test_runner_mode) {
1606 const cache_dir_string = try convertPathArg(run_index, maker, .{ .root_dir = cache_root });
1600 const cache_dir_string = try convertPathArg(arena, run_index, maker, .{ .root_dir = cache_root });
16071601
16081602 try argv_list.ensureUnusedCapacity(gpa, 3);
16091603 argv_list.appendAssumeCapacity(try allocPrint(arena, "--cache-dir={s}", .{cache_dir_string}));
......@@ -1620,7 +1614,7 @@ pub fn rerunInFuzzMode(
16201614 var rand_int: u64 = undefined;
16211615 io.random(@ptrCast(&rand_int));
16221616 const tmp_dir_path = "tmp" ++ Dir.path.sep_str ++ std.fmt.hex(rand_int);
1623 try runCommand(run, run_index, maker, prog_node, argv_list.items, has_side_effects, tmp_dir_path, .{
1617 try runCommand(arena, run, run_index, maker, prog_node, argv_list.items, has_side_effects, tmp_dir_path, .{
16241618 .fuzz = fuzz,
16251619 });
16261620}
......@@ -1633,13 +1627,12 @@ fn populateGeneratedPaths(
16331627) !void {
16341628 const conf = &maker.scanned_config.configuration;
16351629 const graph = maker.graph;
1636 const arena = graph.arena; // TODO don't leak into the process arena
16371630
16381631 for (output_placeholders) |placeholder| {
16391632 const arg = placeholder.arg_index.get(conf);
16401633 maker.generatedPath(arg.generated.value.?).* = .{
16411634 .root_dir = cache_root,
1642 .sub_path = try Dir.path.join(arena, &.{
1635 .sub_path = try Dir.path.join(graph.arena, &.{
16431636 "o", digest, arg.basename.value.?.slice(conf),
16441637 }),
16451638 };
......@@ -1647,20 +1640,20 @@ fn populateGeneratedPaths(
16471640}
16481641
16491642fn populateGeneratedPathsCreateDirs(
1650 run: *Run,
1643 arena: Allocator,
16511644 run_index: Configuration.Step.Index,
16521645 maker: *Maker,
16531646 output_dir_path: []const u8,
1647 output_placeholders: []const IndexedOutput,
1648 argv: [][]const u8,
16541649) !void {
16551650 const step = maker.stepByIndex(run_index);
16561651 const conf = &maker.scanned_config.configuration;
16571652 const graph = maker.graph;
16581653 const io = graph.io;
1659 const arena = graph.arena; // TODO don't leak into the process arena
16601654 const cache_root = graph.local_cache_root;
1661 const argv = run.argv.items;
16621655
1663 for (run.output_placeholders.items) |placeholder| {
1656 for (output_placeholders) |placeholder| {
16641657 const arg = placeholder.arg_index.get(conf);
16651658 const prefix = if (arg.prefix.value) |p| p.slice(conf) else "";
16661659 const suffix = if (arg.suffix.value) |p| p.slice(conf) else "";
......@@ -1668,7 +1661,7 @@ fn populateGeneratedPathsCreateDirs(
16681661
16691662 const generated_path: Path = .{
16701663 .root_dir = cache_root,
1671 .sub_path = try Dir.path.join(arena, &.{ output_dir_path, basename }),
1664 .sub_path = try Dir.path.join(graph.arena, &.{ output_dir_path, basename }),
16721665 };
16731666 const create_path: Path = .{
16741667 .root_dir = cache_root,
......@@ -1683,7 +1676,7 @@ fn populateGeneratedPathsCreateDirs(
16831676
16841677 maker.generatedPath(arg.generated.value.?).* = generated_path;
16851678
1686 const arg_output_path = try convertPathArg(run_index, maker, generated_path);
1679 const arg_output_path = try convertPathArg(arena, run_index, maker, generated_path);
16871680 argv[placeholder.index] = try mem.concat(arena, u8, &.{ prefix, arg_output_path, suffix });
16881681 }
16891682}
......@@ -1696,12 +1689,11 @@ fn populateGeneratedStdIo(
16961689) !void {
16971690 const conf = &maker.scanned_config.configuration;
16981691 const graph = maker.graph;
1699 const arena = graph.arena; // TODO don't leak into the process arena
17001692
17011693 if (conf_run.captured_stdout.value) |captured| {
17021694 maker.generatedPath(captured.generated_file).* = .{
17031695 .root_dir = cache_root,
1704 .sub_path = try Dir.path.join(arena, &.{
1696 .sub_path = try Dir.path.join(graph.arena, &.{
17051697 "o", digest, captured.basename.slice(conf),
17061698 }),
17071699 };
......@@ -1710,7 +1702,7 @@ fn populateGeneratedStdIo(
17101702 if (conf_run.captured_stderr.value) |captured| {
17111703 maker.generatedPath(captured.generated_file).* = .{
17121704 .root_dir = cache_root,
1713 .sub_path = try Dir.path.join(arena, &.{
1705 .sub_path = try Dir.path.join(graph.arena, &.{
17141706 "o", digest, captured.basename.slice(conf),
17151707 }),
17161708 };
......@@ -1736,6 +1728,7 @@ const FuzzContext = struct {
17361728};
17371729
17381730fn runCommand(
1731 arena: Allocator,
17391732 run: *Run,
17401733 run_index: Configuration.Step.Index,
17411734 maker: *Maker,
......@@ -1746,7 +1739,6 @@ fn runCommand(
17461739 fuzz_context: ?FuzzContext,
17471740) Step.ExtendedMakeError!void {
17481741 const graph = maker.graph;
1749 const arena = graph.arena; // TODO don't leak into process arena
17501742 const gpa = maker.gpa;
17511743 const step = maker.stepByIndex(run_index);
17521744 const io = graph.io;
......@@ -1754,7 +1746,6 @@ fn runCommand(
17541746 const conf = &maker.scanned_config.configuration;
17551747 const conf_step = run_index.ptr(conf);
17561748 const conf_run = conf_step.extended.get(conf.extra).run;
1757 const environ_map = &run.environ_map;
17581749
17591750 const cwd: process.Child.Cwd = if (conf_run.cwd.value) |lazy_cwd|
17601751 .{ .path = try maker.resolveLazyPathIndexAbs(arena, lazy_cwd, run_index) }
......@@ -1768,12 +1759,11 @@ fn runCommand(
17681759
17691760 var interp_argv: std.ArrayList([]const u8) = .empty;
17701761
1771 // `environ_map` is initialized with an undefined `allocator` field; lazily
1772 // initialize it here.
1773 environ_map.allocator = gpa;
1762 var environ_map: std.process.Environ.Map = .init(gpa);
1763 defer environ_map.deinit();
1764
17741765 // In either case we add to this mutatable data structure so that we can
17751766 // tweak the environment below.
1776 environ_map.clearRetainingCapacity();
17771767 if (conf_run.environ_map.value) |env_map_index| {
17781768 const conf_env_map = env_map_index.get(conf);
17791769 for (conf_env_map.keys.slice(conf), conf_env_map.values.slice(conf)) |k, v| {
......@@ -1792,7 +1782,7 @@ fn runCommand(
17921782 const root_module = producer.root_module.get(conf);
17931783 const root_module_target = root_module.resolved_target.get(conf).?.result.get(conf);
17941784 if (root_module_target.flags.os_tag == .windows) {
1795 try addPathForDynLibs(maker, producer_index, environ_map, argv[0]);
1785 try addPathForDynLibs(maker, arena, producer_index, &environ_map, argv[0]);
17961786 }
17971787 }
17981788
......@@ -1801,15 +1791,16 @@ fn runCommand(
18011791 .dir => unreachable,
18021792 .inherit => null,
18031793 };
1804 try graph.handleVerbose(cwd_string, environ_map, argv);
1794 try graph.handleVerbose(cwd_string, &environ_map, argv);
18051795
18061796 const opt_generic_result = spawnChildAndCollect(
1797 arena,
18071798 run_index,
18081799 run,
18091800 maker,
18101801 progress_node,
18111802 argv,
1812 environ_map,
1803 &environ_map,
18131804 has_side_effects,
18141805 fuzz_context,
18151806 ) catch |err| term: {
......@@ -1863,7 +1854,7 @@ fn runCommand(
18631854 try environ_map.put("WINEDEBUG", "-all");
18641855 }
18651856 } else {
1866 return failForeign(&conf_run, maker, run_index, "-fwine", argv[0], &root_target, &host);
1857 return failForeign(arena, &conf_run, maker, run_index, "-fwine", argv[0], &root_target, &host);
18671858 }
18681859 },
18691860 .qemu => |bin_name| {
......@@ -1887,11 +1878,11 @@ fn runCommand(
18871878 root_target.abi,
18881879 ) else unreachable,
18891880 }));
1890 } else return failForeign(&conf_run, maker, run_index, "--libc-runtimes", argv[0], &root_target, &host);
1881 } else return failForeign(arena, &conf_run, maker, run_index, "--libc-runtimes", argv[0], &root_target, &host);
18911882 }
18921883
18931884 interp_argv.appendSliceAssumeCapacity(argv);
1894 } else return failForeign(&conf_run, maker, run_index, "-fqemu", argv[0], &root_target, &host);
1885 } else return failForeign(arena, &conf_run, maker, run_index, "-fqemu", argv[0], &root_target, &host);
18951886 },
18961887 .darling => |bin_name| {
18971888 if (graph.enable_darling) {
......@@ -1899,7 +1890,7 @@ fn runCommand(
18991890 interp_argv.appendAssumeCapacity(bin_name);
19001891 interp_argv.appendSliceAssumeCapacity(argv);
19011892 } else {
1902 return failForeign(&conf_run, maker, run_index, "-fdarling", argv[0], &root_target, &host);
1893 return failForeign(arena, &conf_run, maker, run_index, "-fdarling", argv[0], &root_target, &host);
19031894 }
19041895 },
19051896 .wasmtime => |bin_name| {
......@@ -1912,7 +1903,7 @@ fn runCommand(
19121903 interp_argv.appendAssumeCapacity("-Sinherit-env");
19131904 interp_argv.appendSliceAssumeCapacity(argv);
19141905 } else {
1915 return failForeign(&conf_run, maker, run_index, "-fwasmtime", argv[0], &root_target, &host);
1906 return failForeign(arena, &conf_run, maker, run_index, "-fwasmtime", argv[0], &root_target, &host);
19161907 }
19171908 },
19181909 .bad_dl => |foreign_dl| {
......@@ -1941,15 +1932,16 @@ fn runCommand(
19411932
19421933 gpa.free(step.result_failed_command.?);
19431934 step.result_failed_command = null;
1944 try graph.handleVerbose(cwd_string, environ_map, interp_argv.items);
1935 try graph.handleVerbose(cwd_string, &environ_map, interp_argv.items);
19451936
19461937 break :term spawnChildAndCollect(
1938 arena,
19471939 run_index,
19481940 run,
19491941 maker,
19501942 progress_node,
19511943 interp_argv.items,
1952 environ_map,
1944 &environ_map,
19531945 has_side_effects,
19541946 fuzz_context,
19551947 ) catch |e| {
......@@ -1996,7 +1988,7 @@ fn runCommand(
19961988 if (stream.captured) |captured| {
19971989 const output_path: Path = .{
19981990 .root_dir = cache_root,
1999 .sub_path = try Dir.path.join(arena, &.{
1991 .sub_path = try Dir.path.join(graph.arena, &.{
20001992 output_dir_path, captured.basename.slice(conf),
20011993 }),
20021994 };
......@@ -2117,6 +2109,7 @@ const EvalGenericResult = struct {
21172109};
21182110
21192111fn spawnChildAndCollect(
2112 arena: Allocator,
21202113 run_index: Configuration.Step.Index,
21212114 run: *Run,
21222115 maker: *Maker,
......@@ -2129,7 +2122,6 @@ fn spawnChildAndCollect(
21292122 const step = maker.stepByIndex(run_index);
21302123 const graph = maker.graph;
21312124 const io = graph.io;
2132 const arena = graph.arena; // TODO don't leak into process arena
21332125 const gpa = maker.gpa;
21342126 const conf = &maker.scanned_config.configuration;
21352127 const conf_step = run_index.ptr(conf);
......@@ -2189,7 +2181,7 @@ fn spawnChildAndCollect(
21892181
21902182 if (conf_run.flags.stdio == .zig_test) {
21912183 const started: Io.Clock.Timestamp = .now(io, .awake);
2192 const result = evalZigTest(run, run_index, maker, progress_node, spawn_options, fuzz_context) catch |err| switch (err) {
2184 const result = evalZigTest(graph.arena, run, run_index, maker, progress_node, spawn_options, fuzz_context) catch |err| switch (err) {
21932185 error.Canceled => |e| return e,
21942186 else => |e| e,
21952187 };
......@@ -2209,7 +2201,7 @@ fn spawnChildAndCollect(
22092201 try setColorEnvironmentVariables(&conf_run, environ_map, terminal_mode);
22102202
22112203 const started: Io.Clock.Timestamp = .now(io, .awake);
2212 const result = evalGeneric(run_index, maker, spawn_options) catch |err| switch (err) {
2204 const result = evalGeneric(arena, run_index, maker, spawn_options) catch |err| switch (err) {
22132205 error.Canceled => |e| return e,
22142206 else => |e| e,
22152207 };
......@@ -2287,12 +2279,11 @@ fn checksContainStderr(conf_run: *const Configuration.Step.Run) bool {
22872279///
22882280/// Whenever a path is included in the argv of a child, it should be put through this function first
22892281/// to make sure the child doesn't see paths relative to a cwd other than its own.
2290fn convertPathArg(run_index: Configuration.Step.Index, maker: *Maker, path: Path) ![]const u8 {
2282fn convertPathArg(arena: Allocator, run_index: Configuration.Step.Index, maker: *Maker, path: Path) ![]const u8 {
22912283 const conf = &maker.scanned_config.configuration;
22922284 const conf_step = run_index.ptr(conf);
22932285 const conf_run = conf_step.extended.get(conf.extra).run;
22942286 const graph = maker.graph;
2295 const arena = graph.arena; // TODO don't leak into process arena
22962287
22972288 const path_str = try path.toString(arena);
22982289 if (Dir.path.isAbsolute(path_str)) {
......@@ -2319,13 +2310,13 @@ fn convertPathArg(run_index: Configuration.Step.Index, maker: *Maker, path: Path
23192310
23202311fn addPathForDynLibs(
23212312 maker: *Maker,
2313 arena: Allocator,
23222314 artifact: Configuration.Step.Index,
23232315 environ_map: *process.Environ.Map,
23242316 argv0: []const u8,
23252317) !void {
23262318 const conf = &maker.scanned_config.configuration;
23272319 const graph = maker.graph;
2328 const arena = graph.arena; // TODO don't leak into process arena
23292320 const use_wine = graph.enable_wine and builtin.os.tag != .windows and std.ascii.endsWithIgnoreCase(argv0, ".exe");
23302321 const path_key = if (use_wine) "WINEPATH" else "PATH";
23312322 const path_delimiter: u8 = if (builtin.os.tag == .windows or use_wine)
......@@ -2355,6 +2346,7 @@ fn addPathForDynLibs(
23552346}
23562347
23572348fn failForeign(
2349 arena: Allocator,
23582350 conf_run: *const Configuration.Step.Run,
23592351 maker: *Maker,
23602352 step_index: Configuration.Step.Index,
......@@ -2368,10 +2360,8 @@ fn failForeign(
23682360 .check, .zig_test => {
23692361 if (conf_run.flags.skip_foreign_checks) return error.MakeSkipped;
23702362
2371 const graph = maker.graph;
2372 const process_arena = graph.arena; // TODO don't leak into process arena
2373 const host_name = try host_target.zigTriple(process_arena);
2374 const foreign_name = try artifact_target.zigTriple(process_arena);
2363 const host_name = try host_target.zigTriple(arena);
2364 const foreign_name = try artifact_target.zigTriple(arena);
23752365
23762366 return step.fail(maker,
23772367 \\unable to spawn foreign binary '{s}' ({s}) on host system ({s})