Skip to content

Commit 1011e5b

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 ziglang#24139.
1 parent 4d79806 commit 1011e5b

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
@@ -1028,7 +1028,9 @@ fn runCommand(
10281028
var interp_argv = std.ArrayList([]const u8).init(b.allocator);
10291029
defer interp_argv.deinit();
10301030

1031-
const result = spawnChildAndCollect(run, argv, has_side_effects, prog_node, fuzz_context) catch |err| term: {
1031+
var env_map = run.env_map orelse &b.graph.env_map;
1032+
1033+
const result = spawnChildAndCollect(run, argv, env_map, has_side_effects, prog_node, fuzz_context) catch |err| term: {
10321034
// InvalidExe: cpu arch mismatch
10331035
// FileNotFound: can happen with a wrong dynamic linker path
10341036
if (err == error.InvalidExe or err == error.FileNotFound) interpret: {
@@ -1061,6 +1063,15 @@ fn runCommand(
10611063
if (b.enable_wine) {
10621064
try interp_argv.append(bin_name);
10631065
try interp_argv.appendSlice(argv);
1066+
1067+
// Wine's excessive stderr logging is only situationally helpful. Disable it by default, but
1068+
// allow the user to override it (e.g. with `WINEDEBUG=err+all`) if desired.
1069+
if (env_map.get("WINEDEBUG") == null) {
1070+
// We don't own `env_map` at this point, so turn it into a copy before modifying it.
1071+
env_map = b.allocator.create(EnvMap) catch @panic("OOM");
1072+
env_map.hash_map = try env_map.hash_map.cloneWithAllocator(arena);
1073+
try env_map.put("WINEDEBUG", "-all");
1074+
}
10641075
} else {
10651076
return failForeign(run, "-fwine", argv[0], exe);
10661077
}
@@ -1156,7 +1167,7 @@ fn runCommand(
11561167

11571168
try Step.handleVerbose2(step.owner, cwd, run.env_map, interp_argv.items);
11581169

1159-
break :term spawnChildAndCollect(run, interp_argv.items, has_side_effects, prog_node, fuzz_context) catch |e| {
1170+
break :term spawnChildAndCollect(run, interp_argv.items, env_map, has_side_effects, prog_node, fuzz_context) catch |e| {
11601171
if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped;
11611172

11621173
return step.fail("unable to spawn interpreter {s}: {s}", .{
@@ -1339,6 +1350,7 @@ const ChildProcResult = struct {
13391350
fn spawnChildAndCollect(
13401351
run: *Run,
13411352
argv: []const []const u8,
1353+
env_map: *EnvMap,
13421354
has_side_effects: bool,
13431355
prog_node: std.Progress.Node,
13441356
fuzz_context: ?FuzzContext,
@@ -1355,7 +1367,7 @@ fn spawnChildAndCollect(
13551367
if (run.cwd) |lazy_cwd| {
13561368
child.cwd = lazy_cwd.getPath2(b, &run.step);
13571369
}
1358-
child.env_map = run.env_map orelse &b.graph.env_map;
1370+
child.env_map = env_map;
13591371
child.request_resource_usage_statistics = true;
13601372

13611373
child.stdin_behavior = switch (run.stdio) {

0 commit comments

Comments
 (0)