all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob ed122dac222054fca38ebfdd8c809711139721be 6372 bytes (raw)
name: gnu/packages/patches/zig-use-system-paths.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
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
 
This patch replaces the OS-specific detection mechanism by one that solely
relies on environment variables.  This has the benefit that said environment
variables can be used as search paths in Guix.

Index: zig-0.8.1/lib/std/zig/system.zig
===================================================================
--- zig-0.8.1.orig/lib/std/zig/system.zig
+++ zig-0.8.1/lib/std/zig/system.zig
@@ -39,101 +39,57 @@ pub const NativePaths = struct {
         };
         errdefer self.deinit();
 
-        var is_nix = false;
-        if (process.getEnvVarOwned(allocator, "NIX_CFLAGS_COMPILE")) |nix_cflags_compile| {
-            defer allocator.free(nix_cflags_compile);
-
-            is_nix = true;
-            var it = mem.tokenize(nix_cflags_compile, " ");
+        // TODO: Support cross-compile paths?
+        if (process.getEnvVarOwned(allocator, "C_INCLUDE_PATH")) |c_include_path| {
+            defer allocator.free(c_include_path);
+            var it = mem.tokenize(c_include_path, ":");
             while (true) {
-                const word = it.next() orelse break;
-                if (mem.eql(u8, word, "-isystem")) {
-                    const include_path = it.next() orelse {
-                        try self.addWarning("Expected argument after -isystem in NIX_CFLAGS_COMPILE");
-                        break;
-                    };
-                    try self.addIncludeDir(include_path);
-                } else {
-                    if (mem.startsWith(u8, word, "-frandom-seed=")) {
-                        continue;
-                    }
-                    try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {s}", .{word});
-                }
+                const dir = it.next() orelse break;
+                try self.addIncludeDir(dir);
             }
         } else |err| switch (err) {
             error.InvalidUtf8 => {},
             error.EnvironmentVariableNotFound => {},
             error.OutOfMemory => |e| return e,
         }
-        if (process.getEnvVarOwned(allocator, "NIX_LDFLAGS")) |nix_ldflags| {
-            defer allocator.free(nix_ldflags);
 
-            is_nix = true;
-            var it = mem.tokenize(nix_ldflags, " ");
+        if (process.getEnvVarOwned(allocator, "CPLUS_INCLUDE_PATH")) |cplus_include_path| {
+            defer allocator.free(cplus_include_path);
+            var it = mem.tokenize(cplus_include_path, ":");
             while (true) {
-                const word = it.next() orelse break;
-                if (mem.eql(u8, word, "-rpath")) {
-                    const rpath = it.next() orelse {
-                        try self.addWarning("Expected argument after -rpath in NIX_LDFLAGS");
-                        break;
-                    };
-                    try self.addRPath(rpath);
-                } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') {
-                    const lib_path = word[2..];
-                    try self.addLibDir(lib_path);
-                } else {
-                    try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word});
-                    break;
-                }
+                const dir = it.next() orelse break;
+                try self.addIncludeDir(dir);
             }
         } else |err| switch (err) {
             error.InvalidUtf8 => {},
             error.EnvironmentVariableNotFound => {},
             error.OutOfMemory => |e| return e,
         }
-        if (is_nix) {
-            return self;
-        }
-
-        if (comptime Target.current.isDarwin()) {
-            try self.addIncludeDir("/usr/include");
-            try self.addIncludeDir("/usr/local/include");
 
-            try self.addLibDir("/usr/lib");
-            try self.addLibDir("/usr/local/lib");
-
-            try self.addFrameworkDir("/Library/Frameworks");
-            try self.addFrameworkDir("/System/Library/Frameworks");
-
-            return self;
+        if (process.getEnvVarOwned(allocator, "LIBRARY_PATH")) |library_path| {
+            defer allocator.free(library_path);
+            var it = mem.tokenize(library_path, ":");
+            while (true) {
+                const dir = it.next() orelse break;
+                try self.addLibDir(dir);
+            }
+        } else |err| switch (err) {
+            error.InvalidUtf8 => {},
+            error.EnvironmentVariableNotFound => {},
+            error.OutOfMemory => |e| return e,
         }
 
-        if (native_target.os.tag != .windows) {
-            const triple = try native_target.linuxTriple(allocator);
-            const qual = native_target.cpu.arch.ptrBitWidth();
-
-            // TODO: $ ld --verbose | grep SEARCH_DIR
-            // the output contains some paths that end with lib64, maybe include them too?
-            // TODO: what is the best possible order of things?
-            // TODO: some of these are suspect and should only be added on some systems. audit needed.
-
-            try self.addIncludeDir("/usr/local/include");
-            try self.addLibDirFmt("/usr/local/lib{d}", .{qual});
-            try self.addLibDir("/usr/local/lib");
-
-            try self.addIncludeDirFmt("/usr/include/{s}", .{triple});
-            try self.addLibDirFmt("/usr/lib/{s}", .{triple});
-
-            try self.addIncludeDir("/usr/include");
-            try self.addLibDirFmt("/lib{d}", .{qual});
-            try self.addLibDir("/lib");
-            try self.addLibDirFmt("/usr/lib{d}", .{qual});
-            try self.addLibDir("/usr/lib");
-
-            // example: on a 64-bit debian-based linux distro, with zlib installed from apt:
-            // zlib.h is in /usr/include (added above)
-            // libz.so.1 is in /lib/x86_64-linux-gnu (added here)
-            try self.addLibDirFmt("/lib/{s}", .{triple});
+        if (process.getEnvVarOwned(allocator, "DYLD_FRAMEWORK_PATH")) |dyld_framework_path| {
+            defer allocator.free(dyld_framework_path);
+            var it = mem.tokenize(dyld_framework_path, ":");
+            while (true) {
+                const dir = it.next() orelse break;
+                try self.addFrameworkDir(dir);
+            }
+        } else |err| switch (err) {
+            error.InvalidUtf8 => {},
+            error.EnvironmentVariableNotFound => {},
+            error.OutOfMemory => |e| return e,
         }
 
         return self;

debug log:

solving ed122dac22 ...
found ed122dac22 in https://yhetil.org/guix/5ab728b993bf511df7d71cb6781fc10c58aaff6d.camel@gmail.com/ ||
	https://yhetil.org/guix/7b114e500e29364f44b0080e0f782255e92be74f.camel@gmail.com/

applying [1/1] https://yhetil.org/guix/5ab728b993bf511df7d71cb6781fc10c58aaff6d.camel@gmail.com/
diff --git a/gnu/packages/patches/zig-use-system-paths.patch b/gnu/packages/patches/zig-use-system-paths.patch
new file mode 100644
index 0000000000..ed122dac22

1:18: trailing whitespace.
 
1:53: trailing whitespace.
 
1:89: trailing whitespace.
 
1:109: trailing whitespace.
 
1:148: trailing whitespace.
 
Checking patch gnu/packages/patches/zig-use-system-paths.patch...
Applied patch gnu/packages/patches/zig-use-system-paths.patch cleanly.
warning: 5 lines add whitespace errors.

skipping https://yhetil.org/guix/7b114e500e29364f44b0080e0f782255e92be74f.camel@gmail.com/ for ed122dac22
index at:
100644 ed122dac222054fca38ebfdd8c809711139721be	gnu/packages/patches/zig-use-system-paths.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.