guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/56: gnu: zig-0.10: Workaround RUNPATH issue.


From: guix-commits
Subject: 02/56: gnu: zig-0.10: Workaround RUNPATH issue.
Date: Tue, 12 Nov 2024 10:17:10 -0500 (EST)

hako pushed a commit to branch wip-zig-bootstrap
in repository guix.

commit 0af2d8e34b71a034b66ae76c7ef191cc7edc2a8b
Author: Hilton Chain <hako@ultrarare.space>
AuthorDate: Tue Nov 12 17:37:33 2024 +0800

    gnu: zig-0.10: Workaround RUNPATH issue.
    
    * gnu/packages/zig.scm (zig-source): Workaround RUNPATH issue.
    (zig-0.10)[source]: Use it.
    [arguments]: <#:imported-modules,#:modules,#:phases>: Add shrink-runpath 
from
    meson-build-system.
    <#:validate-runpath?>: Unset.
    
    Change-Id: Ic4fd22d8bba664e3d42f433875f9d099969b9df9
---
 gnu/packages/zig.scm | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index e8c0c0b2c3..09b7f0e39d 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -26,6 +26,7 @@
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system meson)
   #:use-module (gnu packages)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages llvm)
@@ -149,32 +150,38 @@ toolchain.  Among other features it provides
                      (when (file-exists? file)
                        (delete-file file)))
                    '("stage1/zig1.wasm"
-                     "stage1/zig1.wasm.zst"))))))
+                     "stage1/zig1.wasm.zst"))
+         ;; FIXME: <https://github.com/ziglang/zig/issues/18434>
+         ;; Workaround for Zig's RUNPATH issue on Guix.
+         ;; Add all paths within LIBRARY_PATH environment variable to RUNPATH.
+         ;; This is meant to be handled with a 'shrink-runpath' build phase.
+         (substitute* "lib/std/zig/system/NativePaths.zig"
+           (("try self.addLibDir\\(dir\\);" all)
+            (string-append all "
+                try self.addRPath(dir);")))))))
 
 (define-public zig-0.10
   (package
     (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)
+       ((#:imported-modules _ '())
+        (append %meson-build-system-modules
+                %cmake-build-system-modules))
+       ((#:modules _ '())
+        (cons '((guix build meson-build-system) #:prefix meson:)
+              '((guix build cmake-build-system)
+                (guix build utils))))
        ((#:configure-flags flags ''())
         #~(cons* "-DZIG_TARGET_MCPU=baseline"
                  "-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
@@ -202,7 +209,9 @@ toolchain.  Among other features it provides
                           "-Dskip-stage2-tests"
                           ;; Non-native tests try to link and execute 
non-native
                           ;; binaries.
-                          "-Dskip-non-native"))))))))
+                          "-Dskip-non-native"))))
+            (add-after 'strip 'shrink-runpath
+              (assoc-ref meson:%standard-phases 'shrink-runpath))))))
     (inputs
      (modify-inputs (package-inputs zig-0.9)
        (prepend zlib `(,zstd "lib"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]