1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
| | 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});
|