hako pushed a commit to branch wip-zig-bootstrap
in repository guix.
commit 276806b72c9614ad5f662ffcd01c83ee4388c59a
Author: Hilton Chain <[email protected]>
AuthorDate: Tue Nov 12 17:37:33 2024 +0800
gnu: zig-0.10: Workaround RUNPATH issue.
* gnu/packages/patches/zig-0.10-use-system-paths.patch: New file.
* gnu/local.mk (dist_patch_DATA): Regisiter it.
* gnu/packages/zig.scm (zig-source): Add it.
(zig-0.10)[source]: Use zig-source.
[arguments]: <#:validate-runpath?>: Unset.
Change-Id: Ic4fd22d8bba664e3d42f433875f9d099969b9df9
---
gnu/local.mk | 1 +
.../patches/zig-0.10-use-system-paths.patch | 47 ++++++++++++++++++++++
gnu/packages/zig.scm | 20 ++++-----
3 files changed, 55 insertions(+), 13 deletions(-)
diff --git a/gnu/local.mk b/gnu/local.mk
index 1f48fddc9e..c07ff4fdae 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2364,6 +2364,7 @@ dist_patch_DATA =
\
%D%/packages/patches/xygrib-newer-proj.patch \
%D%/packages/patches/yggdrasil-extra-config.patch \
%D%/packages/patches/zig-0.9-riscv-support.patch \
+ %D%/packages/patches/zig-0.10-use-system-paths.patch \
%D%/packages/patches/zig-use-baseline-cpu-by-default.patch \
%D%/packages/patches/zig-use-system-paths.patch \
%D%/packages/patches/zsh-egrep-failing-test.patch \
diff --git a/gnu/packages/patches/zig-0.10-use-system-paths.patch
b/gnu/packages/patches/zig-0.10-use-system-paths.patch
new file mode 100644
index 0000000000..26ee8912c2
--- /dev/null
+++ b/gnu/packages/patches/zig-0.10-use-system-paths.patch
@@ -0,0 +1,47 @@
+From 57c475657b544e2c7fea57a03a447c59ca11427e Mon Sep 17 00:00:00 2001
+From: Hilton Chain <[email protected]>
+Date: Wed, 13 Nov 2024 12:54:43 +0800
+Subject: [PATCH] Use system paths.
+
+Add support for "CROSS_" environment variables, and set RUNPATH for directories
+in CROSS_LIBRARY_PATH (or LIBRARY_PATH).
+---
+ lib/std/zig/system/NativePaths.zig | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/lib/std/zig/system/NativePaths.zig
b/lib/std/zig/system/NativePaths.zig
+index 2c4db3ec85..334b396256 100644
+--- a/lib/std/zig/system/NativePaths.zig
++++ b/lib/std/zig/system/NativePaths.zig
+@@ -140,24 +140,25 @@ pub fn detect(allocator: Allocator, native_info:
NativeTargetInfo) !NativePaths
+ // variables to search for headers and libraries.
+ // We use os.getenv here since this part won't be executed on
+ // windows, to get rid of unnecessary error handling.
+- if (std.os.getenv("C_INCLUDE_PATH")) |c_include_path| {
++ if (std.os.getenv("CROSS_C_INCLUDE_PATH") orelse
std.os.getenv("C_INCLUDE_PATH")) |c_include_path| {
+ var it = mem.tokenize(u8, c_include_path, ":");
+ while (it.next()) |dir| {
+ try self.addIncludeDir(dir);
+ }
+ }
+
+- if (std.os.getenv("CPLUS_INCLUDE_PATH")) |cplus_include_path| {
++ if (std.os.getenv("CROSS_CPLUS_INCLUDE_PATH") orelse
std.os.getenv("CPLUS_INCLUDE_PATH")) |cplus_include_path| {
+ var it = mem.tokenize(u8, cplus_include_path, ":");
+ while (it.next()) |dir| {
+ try self.addIncludeDir(dir);
+ }
+ }
+
+- if (std.os.getenv("LIBRARY_PATH")) |library_path| {
++ if (std.os.getenv("CROSS_LIBRARY_PATH") orelse
std.os.getenv("LIBRARY_PATH")) |library_path| {
+ var it = mem.tokenize(u8, library_path, ":");
+ while (it.next()) |dir| {
+ try self.addLibDir(dir);
++ try self.addRPath(dir);
+ }
+ }
+ }
+--
+2.46.0
+
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index cd8d5fbe3f..7f753b1e2b 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -47,7 +47,10 @@
;; CROSS_LIBRARY_PATH or LIBRARY_PATH environment variable to RUNPATH.
;; This is meant to be handled with a 'shrink-runpath' build phase.
;; May be related: <https://github.com/ziglang/zig/issues/18434>.
- (search-patches "zig-use-system-paths.patch")))
+ (search-patches
+ (if (version>=? version "0.10")
+ "zig-0.10-use-system-paths.patch"
+ "zig-use-system-paths.patch"))))
(snippet
#~(for-each (lambda (file)
(when (file-exists? file)
@@ -170,16 +173,9 @@ toolchain. Among other features it provides
(inherit zig-0.9)
(name "zig")
(version "0.10.1")
- (source
- (origin
- (method git-fetch)
- (uri (git-reference
- (url "https://github.com/ziglang/zig.git")
- (commit version)))
- (file-name (git-file-name name version))
- (sha256
- (base32 "1sh5xjsksl52i4cfv1qj36sz5h0ln7cq4pdhgs3960mk8a90im7b"))
- (patches (search-patches "zig-use-baseline-cpu-by-default.patch"))))
+ (source (zig-source
+ version version
+ "1sh5xjsksl52i4cfv1qj36sz5h0ln7cq4pdhgs3960mk8a90im7b"))
(arguments
(substitute-keyword-arguments (package-arguments zig-0.9)
((#:configure-flags flags ''())
@@ -187,8 +183,6 @@ toolchain. Among other features it provides
"-DZIG_SHARED_LLVM=ON"
(string-append "-DZIG_LIB_DIR=" #$output "/lib/zig")
#$flags))
- ;; TODO: zig binary can't find ld-linux.
- ((#:validate-runpath? _ #t) #f)
((#:tests? _ #t) #t)
((#:phases phases '%standard-phases)
#~(modify-phases #$phases