unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Josselin Poiret via Guix-patches via <guix-patches@gnu.org>
To: 63012@debbugs.gnu.org
Cc: Josselin Poiret <dev@jpoiret.xyz>
Subject: [bug#63012] [PATCH core-updates] gnu: zig: Fix build.
Date: Sat, 22 Apr 2023 13:34:56 +0200	[thread overview]
Message-ID: <de4ece223db7b67cad1cf58065e391e6cba43894.1682163296.git.dev@jpoiret.xyz> (raw)

* gnu/packages/patches/zig-do-not-link-against-librt.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/zig.scm (zig-0.10): Use it.  Also force LLVM to be dynamically
linked, and setup the CC env variable.
(zig-0.9): Also use the above patch.
---
 gnu/local.mk                                      |  1 +
 .../patches/zig-do-not-link-against-librt.patch   | 10 ++++++++++
 gnu/packages/zig.scm                              | 15 +++++++++++----
 3 files changed, 22 insertions(+), 4 deletions(-)
 create mode 100644 gnu/packages/patches/zig-do-not-link-against-librt.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index b7af7726e8..9c2b5bbb33 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2054,6 +2054,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/xterm-370-explicit-xcursor.patch		\
   %D%/packages/patches/xygrib-fix-finding-data.patch		\
   %D%/packages/patches/yggdrasil-extra-config.patch	\
+  %D%/packages/patches/zig-do-not-link-against-librt.patch	\
   %D%/packages/patches/zig-use-system-paths.patch		\
   %D%/packages/patches/zsh-egrep-failing-test.patch
 
diff --git a/gnu/packages/patches/zig-do-not-link-against-librt.patch b/gnu/packages/patches/zig-do-not-link-against-librt.patch
new file mode 100644
index 0000000000..3239efbdd4
--- /dev/null
+++ b/gnu/packages/patches/zig-do-not-link-against-librt.patch
@@ -0,0 +1,10 @@
+--- a/src/target.zig	2023-04-22 11:44:47.917416658 +0200
++++ b/src/target.zig	2023-04-22 11:45:04.577465352 +0200
+@@ -478,7 +478,6 @@
+                 "-lpthread",
+                 "-lc",
+                 "-ldl",
+-                "-lrt",
+                 "-lutil",
+             },
+         },
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index 6d6b7ec4b4..c2f92e04e7 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -21,6 +21,7 @@
 
 (define-module (gnu packages zig)
   #:use-module (guix packages)
+  #:use-module (guix utils)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system cmake)
@@ -40,7 +41,8 @@ (define-public zig-0.10
              (commit version)))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1sh5xjsksl52i4cfv1qj36sz5h0ln7cq4pdhgs3960mk8a90im7b"))))
+        (base32 "1sh5xjsksl52i4cfv1qj36sz5h0ln7cq4pdhgs3960mk8a90im7b"))
+       (patches (search-patches "zig-do-not-link-against-librt.patch"))))
     (build-system cmake-build-system)
     (inputs
      (list clang-15 ; Clang propagates llvm.
@@ -57,14 +59,18 @@ (define-public zig-0.10
                                    (%current-target-system))
                    '())
              (string-append "-DZIG_TARGET_MCPU=baseline")
+             "-DZIG_SHARED_LLVM=ON"
              (string-append "-DZIG_LIB_DIR=" (assoc-ref %outputs "out")
                             "/lib/zig"))
        #:validate-runpath? #f       ; TODO: zig binary can't find ld-linux.
        #:out-of-source? #f ; for tests
        #:phases
        (modify-phases %standard-phases
-         (add-after 'configure 'set-cache-dir
-           (lambda _
+         (add-after 'unpack 'set-env-variables
+           (lambda* (#:key inputs native-inputs #:allow-other-keys)
+             ;; Set CC, since the stage 2 zig relies on it to find the libc
+             ;; installation, and otherwise silently links against its own.
+             (setenv "CC" ,(cc-for-target))
              ;; Set cache dir, otherwise Zig looks for `$HOME/.cache'.
              (setenv "ZIG_GLOBAL_CACHE_DIR"
                      (string-append (getcwd) "/zig-cache"))))
@@ -130,7 +136,8 @@ (define-public zig-0.9
        (file-name (git-file-name name version))
        (sha256
         (base32 "0nfvgg23sw50ksy0z0ml6lkdsvmd0278mq29m23dbb2jsirkhry7"))
-       (patches (search-patches "zig-use-system-paths.patch"))))
+       (patches (search-patches "zig-use-system-paths.patch"
+                                "zig-do-not-link-against-librt.patch"))))
     (inputs
      (list clang-13 ; Clang propagates llvm.
            lld-13))

base-commit: 3f7ae420d8a54d4e2ab7f349c40d8930fe9e0771
-- 
2.39.2





             reply	other threads:[~2023-04-22 11:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-22 11:34 Josselin Poiret via Guix-patches via [this message]
2023-04-22 19:57 ` bug#63012: Close Andreas Enge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de4ece223db7b67cad1cf58065e391e6cba43894.1682163296.git.dev@jpoiret.xyz \
    --to=guix-patches@gnu.org \
    --cc=63012@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).