unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#72386] [PATCH] gnu: zig: Update to 0.13.0.
@ 2024-07-30 21:43 Guillaume Pagnoux
  2024-07-30 22:39 ` Ekaitz Zarraga
  0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Pagnoux @ 2024-07-30 21:43 UTC (permalink / raw)
  To: 72386; +Cc: Guillaume Pagnoux, Ekaitz Zarraga

Change-Id: I642c793a0183fc774b746b6ce49c7d8b7230d043
---
Hi Guix,

This patch updates Zig to version 0.13.0. This is my first
contribution to Guix, and here are a few things to note:

- Just like version 0.10, this version is defined as a variant of
  another version (in this case, 0.10). I made this choice since there
  are some packages that depends on zig, specifying the exact version
  of zig they want. Ideally, we should update those packages to use
  the latest version of Zig, and simplify the zig recipe by removing
  those previous versions.
- The Zig tests are currently disabled. I could not get them to
  work. They depend on being able to link with -lrt, but I could not
  find how to provide the dependency to the tests.

Cheers !

 gnu/packages/zig.scm | 62 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index 6e399dfce3..a87060d4f6 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;; Copyright © 2021 Calum Irwin <calumirwin1@gmail.com>
 ;;; Copyright © 2022, 2023 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2024 Guillaume Pagnoux <gpagnoux@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -28,6 +29,7 @@ (define-module (gnu packages zig)
   #: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))

@@ -198,4 +200,62 @@ (define-public zig-0.10
     (properties `((max-silent-time . 9600)
                   ,@(clang-compiler-cpu-architectures "15")))))

-(define-public zig zig-0.10)
+(define-public zig-0.13
+  (package
+    (inherit zig-0.10)
+    (name "zig")
+    (version "0.13.0")
+
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ziglang/zig")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0ly8042lbsa8019g0d1jg4l06rxpq2530n9mijq66n4lmx7a5976"))))
+
+    (arguments
+     (substitute-keyword-arguments (package-arguments zig-0.9)
+       ((#:configure-flags flags
+         ''())
+        #~(cons* "-DZIG_TARGET_MCPU=baseline" "-DZIG_SHARED_LLVM=ON"
+                 #$flags))
+
+       ((#:tests? _ #f)
+        #f)
+
+       ((#:phases phases
+         '%standard-phases)
+        #~(modify-phases #$phases
+            #$@(if (target-riscv64?)
+                   `((delete 'adjust-tests))
+                   '())
+            (add-after 'unpack 'set-CC
+              (lambda _
+                ;; 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))))
+            (add-after 'patch-source-shebangs 'patch-more-shebangs
+              (lambda* (#:key inputs #:allow-other-keys)
+                ;; Zig uses information about /usr/bin/env to determine the
+                ;; version of glibc and other data.
+                (substitute* "lib/std/zig/system.zig"
+                  (("/usr/bin/env")
+                   (search-input-file inputs "/bin/env")))))))))
+
+    (inputs (modify-inputs (package-inputs zig-0.10)
+              (prepend `(,gcc "lib"))
+              (replace "clang" clang-18)
+              (replace "lld" lld-18)))
+
+    (native-inputs (modify-inputs (package-native-inputs zig-0.10)
+                     (replace "llvm" llvm-18)))
+
+    (properties `((max-silent-time . 9600) ,@(clang-compiler-cpu-architectures
+                                              "18")))))
+
+(define-public zig
+  zig-0.13)

base-commit: 2aa0127d4e3d2363c04caab88137b070b6cf1318
--
2.45.2




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [bug#72386] [PATCH] gnu: zig: Update to 0.13.0.
  2024-07-30 21:43 [bug#72386] [PATCH] gnu: zig: Update to 0.13.0 Guillaume Pagnoux
@ 2024-07-30 22:39 ` Ekaitz Zarraga
  0 siblings, 0 replies; 2+ messages in thread
From: Ekaitz Zarraga @ 2024-07-30 22:39 UTC (permalink / raw)
  To: Guillaume Pagnoux, 72386, Hilton Chain

Hi,

On 2024-07-30 23:43, Guillaume Pagnoux wrote:
> Change-Id: I642c793a0183fc774b746b6ce49c7d8b7230d043
> ---
> Hi Guix,
> 
> This patch updates Zig to version 0.13.0. This is my first
> contribution to Guix, and here are a few things to note:
> 
> - Just like version 0.10, this version is defined as a variant of
>    another version (in this case, 0.10). I made this choice since there
>    are some packages that depends on zig, specifying the exact version
>    of zig they want. Ideally, we should update those packages to use
>    the latest version of Zig, and simplify the zig recipe by removing
>    those previous versions.
> - The Zig tests are currently disabled. I could not get them to
>    work. They depend on being able to link with -lrt, but I could not
>    find how to provide the dependency to the tests.
> 
> Cheers !

Thanks for the patch!

There's a problem though: Zig comes with some binaries (the wasm 
bootstrap), which go against of the Guix policy.
Hilton Chain and myself have take a look to this very issue, trying to 
bootstrap it properly, but its taking time.

About the tests, the zig package in nix, which is (I think) maintained 
by the zig author, uses only the behavior tests.

I did a similar package for myself in the following link, that passes 
the behavior tests:

https://git.elenq.tech/guix-packages/tree/zig.scm?id=214f27145ea93dcab99929586df3259acf77d7c9

So, yes. We are trying to add Zig. Sadly, our free-software and 
no-binaries policies don't allow us to include the package just like this.

Thanks again for your contribution.

I hope we can add a modified version of it soon to Guix.

Best,
Ekaitz

>   gnu/packages/zig.scm | 62 +++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 61 insertions(+), 1 deletion(-)
> 
> diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
> index 6e399dfce3..a87060d4f6 100644
> --- a/gnu/packages/zig.scm
> +++ b/gnu/packages/zig.scm
> @@ -3,6 +3,7 @@
>   ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
>   ;;; Copyright © 2021 Calum Irwin <calumirwin1@gmail.com>
>   ;;; Copyright © 2022, 2023 Efraim Flashner <efraim@flashner.co.il>
> +;;; Copyright © 2024 Guillaume Pagnoux <gpagnoux@gmail.com>
>   ;;;
>   ;;; This file is part of GNU Guix.
>   ;;;
> @@ -28,6 +29,7 @@ (define-module (gnu packages zig)
>     #: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))
> 
> @@ -198,4 +200,62 @@ (define-public zig-0.10
>       (properties `((max-silent-time . 9600)
>                     ,@(clang-compiler-cpu-architectures "15")))))
> 
> -(define-public zig zig-0.10)
> +(define-public zig-0.13
> +  (package
> +    (inherit zig-0.10)
> +    (name "zig")
> +    (version "0.13.0")
> +
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/ziglang/zig")
> +             (commit version)))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32 "0ly8042lbsa8019g0d1jg4l06rxpq2530n9mijq66n4lmx7a5976"))))
> +
> +    (arguments
> +     (substitute-keyword-arguments (package-arguments zig-0.9)
> +       ((#:configure-flags flags
> +         ''())
> +        #~(cons* "-DZIG_TARGET_MCPU=baseline" "-DZIG_SHARED_LLVM=ON"
> +                 #$flags))
> +
> +       ((#:tests? _ #f)
> +        #f)
> +
> +       ((#:phases phases
> +         '%standard-phases)
> +        #~(modify-phases #$phases
> +            #$@(if (target-riscv64?)
> +                   `((delete 'adjust-tests))
> +                   '())
> +            (add-after 'unpack 'set-CC
> +              (lambda _
> +                ;; 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))))
> +            (add-after 'patch-source-shebangs 'patch-more-shebangs
> +              (lambda* (#:key inputs #:allow-other-keys)
> +                ;; Zig uses information about /usr/bin/env to determine the
> +                ;; version of glibc and other data.
> +                (substitute* "lib/std/zig/system.zig"
> +                  (("/usr/bin/env")
> +                   (search-input-file inputs "/bin/env")))))))))
> +
> +    (inputs (modify-inputs (package-inputs zig-0.10)
> +              (prepend `(,gcc "lib"))
> +              (replace "clang" clang-18)
> +              (replace "lld" lld-18)))
> +
> +    (native-inputs (modify-inputs (package-native-inputs zig-0.10)
> +                     (replace "llvm" llvm-18)))
> +
> +    (properties `((max-silent-time . 9600) ,@(clang-compiler-cpu-architectures
> +                                              "18")))))
> +
> +(define-public zig
> +  zig-0.13)
> 
> base-commit: 2aa0127d4e3d2363c04caab88137b070b6cf1318
> --
> 2.45.2
> 
> 







^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-31  0:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-30 21:43 [bug#72386] [PATCH] gnu: zig: Update to 0.13.0 Guillaume Pagnoux
2024-07-30 22:39 ` Ekaitz Zarraga

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).