all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 1952c6b867eda874269091bb11eeeeae98630784 2315 bytes (raw)
name: gnu/packages/patches/zig-fix-cross-native-execution.patch 	 # note: path name is non-authoritative(*)

 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});

debug log:

solving 1952c6b867 ...
found 1952c6b867 in https://yhetil.org/guix/865yv6mmk2.fsf@mgsn.dev/

applying [1/1] https://yhetil.org/guix/865yv6mmk2.fsf@mgsn.dev/
diff --git a/gnu/packages/patches/zig-fix-cross-native-execution.patch b/gnu/packages/patches/zig-fix-cross-native-execution.patch
new file mode 100644
index 0000000000..1952c6b867

1:56: trailing whitespace.
 
Checking patch gnu/packages/patches/zig-fix-cross-native-execution.patch...
Applied patch gnu/packages/patches/zig-fix-cross-native-execution.patch cleanly.
warning: 1 line adds whitespace errors.

index at:
100644 1952c6b867eda874269091bb11eeeeae98630784	gnu/packages/patches/zig-fix-cross-native-execution.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.