GNU bug report logs - #50449
[PATCH] Add zig

Previous Next

Package: guix-patches;

Reported by: Andrew Patterson <andrewpatt7 <at> gmail.com>

Date: Tue, 7 Sep 2021 07:07:01 UTC

Severity: normal

Tags: patch

Merged with 39480, 47006

Done: Liliana Marie Prikler <liliana.prikler <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50449 in the body.
You can then email your comments to 50449 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#50449; Package guix-patches. (Tue, 07 Sep 2021 07:07:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andrew Patterson <andrewpatt7 <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 07 Sep 2021 07:07:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andrew Patterson <andrewpatt7 <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Andrew Patterson <andrewpatt7 <at> gmail.com>
Subject: [PATCH] Add zig
Date: Tue,  7 Sep 2021 01:22:28 -0400
---
Note that this is a minor version behind; zig 0.8.0 depends on all the
clang headers version 12.x, and the current version of lld is 11.x.

 gnu/packages/zig.scm | 73 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 gnu/packages/zig.scm

diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
new file mode 100644
index 0000000000..bb8af0c98d
--- /dev/null
+++ b/gnu/packages/zig.scm
@@ -0,0 +1,73 @@
+(define-module (gnu packages zig)
+  #:use-module (guix packages)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cmake)
+  #:use-module ((guix licenses) #:prefix l:)
+  #:use-module (guix build utils)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages llvm)
+  #:use-module (guix utils))
+
+;; Zig versions depend on specific LLVM major versions; should be able to update
+;; to 0.8.x with lld <at> 12
+(define-public zig
+  (package
+    (name "zig")
+    (version "0.7.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ziglang/zig")
+             (commit version)))
+       (sha256
+        (base32
+         "0gq8xjqr3n38i2adkv9vf936frac80wh72dvhh4m5s66yafmhphg"))))
+    (build-system cmake-build-system)
+    (inputs
+     `(("llvm" ,llvm-11)
+       ("clang-toolchain" ,clang-toolchain-11)
+       ("lld" ,lld))) ; is currently version 11
+    (arguments
+     `(#:tests? #f
+       #:phases (modify-phases %standard-phases
+                  (add-before 'install 'set-cachedir
+                    (lambda* _ ;; See [[https://github.com/ziglang/zig/issues/6810]]
+                      (setenv "XDG_CACHE_HOME" "/tmp/"))))))
+    (home-page "https://ziglang.org/")
+    (synopsis
+     "Programming language for maintaining robust, optimal, and reusable software")
+    (description
+     "Zig is a general-purpose programming language and toolchain for
+maintaining robust, optimal, and reusable software.
+
+⚡ A Simple Language
+
+Focus on debugging your application rather than debugging your programming
+language knowledge.
+@itemize @bullet
+@item No hidden control flow.
+@item No hidden memory allocations.
+@item No preprocessor, no macros.
+@end itemize
+
+⚡ Comptime
+
+A fresh approach to metaprogramming based on compile-time code execution and
+lazy evaluation.
+@itemize @bullet
+@item Call any function at compile-time.
+@item Manipulate types as values without runtime overhead.
+@item Comptime emulates the target architecture.
+@end itemize
+
+⚡ Performance Meets Safety
+
+Write fast, clear code capable of handling all error conditions.
+@itemize @bullet
+@item The language gracefully guides your error handling logic.
+@item Configurable runtime checks help you strike a balance between performance
+and safety guarantees.
+@item Take advantage of vector types to express SIMD instructions portably.
+@end itemize")
+    (license l:expat)))
-- 
2.33.0





Information forwarded to guix-patches <at> gnu.org:
bug#50449; Package guix-patches. (Tue, 07 Sep 2021 17:22:02 GMT) Full text and rfc822 format available.

Message #8 received at 50449 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Patterson <andrewpatt7 <at> gmail.com>
To: 50449 <at> debbugs.gnu.org
Cc: Andrew Patterson <andrewpatt7 <at> gmail.com>
Subject: [PATCH] Add zig
Date: Tue,  7 Sep 2021 13:21:05 -0400
---
I forgot the copyright header last time; here it is with it.

 gnu/packages/zig.scm | 91 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 gnu/packages/zig.scm

diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
new file mode 100644
index 0000000000..59056a1f88
--- /dev/null
+++ b/gnu/packages/zig.scm
@@ -0,0 +1,91 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Andrew Patterson <andrewpatt7 <at> gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages zig)
+  #:use-module (guix packages)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cmake)
+  #:use-module ((guix licenses) #:prefix l:)
+  #:use-module (guix build utils)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages llvm)
+  #:use-module (guix utils))
+
+;; Zig versions depend on specific LLVM major versions; should be able to update
+;; to 0.8.x with lld <at> 12
+(define-public zig
+  (package
+    (name "zig")
+    (version "0.7.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ziglang/zig")
+             (commit version)))
+       (sha256
+        (base32
+         "0gq8xjqr3n38i2adkv9vf936frac80wh72dvhh4m5s66yafmhphg"))))
+    (build-system cmake-build-system)
+    (inputs
+     `(("llvm" ,llvm-11)
+       ("clang-toolchain" ,clang-toolchain-11)
+       ("lld" ,lld))) ; is currently version 11
+    (arguments
+     `(#:tests? #f
+       #:phases (modify-phases %standard-phases
+                  (add-before 'install 'set-cachedir
+                    (lambda* _ ;; See [[https://github.com/ziglang/zig/issues/6810]]
+                      (setenv "XDG_CACHE_HOME" "/tmp/"))))))
+    (home-page "https://ziglang.org/")
+    (synopsis
+     "Programming language for maintaining robust, optimal, and reusable software")
+    (description
+     "Zig is a general-purpose programming language and toolchain for
+maintaining robust, optimal, and reusable software.
+
+⚡ A Simple Language
+
+Focus on debugging your application rather than debugging your programming
+language knowledge.
+@itemize @bullet
+@item No hidden control flow.
+@item No hidden memory allocations.
+@item No preprocessor, no macros.
+@end itemize
+
+⚡ Comptime
+
+A fresh approach to metaprogramming based on compile-time code execution and
+lazy evaluation.
+@itemize @bullet
+@item Call any function at compile-time.
+@item Manipulate types as values without runtime overhead.
+@item Comptime emulates the target architecture.
+@end itemize
+
+⚡ Performance Meets Safety
+
+Write fast, clear code capable of handling all error conditions.
+@itemize @bullet
+@item The language gracefully guides your error handling logic.
+@item Configurable runtime checks help you strike a balance between performance
+and safety guarantees.
+@item Take advantage of vector types to express SIMD instructions portably.
+@end itemize")
+    (license l:expat)))
-- 
2.33.0





Information forwarded to guix-patches <at> gnu.org:
bug#50449; Package guix-patches. (Wed, 08 Sep 2021 10:12:01 GMT) Full text and rfc822 format available.

Message #11 received at 50449 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Patterson <andrewpatt7 <at> gmail.com>
To: 50449 <at> debbugs.gnu.org
Cc: Andrew Patterson <andrewpatt7 <at> gmail.com>
Subject: [PATCH] Add zig
Date: Wed,  8 Sep 2021 06:11:24 -0400
---
Confusion between my main guix install and what I'm working on led to
issues.

Current status as to the Submitting Paches checklist in the info page:
1. That's the hash for 0.7.1
2. I've added a synopsis and description
3. I don't know what ~guix lint~'s complaint that "the source file name
should contain the package name" means; otherwise, it's fine
4. It builds on x64 linux.
5. I haven't tried to build it on other platforms; the inputs might need
to be native-inputs, but I'm not sure
6. It has a bundled libc, but that's because zig has a c compiler built
in for some reason.
7. The ~guix size~ output seems reasonable.
8. There shouldn't be any dependent packages, since it's new.
9. ~guix build --rounds=2 zig~ worked fine.
10. Not relevant.
11. The patch is all adding zig.
12. I wrote the patch in emacs, so the indentation should be fine.
13. I don't think there are mirror urls for github?

 gnu/packages/zig.scm | 91 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 gnu/packages/zig.scm

diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
new file mode 100644
index 0000000000..ba48fcf51f
--- /dev/null
+++ b/gnu/packages/zig.scm
@@ -0,0 +1,91 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Andrew Patterson <andrewpatt7 <at> gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages zig)
+  #:use-module (guix packages)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system cmake)
+  #:use-module ((guix licenses) #:prefix l:)
+  #:use-module (guix build utils)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages llvm)
+  #:use-module (guix utils))
+
+;; Zig versions depend on specific LLVM major versions; should be able to update
+;; to 0.8.x with lld <at> 12
+(define-public zig
+  (package
+    (name "zig")
+    (version "0.7.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ziglang/zig")
+             (commit version)))
+       (sha256
+        (base32
+         "1z6c4ym9jmga46cw2arn7zv2drcpmrf3vw139gscxp27n7q2z5md"))))
+    (build-system cmake-build-system)
+    (inputs
+     `(("llvm" ,llvm-11)
+       ("clang-toolchain" ,clang-toolchain-11)
+       ("lld" ,lld))) ; is currently version 11
+    (arguments
+     `(#:tests? #f
+       #:phases (modify-phases %standard-phases
+                  (add-before 'install 'set-cachedir
+                    (lambda* _ ;; See [[https://github.com/ziglang/zig/issues/6810]]
+                      (setenv "XDG_CACHE_HOME" "/tmp/"))))))
+    (home-page "https://ziglang.org/")
+    (synopsis
+     "Programming language for maintaining robust, optimal, and reusable software")
+    (description
+     "Zig is a general-purpose programming language and toolchain for
+maintaining robust, optimal, and reusable software.
+
+⚡ A Simple Language
+
+Focus on debugging your application rather than debugging your programming
+language knowledge.
+@itemize @bullet
+@item No hidden control flow.
+@item No hidden memory allocations.
+@item No preprocessor, no macros.
+@end itemize
+
+⚡ Comptime
+
+A fresh approach to metaprogramming based on compile-time code execution and
+lazy evaluation.
+@itemize @bullet
+@item Call any function at compile-time.
+@item Manipulate types as values without runtime overhead.
+@item Comptime emulates the target architecture.
+@end itemize
+
+⚡ Performance Meets Safety
+
+Write fast, clear code capable of handling all error conditions.
+@itemize @bullet
+@item The language gracefully guides your error handling logic.
+@item Configurable runtime checks help you strike a balance between performance
+and safety guarantees.
+@item Take advantage of vector types to express SIMD instructions portably.
+@end itemize")
+    (license l:expat)))
-- 
2.33.0





Merged 39480 47006 50449. Request was from Liliana Marie Prikler <liliana.prikler <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 08 Sep 2021 22:17:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#50449; Package guix-patches. (Thu, 09 Sep 2021 01:54:02 GMT) Full text and rfc822 format available.

Message #16 received at 50449 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Patterson <andrewpatt7 <at> gmail.com>
To: 50449 <at> debbugs.gnu.org
Cc: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: Re: [PATCH] Add zig
Date: Wed, 08 Sep 2021 21:43:01 -0400
Thanks for the input, and sorry for not looking through the 
existing
bugs first.  I'll look at the merged issues(?), and I'll watch for 
the
lld version bump, but I probably won't add much to this in the 
foreseeable
future.

-- 
Andrew Patterson




Information forwarded to guix-patches <at> gnu.org:
bug#50449; Package guix-patches. (Thu, 09 Sep 2021 16:32:02 GMT) Full text and rfc822 format available.

Message #19 received at 50449 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: Liliana Prikler <liliana.prikler <at> gmail.com>
Cc: 47006 <at> debbugs.gnu.org, 50449 <at> debbugs.gnu.org, maximedevos <at> telenet.be,
 efraim <at> flashner.co.il
Subject: Re: [bug#47006] [PATCH 2/2] gnu: Add zig.
Date: Thu, 09 Sep 2021 09:31:13 -0700
Hi Liliana,

Thanks for taking a look at the recent patch and sending an updated
one.  I've been tinkering with the recent zig patch as well, so I have a
few comments.

Liliana Prikler <liliana.prikler <at> gmail.com> writes:

> * gnu/packages/zig.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it here.
> ---
>  gnu/local.mk         |  1 +
>  gnu/packages/zig.scm | 83 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 84 insertions(+)
>  create mode 100644 gnu/packages/zig.scm
>
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 2a56c4a9e2..710e5bd9df 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -598,6 +598,7 @@ GNU_SYSTEM_MODULES =				\
>    %D%/packages/xdisorg.scm			\
>    %D%/packages/xorg.scm				\
>    %D%/packages/xfce.scm				\
> +  %D%/packages/zig.scm				\
>    %D%/packages/zile.scm				\
>    %D%/packages/zwave.scm			\
>  						\
> diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
> new file mode 100644
> index 0000000000..8b9a863b4d
> --- /dev/null
> +++ b/gnu/packages/zig.scm
> @@ -0,0 +1,83 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2021 Leo Prikler <leo.prikler <at> student.tugraz.at>
> +;;;
> +;;; This file is part of GNU Guix.
> +;;;
> +;;; GNU Guix is free software; you can redistribute it and/or modify it
> +;;; under the terms of the GNU General Public License as published by
> +;;; the Free Software Foundation; either version 3 of the License, or (at
> +;;; your option) any later version.
> +;;;
> +;;; GNU Guix is distributed in the hope that it will be useful, but
> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +;;; GNU General Public License for more details.
> +;;;
> +;;; You should have received a copy of the GNU General Public License
> +;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
> +
> +(define-module (gnu packages zig)
> +  #:use-module (guix packages)
> +  #:use-module (guix git-download)
> +  #:use-module ((guix licenses) #:prefix license:)
> +  #:use-module (guix build-system cmake)
> +  #:use-module (gnu packages)
> +  #:use-module (gnu packages llvm))
> +
> +(define-public zig
> +  (package
> +    (name "zig")
> +    (version "0.8.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 "147qx7xgj0r353wh5ragzn6kmm1vrf31i8038z3zqwjnqqgqxi6c"))))
> +    (build-system cmake-build-system)
> +    ;; Zig is based on and builds itself using the Clang toolchain,
> +    ;; so add it both as inputs and native-inputs.
> +    (inputs
> +     `(("clang" ,clang-12)
> +       ("lld" ,lld-12)
> +       ("llvm" ,llvm-12)))
> +    (native-inputs
> +     `(("clang" ,clang-12)
> +       ("lld" ,lld-12)
> +       ("llvm" ,llvm-12)))

Zig is perfectly happy compiling itself with GCC, and I believe it's the
default.  I'm pretty sure it either needs no native tools, or only llvm,
but I wasn't able to test without compiling a whole GCC cross-toolchain.

For cross compiling, you will also need to add "-DZIG_TARGET_TRIPLE=" to
configure flags, and you might want to look into adding
"-DZIG_TARGET_MCPU" (should take the same values as LLVM's -mcpu) to
change the baseline CPU for ARM systems since we build for ARM7 by
default.

> +    (arguments
> +     `(#:tests? #f                       ; no check target

Did you mean to leave this in? ;)

> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'save-unpack-dir
> +           (lambda _
> +             ;; HACK: Passing unpacked source directory to 'check phase.
> +             (setenv "ZIG_SOURCE_DIR" (getcwd))
> +             #t))
> +         (add-after 'configure 'set-home
> +           (lambda _
> +             (setenv "HOME" (getcwd))    ; zig writes to $HOME/.cache
> +             #t))
> +         (delete 'check)
> +         (add-after 'install 'check
> +           (lambda* (#:key outputs tests? #:allow-other-keys)
> +             (when tests?
> +               (with-directory-excursion (getenv "ZIG_SOURCE_DIR")
> +                 (invoke (string-append (assoc-ref outputs) "out") "/bin/zig"
> +                         "build" "test"))))))))

Full tests take quite a while, (it's supposed to be "an hour or two") so
it may eventually be a good idea to limit what we test, such as using
"-Dskip-release", which tests without optimization.  IMO that should be
enough for catching any Guix-based issues with Zig.

> +    (synopsis "General purpose programming language and toolchain")
> +    (description "Zig is a general-purpose programming language and
> +toolchain.  Among other features it provides
> +@itemize
> +@item an Optional type instead of null pointers,
> +@item manual memory management,
> +@item generic data structures and functions,
> +@item compile-time reflection and compile-time code execution,
> +@item integration with C using zig as a C compiler, and
> +@item concurrency via async functions.
> +@end itemize")
> +    (home-page "https://github.com/ziglang/zig")
> +    (license license:expat)))

I don't know if it affects the license, but Zig bundles the source for
*many* components, such as glibc, musl, mingw, wasi, and from LLVM:
libcxx, libcxxabi, libunwind, and tsan.

Zig doesn't seem to honor LIBRARY_PATH, but oddly enough it honors
NIX_LDFLAGS and NIX_CFLAGS_COMPILE, so if we want it to see external
libraries, something like this is needed:

--8<---------------cut here---------------start------------->8---
         (add-after 'check 'wrap-binary
           (lambda* (#:key outputs #:allow-other-keys)
             ;; TODO: test with 'zig cc'
             (wrap-program (string-append (assoc-ref outputs "out") "/bin/zig")
               `("NIX_LDFLAGS" prefix
                 ("${LIBRARY_PATH:+-L${LIBRARY_PATH//:/ -L}}"))
               `("NIX_CFLAGS_COMPILE" prefix
                 (,(string-append
                    "${CPLUS_INCLUDE_PATH:+-isystem "
                    "${CPLUS_INCLUDE_PATH//:/ -isystem }}"))))))
--8<---------------cut here---------------end--------------->8---

I haven't tested this with 'zig cc', but this worked for compiling [0].

[0] https://github.com/andrewrk/tetris

Hope that helps,

--
Sarah




Information forwarded to guix-patches <at> gnu.org:
bug#50449; Package guix-patches. (Thu, 09 Sep 2021 18:19:02 GMT) Full text and rfc822 format available.

Message #22 received at 50449 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: 47006 <at> debbugs.gnu.org, 50449 <at> debbugs.gnu.org, maximedevos <at> telenet.be,
 efraim <at> flashner.co.il
Subject: Re: [bug#47006] [PATCH 2/2] gnu: Add zig.
Date: Thu, 09 Sep 2021 20:18:20 +0200
Hi Sarah,

Am Donnerstag, den 09.09.2021, 09:31 -0700 schrieb Sarah Morgensen:
> Liliana Prikler <liliana.prikler <at> gmail.com> writes:
> 
> > * gnu/packages/zig.scm: New file.
> > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it here.
> > ---
> >  gnu/local.mk         |  1 +
> >  gnu/packages/zig.scm | 83
> > ++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 84 insertions(+)
> >  create mode 100644 gnu/packages/zig.scm
> > 
> > diff --git a/gnu/local.mk b/gnu/local.mk
> > index 2a56c4a9e2..710e5bd9df 100644
> > --- a/gnu/local.mk
> > +++ b/gnu/local.mk
> > @@ -598,6 +598,7 @@ GNU_SYSTEM_MODULES =				
> > \
> >    %D%/packages/xdisorg.scm			\
> >    %D%/packages/xorg.scm				\
> >    %D%/packages/xfce.scm				\
> > +  %D%/packages/zig.scm				\
> >    %D%/packages/zile.scm				\
> >    %D%/packages/zwave.scm			\
> >  						\
> > diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
> > new file mode 100644
> > index 0000000000..8b9a863b4d
> > --- /dev/null
> > +++ b/gnu/packages/zig.scm
> > @@ -0,0 +1,83 @@
> > +;;; GNU Guix --- Functional package management for GNU
> > +;;; Copyright © 2021 Leo Prikler <leo.prikler <at> student.tugraz.at>
> > +;;;
> > +;;; This file is part of GNU Guix.
> > +;;;
> > +;;; GNU Guix is free software; you can redistribute it and/or
> > modify it
> > +;;; under the terms of the GNU General Public License as published
> > by
> > +;;; the Free Software Foundation; either version 3 of the License,
> > or (at
> > +;;; your option) any later version.
> > +;;;
> > +;;; GNU Guix is distributed in the hope that it will be useful,
> > but
> > +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> > +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > +;;; GNU General Public License for more details.
> > +;;;
> > +;;; You should have received a copy of the GNU General Public
> > License
> > +;;; along with GNU Guix.  If not, see <
> > http://www.gnu.org/licenses/>;.
> > +
> > +(define-module (gnu packages zig)
> > +  #:use-module (guix packages)
> > +  #:use-module (guix git-download)
> > +  #:use-module ((guix licenses) #:prefix license:)
> > +  #:use-module (guix build-system cmake)
> > +  #:use-module (gnu packages)
> > +  #:use-module (gnu packages llvm))
> > +
> > +(define-public zig
> > +  (package
> > +    (name "zig")
> > +    (version "0.8.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
> > "147qx7xgj0r353wh5ragzn6kmm1vrf31i8038z3zqwjnqqgqxi6c"))))
> > +    (build-system cmake-build-system)
> > +    ;; Zig is based on and builds itself using the Clang
> > toolchain,
> > +    ;; so add it both as inputs and native-inputs.
> > +    (inputs
> > +     `(("clang" ,clang-12)
> > +       ("lld" ,lld-12)
> > +       ("llvm" ,llvm-12)))
> > +    (native-inputs
> > +     `(("clang" ,clang-12)
> > +       ("lld" ,lld-12)
> > +       ("llvm" ,llvm-12)))
> 
> Zig is perfectly happy compiling itself with GCC, and I believe it's
> the default.  I'm pretty sure it either needs no native tools, or
> only llvm, but I wasn't able to test without compiling a whole GCC
> cross-toolchain.
> 
> For cross compiling, you will also need to add "-DZIG_TARGET_TRIPLE=" 
> to configure flags, and you might want to look into adding
> "-DZIG_TARGET_MCPU" (should take the same values as LLVM's -mcpu) to
> change the baseline CPU for ARM systems since we build for ARM7 by
> default.
I don't think we set mcpu for LLVM or Clang, so that one should be
fine.  As for ZIG_TARGET_TRIPLET and the native inputs, do you have an
amended patch already lying around?

> > +    (arguments
> > +     `(#:tests? #f                       ; no check target
> 
> Did you mean to leave this in? ;)
Pretty sure that was a copypaste error at some point, good catch.

> > +       #:phases
> > +       (modify-phases %standard-phases
> > +         (add-after 'unpack 'save-unpack-dir
> > +           (lambda _
> > +             ;; HACK: Passing unpacked source directory to 'check
> > phase.
> > +             (setenv "ZIG_SOURCE_DIR" (getcwd))
> > +             #t))
> > +         (add-after 'configure 'set-home
> > +           (lambda _
> > +             (setenv "HOME" (getcwd))    ; zig writes to
> > $HOME/.cache
> > +             #t))
> > +         (delete 'check)
> > +         (add-after 'install 'check
> > +           (lambda* (#:key outputs tests? #:allow-other-keys)
> > +             (when tests?
> > +               (with-directory-excursion (getenv "ZIG_SOURCE_DIR")
> > +                 (invoke (string-append (assoc-ref outputs) "out")
> > "/bin/zig"
> > +                         "build" "test"))))))))
> 
> Full tests take quite a while, (it's supposed to be "an hour or two")
> so it may eventually be a good idea to limit what we test, such as
> using "-Dskip-release", which tests without optimization.  IMO that
> should be enough for catching any Guix-based issues with Zig.
Is that a configure flag or a test flag?

> > +    (synopsis "General purpose programming language and
> > toolchain")
> > +    (description "Zig is a general-purpose programming language
> > and
> > +toolchain.  Among other features it provides
> > +@itemize
> > +@item an Optional type instead of null pointers,
> > +@item manual memory management,
> > +@item generic data structures and functions,
> > +@item compile-time reflection and compile-time code execution,
> > +@item integration with C using zig as a C compiler, and
> > +@item concurrency via async functions.
> > +@end itemize")
> > +    (home-page "https://github.com/ziglang/zig")
> > +    (license license:expat)))
> 
> I don't know if it affects the license, but Zig bundles the source
> for *many* components, such as glibc, musl, mingw, wasi, and from
> LLVM: libcxx, libcxxabi, libunwind, and tsan.
Good catch, could we unbundle some/all of those?

> Zig doesn't seem to honor LIBRARY_PATH, but oddly enough it honors
> NIX_LDFLAGS and NIX_CFLAGS_COMPILE, so if we want it to see external
> libraries, something like this is needed:
> 
> --8<---------------cut here---------------start------------->8---
>          (add-after 'check 'wrap-binary
>            (lambda* (#:key outputs #:allow-other-keys)
>              ;; TODO: test with 'zig cc'
>              (wrap-program (string-append (assoc-ref outputs "out")
> "/bin/zig")
>                `("NIX_LDFLAGS" prefix
>                  ("${LIBRARY_PATH:+-L${LIBRARY_PATH//:/ -L}}"))
>                `("NIX_CFLAGS_COMPILE" prefix
>                  (,(string-append
>                     "${CPLUS_INCLUDE_PATH:+-isystem "
>                     "${CPLUS_INCLUDE_PATH//:/ -isystem }}"))))))
> --8<---------------cut here---------------end--------------->8---
That is rather inelegant.  I'd prefer we patch zig to honor
LIBRARY_PATH, CPLUS_INCLUDE_FLAGS and what other important environment
variables we find.

Thanks





Information forwarded to guix-patches <at> gnu.org:
bug#50449; Package guix-patches. (Fri, 24 Sep 2021 00:18:02 GMT) Full text and rfc822 format available.

Message #25 received at 50449 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Cc: 50449 <at> debbugs.gnu.org
Subject: Re: [bug#47006] [WIP PATCH v2 2/2] gnu: Add zig.
Date: Thu, 23 Sep 2021 17:17:28 -0700
Hi Liliana,

I just thought I'd send a note that lld (and the LLVM toolchain) is now
12.0.1 in master (see a7283c1d14).

Liliana Marie Prikler <liliana.prikler <at> gmail.com> writes:

> Hi,
>
> Am Sonntag, den 12.09.2021, 15:40 -0700 schrieb Sarah Morgensen:
>> > > +       (patches
>> > > +        (search-patches
>> > > +         "zig-disable-libc-note-test.patch"
>> > Is this test really necessary to skip that test?  If not, let's try
>> > to use the command line for that.
>> 
>> We could use "-Dskip-compile-errors", but that also skips ~600 other
>> test cases.
> Point taken, let's keep it then.
>
>> > > +         ;; XXX: Remove the following patch when updating LLVM
>> > > to 12.0.1.
>> > > +         "zig-disable-MIPS-tests.patch"
>> > There's a patch for LLVM 12.0.1 waiting in the ML and we could
>> > potentially bump lld to 12.0.1 regardless.  (Can LLVM components be
>> > mix-matched like that?)
>> 
>> I have no idea if they *can*, but I'm pretty sure they're not
>> intended to be, as LLVM wants you to build everything together in one
>> big blob.
> Fair enough, I've tried to rebase this based on András patch
> regardless.  In some sense this counts as a review of #50486, but I
> obviously haven't tested all the problematic packages that would keep
> it from being merged, like mesa.
>
>> > > +         "zig-fix-cross-native-execution.patch"
>> > IIUC this is weaker than "-Dskip-non-native".  Is there a reason to
>> > include specifically these non-native tests?
>> 
>> Yes, as I wrote in the patch header, it fixes the behavior of 'zig
>> run' and 'zig test' when the target is cross-native.  Would we want
>> to stick to upstream, even if it's buggy?
> I'm not particularly sure about 'zig run', but imo we should simply
> supply the correct linker in cross-native and not worry about upstream
> bugs in the negative case.
>
>> We might want to add "-Dskip-non-native" anyway as it speeds up tests
>> by an order of magnitude, in which case tests will succeed without
>> the patch.  It looks their CI uses it "-Dskip-non-native" as well,
>> and I suppose there's not a whole lot Guix can do to mess up Zig's
>> cross-compiling anyway, since it's pretty self-contained...
> Did that.
>
>> > > +    (native-search-paths
>> > > +     (list
>> > > +      (search-path-specification
>> > > +       (variable "ZIG_INCLUDE_DIRS")
>> > > +       ;; XXX: It doesn't seem as though Zig can distinguish
>> > > between
>> > > C and C++
>> > > +       ;;      include paths, so provide both.
>> > > +       (files '("include/c++" "include")))
>> > > +      (search-path-specification
>> > > +       ;; TODO: Might be confused with "ZIG_LIB_DIR"... Maybe
>> > > use
>> > > +       ;;       "ZIG_INCLUDE_PATH" and "ZIG_LIBRARY_PATH"?
>> > > +       (variable "ZIG_LIB_DIRS")
>> > > +       (files '("lib" "lib64")))))
>> > You can rewrite "zig-use-explicit-paths.patch" in-place with Emacs'
>> > query-replace and/or sed (or even just manually, there are no lines
>> > to add or remove) if you disagree with my environment variable
>> > naming choice.  Just make sure you don't accidentally break diff by
>> > deleting trailing space.
>> > Another potential naming choice would be to prefix everything with
>> > ZIG_LIBC_ rather than simply ZIG_.  Of course I thought about that
>> > only after sending my previous mail ^^"
>> 
>> Ah, I meant to mention it in my last e-mail but I forgot.  I didn't
>> want to just go changing it on you without discussing it.
>> 
>> As far as I can tell, there's no such thing as a "Zig library" or a
>> "Zig header"; these are for including system C headers and
>> libraries.  So, I would just go with LIBRARY_PATH and
>> CPLUS_INCLUDE_PATH unless we anticipate needing to tell Zig something
>> different than what we tell GCC/Clang.  Furthermore, the in-
>> development 'zig cc' command is intended to be a drop-in replacement
>> for GCC/Clang, so it should probably honor the same environment
>> variables.
> Fair enough, I now have zig search the paths that would normally be
> expected to be accordingly set.  This leads to doubly adding
> "/include", but I suppose that's fine as we risk not including the
> right things in a C only context otherwise.
>
> Regards
>
> [2. text/x-patch; v4-0001-gnu-lld-Update-to-12.0.1.patch]...
>
> [3. text/x-patch; v4-0002-gnu-Add-zig.patch]...

--
Sarah




Information forwarded to guix-patches <at> gnu.org:
bug#50449; Package guix-patches. (Fri, 24 Sep 2021 07:45:02 GMT) Full text and rfc822 format available.

Message #28 received at 50449 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Prikler <liliana.prikler <at> gmail.com>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: 47006 <at> debbugs.gnu.org,
 András Vöröskői <voroskoi <at> gmail.com>,
 50449 <at> debbugs.gnu.org, maximedevos <at> telenet.be, efraim <at> flashner.co.il
Subject: [PATCH v5] gnu: Add zig.
Date: Thu, 9 Sep 2021 15:32:22 +0200
* gnu/packages/patches/zig-disable-libc-note-test.patch,
gnu/packages/patches/zig-use-system-paths.patch: New files.
* gnu/packages/zig.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES, dist_patch_DATA): Adjust accordingly.
---
 gnu/local.mk                                  |   3 +
 .../patches/zig-disable-libc-note-test.patch  |  31 ++++
 .../patches/zig-use-system-paths.patch        | 143 ++++++++++++++++++
 gnu/packages/zig.scm                          | 104 +++++++++++++
 4 files changed, 281 insertions(+)
 create mode 100644 gnu/packages/patches/zig-disable-libc-note-test.patch
 create mode 100644 gnu/packages/patches/zig-use-system-paths.patch
 create mode 100644 gnu/packages/zig.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index ba87264948..e8df88d7fe 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -598,6 +598,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/xdisorg.scm			\
   %D%/packages/xorg.scm				\
   %D%/packages/xfce.scm				\
+  %D%/packages/zig.scm				\
   %D%/packages/zile.scm				\
   %D%/packages/zwave.scm			\
 						\
@@ -1904,6 +1905,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/ytfzf-updates.patch        \
   %D%/packages/patches/ytnef-CVE-2021-3403.patch	\
   %D%/packages/patches/ytnef-CVE-2021-3404.patch	\
+  %D%/packages/patches/zig-disable-libc-note-test.patch         \
+  %D%/packages/patches/zig-use-system-paths.patch	        \
   %D%/packages/patches/zstd-CVE-2021-24031_CVE-2021-24032.patch	\
   %D%/packages/patches/zziplib-CVE-2018-16548.patch
 
diff --git a/gnu/packages/patches/zig-disable-libc-note-test.patch b/gnu/packages/patches/zig-disable-libc-note-test.patch
new file mode 100644
index 0000000000..971ae53912
--- /dev/null
+++ b/gnu/packages/patches/zig-disable-libc-note-test.patch
@@ -0,0 +1,31 @@
+This test fails with "error.CompilationIncorrectlySucceeded".
+
+diff --git a/test/compile_errors.zig b/test/compile_errors.zig
+index fd1255c..20d5548 100644
+--- a/test/compile_errors.zig
++++ b/test/compile_errors.zig
+@@ -2751,15 +2751,15 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
+             "tmp.zig:3:5: error: dependency on libc must be explicitly specified in the build command",
+         });
+ 
+-        cases.addTest("libc headers note",
+-            \\const c = @cImport(@cInclude("stdio.h"));
+-            \\export fn entry() void {
+-            \\    _ = c.printf("hello, world!\n");
+-            \\}
+-        , &[_][]const u8{
+-            "tmp.zig:1:11: error: C import failed",
+-            "tmp.zig:1:11: note: libc headers not available; compilation does not link against libc",
+-        });
++//        cases.addTest("libc headers note",
++//            \\const c = @cImport(@cInclude("stdio.h"));
++//            \\export fn entry() void {
++//            \\    _ = c.printf("hello, world!\n");
++//            \\}
++//        , &[_][]const u8{
++//            "tmp.zig:1:11: error: C import failed",
++//            "tmp.zig:1:11: note: libc headers not available; compilation does not link against libc",
++//        });
+     }
+ 
+     cases.addTest("comptime vector overflow shows the index",
diff --git a/gnu/packages/patches/zig-use-system-paths.patch b/gnu/packages/patches/zig-use-system-paths.patch
new file mode 100644
index 0000000000..ed122dac22
--- /dev/null
+++ b/gnu/packages/patches/zig-use-system-paths.patch
@@ -0,0 +1,143 @@
+This patch replaces the OS-specific detection mechanism by one that solely
+relies on environment variables.  This has the benefit that said environment
+variables can be used as search paths in Guix.
+
+Index: zig-0.8.1/lib/std/zig/system.zig
+===================================================================
+--- zig-0.8.1.orig/lib/std/zig/system.zig
++++ zig-0.8.1/lib/std/zig/system.zig
+@@ -39,101 +39,57 @@ pub const NativePaths = struct {
+         };
+         errdefer self.deinit();
+ 
+-        var is_nix = false;
+-        if (process.getEnvVarOwned(allocator, "NIX_CFLAGS_COMPILE")) |nix_cflags_compile| {
+-            defer allocator.free(nix_cflags_compile);
+-
+-            is_nix = true;
+-            var it = mem.tokenize(nix_cflags_compile, " ");
++        // TODO: Support cross-compile paths?
++        if (process.getEnvVarOwned(allocator, "C_INCLUDE_PATH")) |c_include_path| {
++            defer allocator.free(c_include_path);
++            var it = mem.tokenize(c_include_path, ":");
+             while (true) {
+-                const word = it.next() orelse break;
+-                if (mem.eql(u8, word, "-isystem")) {
+-                    const include_path = it.next() orelse {
+-                        try self.addWarning("Expected argument after -isystem in NIX_CFLAGS_COMPILE");
+-                        break;
+-                    };
+-                    try self.addIncludeDir(include_path);
+-                } else {
+-                    if (mem.startsWith(u8, word, "-frandom-seed=")) {
+-                        continue;
+-                    }
+-                    try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {s}", .{word});
+-                }
++                const dir = it.next() orelse break;
++                try self.addIncludeDir(dir);
+             }
+         } else |err| switch (err) {
+             error.InvalidUtf8 => {},
+             error.EnvironmentVariableNotFound => {},
+             error.OutOfMemory => |e| return e,
+         }
+-        if (process.getEnvVarOwned(allocator, "NIX_LDFLAGS")) |nix_ldflags| {
+-            defer allocator.free(nix_ldflags);
+ 
+-            is_nix = true;
+-            var it = mem.tokenize(nix_ldflags, " ");
++        if (process.getEnvVarOwned(allocator, "CPLUS_INCLUDE_PATH")) |cplus_include_path| {
++            defer allocator.free(cplus_include_path);
++            var it = mem.tokenize(cplus_include_path, ":");
+             while (true) {
+-                const word = it.next() orelse break;
+-                if (mem.eql(u8, word, "-rpath")) {
+-                    const rpath = it.next() orelse {
+-                        try self.addWarning("Expected argument after -rpath in NIX_LDFLAGS");
+-                        break;
+-                    };
+-                    try self.addRPath(rpath);
+-                } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') {
+-                    const lib_path = word[2..];
+-                    try self.addLibDir(lib_path);
+-                } else {
+-                    try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word});
+-                    break;
+-                }
++                const dir = it.next() orelse break;
++                try self.addIncludeDir(dir);
+             }
+         } else |err| switch (err) {
+             error.InvalidUtf8 => {},
+             error.EnvironmentVariableNotFound => {},
+             error.OutOfMemory => |e| return e,
+         }
+-        if (is_nix) {
+-            return self;
+-        }
+-
+-        if (comptime Target.current.isDarwin()) {
+-            try self.addIncludeDir("/usr/include");
+-            try self.addIncludeDir("/usr/local/include");
+ 
+-            try self.addLibDir("/usr/lib");
+-            try self.addLibDir("/usr/local/lib");
+-
+-            try self.addFrameworkDir("/Library/Frameworks");
+-            try self.addFrameworkDir("/System/Library/Frameworks");
+-
+-            return self;
++        if (process.getEnvVarOwned(allocator, "LIBRARY_PATH")) |library_path| {
++            defer allocator.free(library_path);
++            var it = mem.tokenize(library_path, ":");
++            while (true) {
++                const dir = it.next() orelse break;
++                try self.addLibDir(dir);
++            }
++        } else |err| switch (err) {
++            error.InvalidUtf8 => {},
++            error.EnvironmentVariableNotFound => {},
++            error.OutOfMemory => |e| return e,
+         }
+ 
+-        if (native_target.os.tag != .windows) {
+-            const triple = try native_target.linuxTriple(allocator);
+-            const qual = native_target.cpu.arch.ptrBitWidth();
+-
+-            // TODO: $ ld --verbose | grep SEARCH_DIR
+-            // the output contains some paths that end with lib64, maybe include them too?
+-            // TODO: what is the best possible order of things?
+-            // TODO: some of these are suspect and should only be added on some systems. audit needed.
+-
+-            try self.addIncludeDir("/usr/local/include");
+-            try self.addLibDirFmt("/usr/local/lib{d}", .{qual});
+-            try self.addLibDir("/usr/local/lib");
+-
+-            try self.addIncludeDirFmt("/usr/include/{s}", .{triple});
+-            try self.addLibDirFmt("/usr/lib/{s}", .{triple});
+-
+-            try self.addIncludeDir("/usr/include");
+-            try self.addLibDirFmt("/lib{d}", .{qual});
+-            try self.addLibDir("/lib");
+-            try self.addLibDirFmt("/usr/lib{d}", .{qual});
+-            try self.addLibDir("/usr/lib");
+-
+-            // example: on a 64-bit debian-based linux distro, with zlib installed from apt:
+-            // zlib.h is in /usr/include (added above)
+-            // libz.so.1 is in /lib/x86_64-linux-gnu (added here)
+-            try self.addLibDirFmt("/lib/{s}", .{triple});
++        if (process.getEnvVarOwned(allocator, "DYLD_FRAMEWORK_PATH")) |dyld_framework_path| {
++            defer allocator.free(dyld_framework_path);
++            var it = mem.tokenize(dyld_framework_path, ":");
++            while (true) {
++                const dir = it.next() orelse break;
++                try self.addFrameworkDir(dir);
++            }
++        } else |err| switch (err) {
++            error.InvalidUtf8 => {},
++            error.EnvironmentVariableNotFound => {},
++            error.OutOfMemory => |e| return e,
+         }
+ 
+         return self;
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
new file mode 100644
index 0000000000..ef5fe04c86
--- /dev/null
+++ b/gnu/packages/zig.scm
@@ -0,0 +1,104 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Liliana Prikler <liliana.prikler <at> gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages zig)
+  #:use-module (guix packages)
+  #:use-module (guix git-download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system cmake)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages llvm))
+
+(define-public zig
+  (package
+    (name "zig")
+    (version "0.8.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 "147qx7xgj0r353wh5ragzn6kmm1vrf31i8038z3zqwjnqqgqxi6c"))
+       (patches
+        (search-patches
+         "zig-disable-libc-note-test.patch"
+         "zig-use-system-paths.patch"))))
+    (build-system cmake-build-system)
+    (inputs
+     `(("clang" ,clang-12) ; Clang propagates llvm.
+       ("lld" ,lld-12)))
+    ;; Zig compiles fine with GCC, but also needs native LLVM libraries.
+    (native-inputs
+     `(("llvm" ,llvm-12)))
+    (arguments
+     `(#:configure-flags
+       (list ,@(if (%current-target-system)
+                   (string-append "-DZIG_TARGET_TRIPLE="
+                                  (%current-target-system))
+                   '()))
+       #:out-of-source? #f ; for tests
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'configure 'set-cache-dir
+           (lambda _
+             ;; Set cache dir, otherwise Zig looks for `$HOME/.cache'.
+             (setenv "ZIG_GLOBAL_CACHE_DIR"
+                     (string-append (getcwd) "/zig-cache"))))
+         (delete 'check)
+         (add-after 'install 'check
+           (lambda* (#:key outputs tests? #:allow-other-keys)
+             (when tests?
+               (invoke (string-append (assoc-ref outputs "out") "/bin/zig")
+                       ;; Testing the standard library takes >7.5GB RAM, and
+                       ;; will fail if it is OOM-killed.  The 'test-toolchain'
+                       ;; target skips standard library and doc tests.
+                       "build" "test-toolchain"
+                       ;; Stage 2 is experimental, not what we run with `zig',
+                       ;; and stage 2 tests require a lot of RAM.
+                       "-Dskip-stage2-tests"
+                       ;; Non-native tests try to link and execute non-native
+                       ;; binaries.
+                       "-Dskip-non-native")))))))
+    (native-search-paths
+     (list
+      (search-path-specification
+       (variable "C_INCLUDE_PATH")
+       (files '("include")))
+      (search-path-specification
+       (variable "CPLUS_INCLUDE_PATH")
+       (files '("include/c++" "include")))
+      (search-path-specification
+       (variable "LIBRARY_PATH")
+       (files '("lib" "lib64")))))
+    (synopsis "General purpose programming language and toolchain")
+    (description "Zig is a general-purpose programming language and
+toolchain.  Among other features it provides
+@itemize
+@item an Optional type instead of null pointers,
+@item manual memory management,
+@item generic data structures and functions,
+@item compile-time reflection and compile-time code execution,
+@item integration with C using zig as a C compiler, and
+@item concurrency via async functions.
+@end itemize")
+    (home-page "https://github.com/ziglang/zig")
+    (license license:expat)))
-- 
2.33.0






Information forwarded to guix-patches <at> gnu.org:
bug#50449; Package guix-patches. (Sun, 31 Oct 2021 08:08:02 GMT) Full text and rfc822 format available.

Message #31 received at 50449 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: 47006 <at> debbugs.gnu.org,
 András Vöröskői <voroskoi <at> gmail.com>,
 50449 <at> debbugs.gnu.org, maximedevos <at> telenet.be, efraim <at> flashner.co.il
Subject: Re: [PATCH v5] gnu: Add zig.
Date: Sun, 31 Oct 2021 09:06:59 +0100
I've now pushed this with the following change:

Am Donnerstag, den 09.09.2021, 15:32 +0200 schrieb Liliana Prikler:
> +       ("lld" ,lld-12)))
lld is lld.

Thanks, everyone, and enjoy your zig.





bug closed, send any further explanations to 47006 <at> debbugs.gnu.org and Leo Prikler <leo.prikler <at> student.tugraz.at> Request was from Liliana Marie Prikler <liliana.prikler <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 31 Oct 2021 08:21:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 28 Nov 2021 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 121 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.