summary refs log tree commit diff
path: root/gnu/packages/patches/zig-use-system-paths.patch
diff options
context:
space:
mode:
authorCalum Irwin <calumirwin1@gmail.com>2022-01-19 08:11:25 +0000
committerLudovic Courtès <ludo@gnu.org>2022-01-24 15:39:16 +0100
commit6504587168f78720198bdb518d63608af95f312c (patch)
treef8f8ed9c1cc657aff62aa26dc53bbcd88a41e9da /gnu/packages/patches/zig-use-system-paths.patch
parentc9627323eca0fb1e0b0a0680049ea0f9f20def5e (diff)
downloadguix-6504587168f78720198bdb518d63608af95f312c.tar.gz
gnu: zig: Update to 0.9.0
* gnu/packages/patches/zig-disable-libc-note-test.patch: Move patch changes to new file.
* gnu/packages/patches/zig-use-system-paths.patch: Update line numbers.
* gnu/packages/zig.scm: Update to 0.9.0

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/packages/patches/zig-use-system-paths.patch')
-rw-r--r--gnu/packages/patches/zig-use-system-paths.patch257
1 files changed, 131 insertions, 126 deletions
diff --git a/gnu/packages/patches/zig-use-system-paths.patch b/gnu/packages/patches/zig-use-system-paths.patch
index 33b7da1e0d..a008beafc2 100644
--- a/gnu/packages/patches/zig-use-system-paths.patch
+++ b/gnu/packages/patches/zig-use-system-paths.patch
@@ -2,142 +2,147 @@ 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);
+diff --git a/lib/std/zig/system/NativePaths.zig b/lib/std/zig/system/NativePaths.zig
+index 8e3e46e48..1ed9d3206 100644
+--- a/lib/std/zig/system/NativePaths.zig
++++ b/lib/std/zig/system/NativePaths.zig
+@@ -26,73 +26,42 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
+     };
+     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});
+-        is_nix = true;
+-        var it = mem.tokenize(u8, 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(u8, 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;
 -                }
-+                const dir = it.next() orelse break;
-+                try self.addIncludeDir(dir);
-             }
-         } else |err| switch (err) {
-             error.InvalidUtf8 => {},
-             error.EnvironmentVariableNotFound => {},
-             error.OutOfMemory => |e| return e,
+-                try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {s}", .{word});
+-            }
++            const dir = it.next() orelse break;
++            try self.addIncludeDir(dir);
          }
--        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});
+     } 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(u8, nix_ldflags, " ");
++    if (process.getEnvVarOwned(allocator, "CPLUS_INCLUDE_PATH")) |cplus_include_path| {
++        defer allocator.free(cplus_include_path);
++        var it = mem.tokenize(u8, 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;
--                }
-+                const dir = it.next() orelse break;
-+                try self.addIncludeDir(dir);
-             }
-         } else |err| switch (err) {
-             error.InvalidUtf8 => {},
-             error.EnvironmentVariableNotFound => {},
-             error.OutOfMemory => |e| return e,
+-                };
+-                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);
          }
--        if (is_nix) {
--            return self;
--        }
+     } 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");
+-    if (comptime builtin.target.isDarwin()) {
+-        try self.addIncludeDir("/usr/include");
+-        try self.addIncludeDir("/usr/local/include");
 -
--            try self.addFrameworkDir("/Library/Frameworks");
--            try self.addFrameworkDir("/System/Library/Frameworks");
+-        try self.addLibDir("/usr/lib");
+-        try self.addLibDir("/usr/local/lib");
 -
--            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();
+-        try self.addFrameworkDir("/Library/Frameworks");
+-        try self.addFrameworkDir("/System/Library/Frameworks");
 -
--            // 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.
+-        return self;
++    if (process.getEnvVarOwned(allocator, "LIBRARY_PATH")) |library_path| {
++        defer allocator.free(library_path);
++        var it = mem.tokenize(u8, 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 (comptime native_target.os.tag == .solaris) {
+@@ -106,32 +75,17 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
+         return self;
+     }
+ 
+-    if (native_target.os.tag != .windows) {
+-        const triple = try native_target.linuxTriple(allocator);
+-        const qual = native_target.cpu.arch.ptrBitWidth();
 -
--            try self.addIncludeDir("/usr/local/include");
--            try self.addLibDirFmt("/usr/local/lib{d}", .{qual});
--            try self.addLibDir("/usr/local/lib");
+-        // 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.addIncludeDirFmt("/usr/include/{s}", .{triple});
--            try self.addLibDirFmt("/usr/lib/{s}", .{triple});
+-        try self.addIncludeDir("/usr/local/include");
+-        try self.addLibDirFmt("/usr/local/lib{d}", .{qual});
+-        try self.addLibDir("/usr/local/lib");
 -
--            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");
+-        try self.addIncludeDirFmt("/usr/include/{s}", .{triple});
+-        try self.addLibDirFmt("/usr/lib/{s}", .{triple});
 -
--            // 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;
+-        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(u8, 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;