[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
37/60: gnu: Add zig-0.11.
From: |
guix-commits |
Subject: |
37/60: gnu: Add zig-0.11. |
Date: |
Mon, 18 Nov 2024 07:16:53 -0500 (EST) |
hako pushed a commit to branch wip-zig-bootstrap
in repository guix.
commit e862ea932e57b96c16ecca6de4160c3219ee6beb
Author: Hilton Chain <hako@ultrarare.space>
AuthorDate: Mon Nov 11 11:10:16 2024 +0800
gnu: Add zig-0.11.
* gnu/packages/patches/zig-0.11-fix-runpath.patch: New file.
* gnu/packages/patches/zig-0.11-use-system-paths.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register them.
* gnu/packages/zig.scm (zig-0.11): New variable.
Change-Id: I2507af62918f3989967d55dec942b84655d6d8bd
---
gnu/local.mk | 2 +
gnu/packages/patches/zig-0.11-fix-runpath.patch | 47 +++++++++++
.../patches/zig-0.11-use-system-paths.patch | 92 ++++++++++++++++++++++
gnu/packages/zig.scm | 55 +++++++++++++
4 files changed, 196 insertions(+)
diff --git a/gnu/local.mk b/gnu/local.mk
index f63aa391ed..f1e1923318 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2378,6 +2378,8 @@ dist_patch_DATA =
\
%D%/packages/patches/zig-0.10.0-675-TypeOf-hack.patch \
%D%/packages/patches/zig-0.10.0-747-CallOptions.patch \
%D%/packages/patches/zig-0.10.0-1638-re-add-qualCast.patch \
+ %D%/packages/patches/zig-0.11-fix-runpath.patch \
+ %D%/packages/patches/zig-0.11-use-system-paths.patch \
%D%/packages/patches/zsh-egrep-failing-test.patch \
%D%/packages/patches/zuo-bin-sh.patch
diff --git a/gnu/packages/patches/zig-0.11-fix-runpath.patch
b/gnu/packages/patches/zig-0.11-fix-runpath.patch
new file mode 100644
index 0000000000..cfd3881671
--- /dev/null
+++ b/gnu/packages/patches/zig-0.11-fix-runpath.patch
@@ -0,0 +1,47 @@
+From 7d73a0a11499d55ec5b3f836a777f68bbc53e815 Mon Sep 17 00:00:00 2001
+From: Hilton Chain <hako@ultrarare.space>
+Date: Thu, 14 Nov 2024 14:13:02 +0800
+Subject: [PATCH 2/5] Fix RUNPATH issue.
+
+Add needed libraries and libc to RUNPATH when CROSS_LIBRARY_PATH or
LIBRARY_PATH
+is set.
+---
+ src/Compilation.zig | 4 +++-
+ src/link/Elf.zig | 6 ++++++
+ 2 files changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/src/Compilation.zig b/src/Compilation.zig
+index a08c3e09f4..33e86dc24e 100644
+--- a/src/Compilation.zig
++++ b/src/Compilation.zig
+@@ -1542,7 +1542,9 @@ pub fn create(gpa: Allocator, options: InitOptions)
!*Compilation {
+ .llvm_cpu_features = llvm_cpu_features,
+ .skip_linker_dependencies = options.skip_linker_dependencies,
+ .parent_compilation_link_libc =
options.parent_compilation_link_libc,
+- .each_lib_rpath = options.each_lib_rpath orelse false,
++ .each_lib_rpath = std.process.hasEnvVar(gpa,
"CROSS_LIBRARY_PATH") catch false or
++ std.process.hasEnvVar(gpa, "LIBRARY_PATH") catch false or
++ options.each_lib_rpath orelse false,
+ .build_id = build_id,
+ .cache_mode = cache_mode,
+ .disable_lld_caching = options.disable_lld_caching or cache_mode
== .whole,
+diff --git a/src/link/Elf.zig b/src/link/Elf.zig
+index dd88d47fab..b6e3944725 100644
+--- a/src/link/Elf.zig
++++ b/src/link/Elf.zig
+@@ -1730,6 +1730,12 @@ fn linkWithLLD(self: *Elf, comp: *Compilation,
prog_node: *std.Progress.Node) !v
+ }
+ }
+ }
++ if (self.base.options.link_libc and self.base.options.link_mode
== .Dynamic) {
++ if (self.base.options.libc_installation) |libc_installation| {
++ try argv.append("-rpath");
++ try argv.append(libc_installation.crt_dir.?);
++ }
++ }
+ }
+
+ for (self.base.options.lib_dirs) |lib_dir| {
+--
+2.46.0
+
diff --git a/gnu/packages/patches/zig-0.11-use-system-paths.patch
b/gnu/packages/patches/zig-0.11-use-system-paths.patch
new file mode 100644
index 0000000000..12e022264e
--- /dev/null
+++ b/gnu/packages/patches/zig-0.11-use-system-paths.patch
@@ -0,0 +1,92 @@
+From b5349aafd31d85b684b4412206b5e2d340c482c6 Mon Sep 17 00:00:00 2001
+From: Hilton Chain <hako@ultrarare.space>
+Date: Wed, 13 Nov 2024 12:54:43 +0800
+Subject: [PATCH 3/5] Use system paths.
+
+Prefer Guix search paths and support Guix cross builds.
+---
+ lib/std/zig/system/NativePaths.zig | 53 ++++++++++++++++++++++++++++++
+ src/main.zig | 3 +-
+ 2 files changed, 55 insertions(+), 1 deletion(-)
+
+diff --git a/lib/std/zig/system/NativePaths.zig
b/lib/std/zig/system/NativePaths.zig
+index 4c8f1286b8..b738f6a9c2 100644
+--- a/lib/std/zig/system/NativePaths.zig
++++ b/lib/std/zig/system/NativePaths.zig
+@@ -17,6 +17,59 @@ warnings: std.ArrayListUnmanaged([]const u8) = .{},
+ pub fn detect(arena: Allocator, native_info: NativeTargetInfo) !NativePaths {
+ const native_target = native_info.target;
+ var self: NativePaths = .{ .arena = arena };
++ const getenv_available = !(builtin.os.tag == .windows or (builtin.os.tag
== .wasi and !builtin.link_libc));
++ var is_guix = false;
++ var is_cross_guix = false;
++ if (getenv_available) {
++ if (std.os.getenv("CROSS_C_INCLUDE_PATH")) |c_include_path| {
++ is_cross_guix = true;
++ var it = mem.tokenizeScalar(u8, c_include_path, ':');
++ while (it.next()) |dir| {
++ try self.addIncludeDir(dir);
++ }
++ }
++ if (std.os.getenv("CROSS_CPLUS_INCLUDE_PATH")) |cplus_include_path| {
++ is_cross_guix = true;
++ var it = mem.tokenizeScalar(u8, cplus_include_path, ':');
++ while (it.next()) |dir| {
++ try self.addIncludeDir(dir);
++ }
++ }
++ if (std.os.getenv("CROSS_LIBRARY_PATH")) |library_path| {
++ is_cross_guix = true;
++ var it = mem.tokenizeScalar(u8, library_path, ':');
++ while (it.next()) |dir| {
++ try self.addLibDir(dir);
++ }
++ }
++ if (!is_cross_guix) {
++ if (std.os.getenv("C_INCLUDE_PATH")) |c_include_path| {
++ is_guix = true;
++ var it = mem.tokenizeScalar(u8, c_include_path, ':');
++ while (it.next()) |dir| {
++ try self.addIncludeDir(dir);
++ }
++ }
++ if (std.os.getenv("CPLUS_INCLUDE_PATH")) |cplus_include_path| {
++ is_guix = true;
++ var it = mem.tokenizeScalar(u8, cplus_include_path, ':');
++ while (it.next()) |dir| {
++ try self.addIncludeDir(dir);
++ }
++ }
++ if (std.os.getenv("LIBRARY_PATH")) |library_path| {
++ is_guix = true;
++ var it = mem.tokenizeScalar(u8, library_path, ':');
++ while (it.next()) |dir| {
++ try self.addLibDir(dir);
++ }
++ }
++ }
++ }
++ if (is_guix or is_cross_guix) {
++ return self;
++ }
++
+ var is_nix = false;
+ if (process.getEnvVarOwned(arena, "NIX_CFLAGS_COMPILE"))
|nix_cflags_compile| {
+ is_nix = true;
+diff --git a/src/main.zig b/src/main.zig
+index 456886c915..b5318d58d3 100644
+--- a/src/main.zig
++++ b/src/main.zig
+@@ -2674,7 +2674,8 @@ fn buildOutputType(
+ // After this point, external_system_libs is used instead of system_libs.
+
+ // Trigger native system library path detection if necessary.
+- if (sysroot == null and cross_target.isNativeOs() and
cross_target.isNativeAbi() and
++ if (process.hasEnvVar(arena, "CROSS_LIBRARY_PATH") catch false or
++ sysroot == null and cross_target.isNativeOs() and
cross_target.isNativeAbi() and
+ (external_system_libs.len != 0 or want_native_include_dirs))
+ {
+ const paths = std.zig.system.NativePaths.detect(arena, target_info)
catch |err| {
+--
+2.46.0
+
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index 602b06c868..38830be394 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -29,6 +29,7 @@
#:use-module (guix build-system cmake)
#:use-module (gnu packages)
#:use-module (gnu packages compression)
+ #:use-module (gnu packages gcc)
#:use-module (gnu packages llvm)
#:use-module (gnu packages llvm-meta)
#:use-module (gnu packages web))
@@ -1028,4 +1029,58 @@ toolchain. Among other features it provides
(modify-inputs (package-native-inputs base)
(replace "zig" `(,base "out")))))))
+(define-public zig-0.11
+ (package
+ (inherit zig-0.10)
+ (name "zig")
+ (version "0.11.0")
+ (source
+ (origin
+ (inherit (zig-source
+ version version
+ "0qh7c27cd4wcdjj0mbpkarvwypfk1js8hkyxs0z149qv75zkbrca"))
+ (patches
+ (search-patches
+ "zig-0.9-add-GUIX_ZIG_GLIBC_LINKER.patch"
+ "zig-0.11-fix-runpath.patch"
+ "zig-0.9-use-baseline-cpu-by-default.patch"
+ "zig-0.11-use-system-paths.patch"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments zig-0.10)
+ ((#:phases phases '%standard-phases)
+ #~(modify-phases #$phases
+ (add-after 'unpack 'prepare-source
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (install-file (search-input-file
+ (or native-inputs inputs) "bin/zig1.wasm")
+ "stage1")
+ (make-file-writable "stage1/zig1.wasm")))
+ (add-after 'install 'build-zig1
+ (lambda _
+ (invoke (string-append #$output "/bin/zig")
+ "build" "update-zig1" "--verbose")))
+ (add-after 'build-zig1 'install-zig1
+ (lambda _
+ (install-file "stage1/zig1.wasm"
+ (string-append #$output:zig1 "/bin"))))
+ ;; TODO: Disable tests for macOS target and run full test.
+ ;; Issue with glibc in CPLUS_INCLUDE_PATH:
+ ;; <https://github.com/ziglang/zig/issues/18063>.
+ (replace 'check
+ (lambda* (#:key tests? #:allow-other-keys)
+ (when tests?
+ (invoke (string-append #$output "/bin/zig")
+ "test" "-I" "test" "test/behavior.zig"))))))))
+ (inputs
+ (modify-inputs (package-inputs zig-0.10)
+ (replace "clang" clang-16)
+ (replace "lld" lld-16)))
+ (native-inputs
+ (modify-inputs (package-native-inputs zig-0.10)
+ (prepend binaryen `(,zig-0.10.0-3985 "zig1"))
+ (replace "llvm" llvm-16)))
+ (outputs '("out" "zig1"))
+ (properties `((max-silent-time . 9600)
+ ,@(clang-compiler-cpu-architectures "16")))))
+
(define-public zig zig-0.10)
- 47/60: gnu: Add zig-0.11.0-3245., (continued)
- 47/60: gnu: Add zig-0.11.0-3245., guix-commits, 2024/11/18
- 58/60: build/zig: Adjust the build triplets for some systems., guix-commits, 2024/11/18
- 04/60: gnu: zig-0.10: Fix lint warning., guix-commits, 2024/11/18
- 24/60: gnu: Add zig-0.10.0-1891., guix-commits, 2024/11/18
- 32/60: gnu: Add zig-0.10.0-3728., guix-commits, 2024/11/18
- 21/60: gnu: Add zig-0.10.0-1712., guix-commits, 2024/11/18
- 15/60: gnu: Add zig-0.10.0-1073., guix-commits, 2024/11/18
- 59/60: gnu: zig: Respect the PKG_CONFIG environment variable., guix-commits, 2024/11/18
- 19/60: gnu: Add zig-0.10.0-1657., guix-commits, 2024/11/18
- 51/60: gnu: Add zig-0.11.0-3506., guix-commits, 2024/11/18
- 37/60: gnu: Add zig-0.11.,
guix-commits <=
- 39/60: gnu: Add zig-0.11.0-384., guix-commits, 2024/11/18
- 29/60: gnu: Add zig-0.10.0-2838., guix-commits, 2024/11/18
- 60/60: DRAFT: gnu: zig: Build reproducibly., guix-commits, 2024/11/18
- 22/60: gnu: Add zig-0.10.0-1713., guix-commits, 2024/11/18
- 35/60: gnu: Add zig-0.10.0-3980., guix-commits, 2024/11/18
- 53/60: gnu: Add zig-0.12., guix-commits, 2024/11/18
- 40/60: gnu: Add zig-0.11.0-494., guix-commits, 2024/11/18