authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-09-26 19:35:14+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-10-05 20:52:26+01:00
logada60616b37b76004237f4e13de8b552c16dc773
tree55aaf6adb45e1440db5f6006bf2f11014d63a168
parent14ccbbef9f4e34ed2311b96b771bbb452dccf9dc
signaturelock-open Commit is signed but in an unrecognized format.

incr-check: minor fixes

* fix inconsistency in global cache directory name * don't error if spawning external executor fails * handle CRLF correctly

1 files changed, 22 insertions(+), 7 deletions(-)

tools/incr-check.zig+22-7
...@@ -110,7 +110,7 @@ pub fn main() !void {...@@ -110,7 +110,7 @@ pub fn main() !void {
110 "--cache-dir",110 "--cache-dir",
111 ".local-cache",111 ".local-cache",
112 "--global-cache-dir",112 "--global-cache-dir",
113 ".global_cache",113 ".global-cache",
114 "--listen=-",114 "--listen=-",
115 });115 });
116 if (opt_resolved_lib_dir) |resolved_lib_dir| {116 if (opt_resolved_lib_dir) |resolved_lib_dir| {
...@@ -373,7 +373,7 @@ const Eval = struct {...@@ -373,7 +373,7 @@ const Eval = struct {
373 };373 };
374374
375 var argv_buf: [2][]const u8 = undefined;375 var argv_buf: [2][]const u8 = undefined;
376 const argv: []const []const u8, const ignore_stderr: bool = switch (std.zig.system.getExternalExecutor(376 const argv: []const []const u8, const is_foreign: bool = switch (std.zig.system.getExternalExecutor(
377 eval.host,377 eval.host,
378 &eval.target.resolved,378 &eval.target.resolved,
379 .{ .link_libc = eval.target.backend == .cbe },379 .{ .link_libc = eval.target.backend == .cbe },
...@@ -395,8 +395,6 @@ const Eval = struct {...@@ -395,8 +395,6 @@ const Eval = struct {
395 .qemu, .wine, .wasmtime, .darling => |executor_cmd| argv: {395 .qemu, .wine, .wasmtime, .darling => |executor_cmd| argv: {
396 argv_buf[0] = executor_cmd;396 argv_buf[0] = executor_cmd;
397 argv_buf[1] = binary_path;397 argv_buf[1] = binary_path;
398 // Some executors (looking at you, Wine) like throwing some stderr in, just for fun.
399 // Therefore, we'll ignore stderr when using a foreign executor.
400 break :argv .{ argv_buf[0..2], true };398 break :argv .{ argv_buf[0..2], true };
401 },399 },
402 };400 };
...@@ -410,15 +408,31 @@ const Eval = struct {...@@ -410,15 +408,31 @@ const Eval = struct {
410 .cwd_dir = eval.tmp_dir,408 .cwd_dir = eval.tmp_dir,
411 .cwd = eval.tmp_dir_path,409 .cwd = eval.tmp_dir_path,
412 }) catch |err| {410 }) catch |err| {
411 if (is_foreign) {
412 // Chances are the foreign executor isn't available. Skip this evaluation.
413 if (eval.allow_stderr) {
414 std.log.warn("update '{s}': skipping execution of '{s}' via executor for foreign target '{s}': {s}", .{
415 update.name,
416 binary_path,
417 try eval.target.resolved.zigTriple(eval.arena),
418 @errorName(err),
419 });
420 }
421 return;
422 }
413 eval.fatal("update '{s}': failed to run the generated executable '{s}': {s}", .{423 eval.fatal("update '{s}': failed to run the generated executable '{s}': {s}", .{
414 update.name, binary_path, @errorName(err),424 update.name, binary_path, @errorName(err),
415 });425 });
416 };426 };
417 if (!ignore_stderr and result.stderr.len != 0) {427
428 // Some executors (looking at you, Wine) like throwing some stderr in, just for fun.
429 // Therefore, we'll ignore stderr when using a foreign executor.
430 if (!is_foreign and result.stderr.len != 0) {
418 std.log.err("update '{s}': generated executable '{s}' had unexpected stderr:\n{s}", .{431 std.log.err("update '{s}': generated executable '{s}' had unexpected stderr:\n{s}", .{
419 update.name, binary_path, result.stderr,432 update.name, binary_path, result.stderr,
420 });433 });
421 }434 }
435
422 switch (result.term) {436 switch (result.term) {
423 .Exited => |code| switch (update.outcome) {437 .Exited => |code| switch (update.outcome) {
424 .unknown, .compile_errors => unreachable,438 .unknown, .compile_errors => unreachable,
...@@ -438,7 +452,8 @@ const Eval = struct {...@@ -438,7 +452,8 @@ const Eval = struct {
438 });452 });
439 },453 },
440 }454 }
441 if (!ignore_stderr and result.stderr.len != 0) std.process.exit(1);455
456 if (!is_foreign and result.stderr.len != 0) std.process.exit(1);
442 }457 }
443458
444 fn requestUpdate(eval: *Eval) !void {459 fn requestUpdate(eval: *Eval) !void {
...@@ -594,7 +609,7 @@ const Case = struct {...@@ -594,7 +609,7 @@ const Case = struct {
594 if (std.mem.startsWith(u8, line, "#")) {609 if (std.mem.startsWith(u8, line, "#")) {
595 var line_it = std.mem.splitScalar(u8, line, '=');610 var line_it = std.mem.splitScalar(u8, line, '=');
596 const key = line_it.first()[1..];611 const key = line_it.first()[1..];
597 const val = line_it.rest();612 const val = std.mem.trimRight(u8, line_it.rest(), "\r"); // windows moment
598 if (val.len == 0) {613 if (val.len == 0) {
599 fatal("line {d}: missing value", .{line_n});614 fatal("line {d}: missing value", .{line_n});
600 } else if (std.mem.eql(u8, key, "target")) {615 } else if (std.mem.eql(u8, key, "target")) {