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>
This commit is contained in:
Calum Irwin 2022-01-19 08:11:25 +00:00 committed by Ludovic Courtès
parent c9627323ec
commit 6504587168
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 154 additions and 148 deletions

View file

@ -1,14 +1,14 @@
This test fails with "error.CompilationIncorrectlySucceeded". This test fails with "error.CompilationIncorrectlySucceeded".
diff --git a/test/compile_errors.zig b/test/compile_errors.zig diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index fd1255c..20d5548 100644 index b1eaa0302..621f9db0a 100644
--- a/test/compile_errors.zig --- a/test/compile_errors.zig
+++ b/test/compile_errors.zig +++ b/test/compile_errors.zig
@@ -2751,15 +2751,15 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { @@ -2943,15 +2943,15 @@ pub fn addCases(ctx: *TestContext) !void {
"tmp.zig:3:5: error: dependency on libc must be explicitly specified in the build command", "tmp.zig:3:5: error: dependency on libc must be explicitly specified in the build command",
}); });
- cases.addTest("libc headers note", - ctx.testErrStage1("libc headers note",
- \\const c = @cImport(@cInclude("stdio.h")); - \\const c = @cImport(@cInclude("stdio.h"));
- \\export fn entry() void { - \\export fn entry() void {
- \\ _ = c.printf("hello, world!\n"); - \\ _ = c.printf("hello, world!\n");
@ -17,15 +17,15 @@ index fd1255c..20d5548 100644
- "tmp.zig:1:11: error: C import failed", - "tmp.zig:1:11: error: C import failed",
- "tmp.zig:1:11: note: libc headers not available; compilation does not link against libc", - "tmp.zig:1:11: note: libc headers not available; compilation does not link against libc",
- }); - });
+// cases.addTest("libc headers note", + // ctx.testErrStage1("libc headers note",
+// \\const c = @cImport(@cInclude("stdio.h")); + // \\const c = @cImport(@cInclude("stdio.h"));
+// \\export fn entry() void { + // \\export fn entry() void {
+// \\ _ = c.printf("hello, world!\n"); + // \\ _ = c.printf("hello, world!\n");
+// \\} + // \\}
+// , &[_][]const u8{ + // , &[_][]const u8{
+// "tmp.zig:1:11: error: C import failed", + // "tmp.zig:1:11: error: C import failed",
+// "tmp.zig:1:11: note: libc headers not available; compilation does not link against libc", + // "tmp.zig:1:11: note: libc headers not available; compilation does not link against libc",
+// }); + // });
} }
cases.addTest("comptime vector overflow shows the index", ctx.testErrStage1("comptime vector overflow shows the index",

View file

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

View file

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Liliana Marie Prikler <liliana.prikler@gmail.com> ;;; Copyright © 2021 Liliana Marie Prikler <liliana.prikler@gmail.com>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2021 Calum Irwin <calumirwin1@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -28,7 +29,7 @@ (define-module (gnu packages zig)
(define-public zig (define-public zig
(package (package
(name "zig") (name "zig")
(version "0.8.1") (version "0.9.0")
(source (source
(origin (origin
(method git-fetch) (method git-fetch)
@ -37,18 +38,18 @@ (define-public zig
(commit version))) (commit version)))
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 "147qx7xgj0r353wh5ragzn6kmm1vrf31i8038z3zqwjnqqgqxi6c")) (base32 "1zdz5s434c48z3y0c8l9wm2z1gxa7yyzd53zmr68lwj6mcl7by8x"))
(patches (patches
(search-patches (search-patches
"zig-disable-libc-note-test.patch" "zig-disable-libc-note-test.patch"
"zig-use-system-paths.patch")))) "zig-use-system-paths.patch"))))
(build-system cmake-build-system) (build-system cmake-build-system)
(inputs (inputs
(list clang-12 ; Clang propagates llvm. (list clang-13 ; Clang propagates llvm.
lld-12)) lld))
;; Zig compiles fine with GCC, but also needs native LLVM libraries. ;; Zig compiles fine with GCC, but also needs native LLVM libraries.
(native-inputs (native-inputs
(list llvm-12)) (list llvm-13))
(arguments (arguments
`(#:configure-flags `(#:configure-flags
(list ,@(if (%current-target-system) (list ,@(if (%current-target-system)