authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-06-11 23:36:34+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-12 00:03:02+02:00
log681d324c49e7cdc773cc891ea49ed69dd03c23c7
tree2aebc817268b1f316151f3a544e83210dc681f2a
parentf4ed35f800396f12c7cd6aa1f70cf2555ddf7c84

std.Build.Step.Run: Set WINEDEBUG=-all for -fwine by default.

This silences the excessive default stderr logging from Wine. The user can still override this by setting WINEDEBUG in the environment; this just provides a more sensible default. Closes #24139.

1 files changed, 15 insertions(+), 3 deletions(-)

lib/std/Build/Step/Run.zig+15-3
......@@ -1079,7 +1079,9 @@ fn runCommand(
10791079 var interp_argv = std.ArrayList([]const u8).init(b.allocator);
10801080 defer interp_argv.deinit();
10811081
1082 const result = spawnChildAndCollect(run, argv, has_side_effects, prog_node, fuzz_context) catch |err| term: {
1082 var env_map = run.env_map orelse &b.graph.env_map;
1083
1084 const result = spawnChildAndCollect(run, argv, env_map, has_side_effects, prog_node, fuzz_context) catch |err| term: {
10831085 // InvalidExe: cpu arch mismatch
10841086 // FileNotFound: can happen with a wrong dynamic linker path
10851087 if (err == error.InvalidExe or err == error.FileNotFound) interpret: {
......@@ -1112,6 +1114,15 @@ fn runCommand(
11121114 if (b.enable_wine) {
11131115 try interp_argv.append(bin_name);
11141116 try interp_argv.appendSlice(argv);
1117
1118 // Wine's excessive stderr logging is only situationally helpful. Disable it by default, but
1119 // allow the user to override it (e.g. with `WINEDEBUG=err+all`) if desired.
1120 if (env_map.get("WINEDEBUG") == null) {
1121 // We don't own `env_map` at this point, so turn it into a copy before modifying it.
1122 env_map = arena.create(EnvMap) catch @panic("OOM");
1123 env_map.hash_map = try env_map.hash_map.cloneWithAllocator(arena);
1124 try env_map.put("WINEDEBUG", "-all");
1125 }
11151126 } else {
11161127 return failForeign(run, "-fwine", argv[0], exe);
11171128 }
......@@ -1207,7 +1218,7 @@ fn runCommand(
12071218
12081219 try Step.handleVerbose2(step.owner, cwd, run.env_map, interp_argv.items);
12091220
1210 break :term spawnChildAndCollect(run, interp_argv.items, has_side_effects, prog_node, fuzz_context) catch |e| {
1221 break :term spawnChildAndCollect(run, interp_argv.items, env_map, has_side_effects, prog_node, fuzz_context) catch |e| {
12111222 if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped;
12121223
12131224 return step.fail("unable to spawn interpreter {s}: {s}", .{
......@@ -1390,6 +1401,7 @@ const ChildProcResult = struct {
13901401fn spawnChildAndCollect(
13911402 run: *Run,
13921403 argv: []const []const u8,
1404 env_map: *EnvMap,
13931405 has_side_effects: bool,
13941406 prog_node: std.Progress.Node,
13951407 fuzz_context: ?FuzzContext,
......@@ -1406,7 +1418,7 @@ fn spawnChildAndCollect(
14061418 if (run.cwd) |lazy_cwd| {
14071419 child.cwd = lazy_cwd.getPath2(b, &run.step);
14081420 }
1409 child.env_map = run.env_map orelse &b.graph.env_map;
1421 child.env_map = env_map;
14101422 child.request_resource_usage_statistics = true;
14111423
14121424 child.stdin_behavior = switch (run.stdio) {