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(...@@ -1079,7 +1079,9 @@ fn runCommand(
1079 var interp_argv = std.ArrayList([]const u8).init(b.allocator);1079 var interp_argv = std.ArrayList([]const u8).init(b.allocator);
1080 defer interp_argv.deinit();1080 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: {
1083 // InvalidExe: cpu arch mismatch1085 // InvalidExe: cpu arch mismatch
1084 // FileNotFound: can happen with a wrong dynamic linker path1086 // FileNotFound: can happen with a wrong dynamic linker path
1085 if (err == error.InvalidExe or err == error.FileNotFound) interpret: {1087 if (err == error.InvalidExe or err == error.FileNotFound) interpret: {
...@@ -1112,6 +1114,15 @@ fn runCommand(...@@ -1112,6 +1114,15 @@ fn runCommand(
1112 if (b.enable_wine) {1114 if (b.enable_wine) {
1113 try interp_argv.append(bin_name);1115 try interp_argv.append(bin_name);
1114 try interp_argv.appendSlice(argv);1116 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 }
1115 } else {1126 } else {
1116 return failForeign(run, "-fwine", argv[0], exe);1127 return failForeign(run, "-fwine", argv[0], exe);
1117 }1128 }
...@@ -1207,7 +1218,7 @@ fn runCommand(...@@ -1207,7 +1218,7 @@ fn runCommand(
12071218
1208 try Step.handleVerbose2(step.owner, cwd, run.env_map, interp_argv.items);1219 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| {
1211 if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped;1222 if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped;
12121223
1213 return step.fail("unable to spawn interpreter {s}: {s}", .{1224 return step.fail("unable to spawn interpreter {s}: {s}", .{
...@@ -1390,6 +1401,7 @@ const ChildProcResult = struct {...@@ -1390,6 +1401,7 @@ const ChildProcResult = struct {
1390fn spawnChildAndCollect(1401fn spawnChildAndCollect(
1391 run: *Run,1402 run: *Run,
1392 argv: []const []const u8,1403 argv: []const []const u8,
1404 env_map: *EnvMap,
1393 has_side_effects: bool,1405 has_side_effects: bool,
1394 prog_node: std.Progress.Node,1406 prog_node: std.Progress.Node,
1395 fuzz_context: ?FuzzContext,1407 fuzz_context: ?FuzzContext,
...@@ -1406,7 +1418,7 @@ fn spawnChildAndCollect(...@@ -1406,7 +1418,7 @@ fn spawnChildAndCollect(
1406 if (run.cwd) |lazy_cwd| {1418 if (run.cwd) |lazy_cwd| {
1407 child.cwd = lazy_cwd.getPath2(b, &run.step);1419 child.cwd = lazy_cwd.getPath2(b, &run.step);
1408 }1420 }
1409 child.env_map = run.env_map orelse &b.graph.env_map;1421 child.env_map = env_map;
1410 child.request_resource_usage_statistics = true;1422 child.request_resource_usage_statistics = true;
14111423
1412 child.stdin_behavior = switch (run.stdio) {1424 child.stdin_behavior = switch (run.stdio) {