Message ID | 20210308131155.7441-1-leo.prikler@student.tugraz.at |
---|---|
State | Accepted |
Headers | show |
Series | [bug#47006] gnu: Add zig. | expand |
Context | Check | Description |
---|---|---|
cbaines/submitting builds | success | |
cbaines/comparison | success | View comparision |
cbaines/git branch | success | View Git branch |
cbaines/applying patch | success | View Laminar job |
cbaines/issue | success | View issue |
I attempted to add tests, Zig has an unconventional way of requiring tests to be run after installation so I added a 'check phase after the 'install phase which works but then after lots of tests succeeded there is a FileNotFound error cause by some 'test' binary failing to run. I found out by running: $ ./pre-inst-env guix build --keep-failed zig $ cd /tmp/guix-build-zig-0.7.1.drv-0/source $ env -i $(which bash) $ source ../environment-variables $ /run/current-system/profile/bin/strace -f -e trace=file /gnu/store/1cmjgdiim452bqkzgp53d0kw4fi4gfar-zig-0.7.1/bin/zig build test ... [pid 25896] execve("/tmp/guix-build-zig-0.7.1.drv-0/source/zig-cache/o/25718f52ae311b1dafdba7de4a338f12/test", ["/tmp/guix-build-zig-0.7.1.drv-0/"...], 0x4e42bb0 /* 27 vars */) = -1 ENOENT (No such file or directory) [pid 25896] +++ exited with 1 +++ [pid 25885] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=25896, si_uid=1000, si_status=1, si_utime=0, si_stime=0} --- error: FileNotFound ... $ ldd /tmp/guix-build-zig-0.7.1.drv-0/source/zig-cache/o/25718f52ae311b1dafdba7de4a338f12/test linux-vdso.so.1 (0x00007ffd22d1d000) libc.so.6 => /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/libc.so.6 (0x00007fea82162000) libm.so.6 => /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/libm.so.6 (0x00007fea82021000) libpthread.so.0 => /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/libpthread.so.0 (0x00007fea82000000) libdl.so.2 => /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/libdl.so.2 (0x00007fea81ffb000) librt.so.1 => /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/librt.so.1 (0x00007fea81ff1000) /lib64/ld-linux-x86-64.so.2 => /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/ld-linux-x86-64.so.2 (0x00007fea82321000) libutil.so.1 => /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/libutil.so.1 (0x00007fea81fec000) $ file /tmp/guix-build-zig-0.7.1.drv-0/source/zig-cache/o/25718f52ae311b1dafdba7de4a338f12/test /tmp/guix-build-zig-0.7.1.drv-0/source/zig-cache/o/25718f52ae311b1dafdba7de4a338f12/test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, with debug_info, not stripped The issue here is that this binary should work fine already according to the output of ldd and file. We would need a way to get verbose debugging errors of execve somehow. Leo Prikler (1): gnu: Add zig. gnu/local.mk | 1 + gnu/packages/zig.scm | 76 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 gnu/packages/zig.scm
On Mon, Mar 08, 2021 at 02:11:56PM +0100, Leo Prikler wrote: > * gnu/packages/zig.scm: New file. > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it here. > --- > gnu/local.mk | 1 + > gnu/packages/zig.scm | 65 ++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 66 insertions(+) > create mode 100644 gnu/packages/zig.scm > > diff --git a/gnu/local.mk b/gnu/local.mk > index fb3b395852..abcf86fb7e 100644 > --- a/gnu/local.mk > +++ b/gnu/local.mk > @@ -586,6 +586,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..caf0a5e21a > --- /dev/null > +++ b/gnu/packages/zig.scm > @@ -0,0 +1,65 @@ > +;;; GNU Guix --- Functional package management for GNU > +;;; Copyright © 2021 Leo Prikler <leo.prikler@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.7.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 "1z6c4ym9jmga46cw2arn7zv2drcpmrf3vw139gscxp27n7q2z5md")))) > + (build-system cmake-build-system) > + (native-inputs > + `(("clang" ,clang-11) > + ("lld" ,lld) > + ("llvm" ,llvm-11))) Does it work to replace these three with clang-toolchain-11? > + (arguments > + `(#:tests? #f ; no check target > + #:phases > + (modify-phases %standard-phases > + (add-after 'configure 'set-home > + (lambda _ > + (setenv "HOME" (getcwd)) ; zig writes to $HOME/.cache > + #t))))) > + (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.30.1 > > > >
Am Dienstag, den 16.03.2021, 14:57 +0200 schrieb Efraim Flashner: > On Mon, Mar 08, 2021 at 02:11:56PM +0100, Leo Prikler wrote: > > + (native-inputs > > + `(("clang" ,clang-11) > > + ("lld" ,lld) > > + ("llvm" ,llvm-11))) > > Does it work to replace these three with clang-toolchain-11? You can replace clang+llvm by clang-toolchain, but IIUC we prefer the explicit style in Guix. Correct me if I'm wrong. Regards, Leo
Another patch submission for Zig was sent: https://issues.guix.gnu.org/47206 (I closed and directed them here for cooperation instead). But still have a look there for any improvements to the current patch.
Hi, are there any issues left preventing this patch from being merged? If so, I can help. I would love to see Zig packaged in guix.
One comment below. > + (native-inputs > + `(("clang" ,clang-11) > + ("lld" ,lld) > + ("llvm" ,llvm-11))) This looks rather suspicious from a cross-compilation perspective. IIUC, lld and llvm are used for two purposes: * for compiling the "zig" compiler --> native-inputs is ok (or is GCC used to compile the zig compiler?) * as a run-time dependency of "zig" --> should be 'inputs' Therefore, shouldn't "lld" and "llvm" be added to "inputs" as well? TODO to self: define a variant of disallowed-references disallowed-references/native that refers to the package in 'native-inputs' instead of 'inputs'. Perhaps explicitely whitelist some inputs (llvm, lld, maybe some implicit libc inputs?). Note: according to me, *all* inputs in native-inputs should be added to disallowed-references *by default* when cross-compiling. Alternatively, I guess ‘we’ could simply add a comment ;; Cross-compilation is currently unsupported. and leave cross-compilation for later. My comments are mostly about ‘giving the good example’ on how to use inputs & native-inputs and avoid giving ‘bad examples’ of package definitions without marking them as such. Greetings, Maxime.
Hi Guix team. There is an open issue from 2020 adding zig https://issues.guix.gnu.org/39480 it probably could be linked to this one #47006 Zig has it's own build system: zig build it will be usefully to have a guix native build system as well when compiler is merged. https://ziglang.org/learn/overview/#zig-build-system It also has a language server https://github.com/zigtools/zls
Hi, I have also spent some time with zig, having hard time with tests too. I can reproduce the "FileNotFound" error :-) I have a rpi4 running guix on top of Alpine and the failing test was aarch64-linux-gnu. After disabling it I got an other LLD related error and gave up. Now, I am trying -Dskip-non-native=true, so far so good, but I also want to try if -Dskip-libc. BTW I would not recommend skipping ReleaseFast builds, maybe ReleaseSmall is the least interesting one.
Hi, So zig testing result is the following: -Dskip-libc does not work, my best result is with -Dskip-non-native. -Dskip-non-native fails with "libc headers note" test from `compile_errors.zig` (I had to comment it around line 2750) and std library tests also fails instantaneously. So I suggest the following test command for now: `zig build -Dskip-non-native test-toolchain` with a patch to disable that failing test. This will test everything except the std library and docs.
diff --git a/gnu/local.mk b/gnu/local.mk index fb3b395852..abcf86fb7e 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -586,6 +586,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..caf0a5e21a --- /dev/null +++ b/gnu/packages/zig.scm @@ -0,0 +1,65 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Leo Prikler <leo.prikler@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.7.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 "1z6c4ym9jmga46cw2arn7zv2drcpmrf3vw139gscxp27n7q2z5md")))) + (build-system cmake-build-system) + (native-inputs + `(("clang" ,clang-11) + ("lld" ,lld) + ("llvm" ,llvm-11))) + (arguments + `(#:tests? #f ; no check target + #:phases + (modify-phases %standard-phases + (add-after 'configure 'set-home + (lambda _ + (setenv "HOME" (getcwd)) ; zig writes to $HOME/.cache + #t))))) + (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)))