Skip to content

Commit 681d324

Browse files
committed
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 parent f4ed35f commit 681d324

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/std/Build/Step/Run.zig

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {
13901401
fn 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) {

0 commit comments

Comments
 (0)