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 {
110110 "--cache-dir",
111111 ".local-cache",
112112 "--global-cache-dir",
113 ".global_cache",
113 ".global-cache",
114114 "--listen=-",
115115 });
116116 if (opt_resolved_lib_dir) |resolved_lib_dir| {
......@@ -373,7 +373,7 @@ const Eval = struct {
373373 };
374374
375375 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(
377377 eval.host,
378378 &eval.target.resolved,
379379 .{ .link_libc = eval.target.backend == .cbe },
......@@ -395,8 +395,6 @@ const Eval = struct {
395395 .qemu, .wine, .wasmtime, .darling => |executor_cmd| argv: {
396396 argv_buf[0] = executor_cmd;
397397 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.
400398 break :argv .{ argv_buf[0..2], true };
401399 },
402400 };
......@@ -410,15 +408,31 @@ const Eval = struct {
410408 .cwd_dir = eval.tmp_dir,
411409 .cwd = eval.tmp_dir_path,
412410 }) 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 }
413423 eval.fatal("update '{s}': failed to run the generated executable '{s}': {s}", .{
414424 update.name, binary_path, @errorName(err),
415425 });
416426 };
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) {
418431 std.log.err("update '{s}': generated executable '{s}' had unexpected stderr:\n{s}", .{
419432 update.name, binary_path, result.stderr,
420433 });
421434 }
435
422436 switch (result.term) {
423437 .Exited => |code| switch (update.outcome) {
424438 .unknown, .compile_errors => unreachable,
......@@ -438,7 +452,8 @@ const Eval = struct {
438452 });
439453 },
440454 }
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);
442457 }
443458
444459 fn requestUpdate(eval: *Eval) !void {
......@@ -594,7 +609,7 @@ const Case = struct {
594609 if (std.mem.startsWith(u8, line, "#")) {
595610 var line_it = std.mem.splitScalar(u8, line, '=');
596611 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
598613 if (val.len == 0) {
599614 fatal("line {d}: missing value", .{line_n});
600615 } else if (std.mem.eql(u8, key, "target")) {