Upstream issue: https://github.com/ziglang/zig/issues/9738 Without this patch, 'zig run' or 'zig test' attempts to run cross-native binaries even if their dynamic loader isn't present, which causes a crash with "error: FileNotFound". --- diff --git a/src/main.zig b/src/main.zig index c1d12fcba..9b1bee0d6 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2040,7 +2040,7 @@ fn buildOutputType( test_exec_args.items, self_exe_path, arg_mode, - target_info.target, + target_info, watch, &comp_destroyed, all_args, @@ -2110,7 +2110,7 @@ fn buildOutputType( test_exec_args.items, self_exe_path, arg_mode, - target_info.target, + target_info, watch, &comp_destroyed, all_args, @@ -2134,7 +2134,7 @@ fn buildOutputType( test_exec_args.items, self_exe_path, arg_mode, - target_info.target, + target_info, watch, &comp_destroyed, all_args, @@ -2158,7 +2158,7 @@ fn runOrTest( test_exec_args: []const ?[]const u8, self_exe_path: []const u8, arg_mode: ArgMode, - target: std.Target, + target: std.zig.system.NativeTargetInfo, watch: bool, comp_destroyed: *bool, all_args: []const []const u8, @@ -2174,7 +2174,15 @@ fn runOrTest( defer argv.deinit(); if (test_exec_args.len == 0) { - if (!std.Target.current.canExecBinariesOf(target)) { + const can_run = blk: { + if (!std.Target.current.canExecBinariesOf(target.target)) break :blk false; + if (target.dynamic_linker.get()) |dl| { + std.fs.cwd().access(dl, .{}) catch break :blk false; + break :blk true; + } + break :blk false; + }; + if (!can_run) { switch (arg_mode) { .zig_test => { warn("created {s} but skipping execution because it is non-native", .{exe_path});