[PATCH] gnu: Add zig compiler

  • Done
  • quality assurance status badge
Details
6 participants
  • Sarah Morgensen
  • Leo Prikler
  • Leo Famulari
  • Liliana Marie Prikler
  • Christopher Baines
  • Simon Nielsen
Owner
unassigned
Submitted by
Simon Nielsen
Severity
normal
Merged with
S
S
Simon Nielsen wrote on 7 Feb 2020 13:40
(address . guix-patches@gnu.org)
11943681581079241@vla1-d97dbca235a9.qloud-c.yandex.net
Hi,

Adds the zig compiler as a new file in `gnu/packages/`

- Simon
From a87eb4cbc76337a2f9ede07fae57808851ac5d45 Mon Sep 17 00:00:00 2001
From: "Simon A. Nielsen Knights" <tauoverpi@yandex.com>
Date: Fri, 7 Feb 2020 12:19:05 +0100
Subject: [PATCH] gnu: Add zig-0.5.0 compiler

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

Toggle diff (67 lines)
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
new file mode 100644
index 0000000000..ccd8327aed
--- /dev/null
+++ b/gnu/packages/zig.scm
@@ -0,0 +1,59 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2020 Simon A. Nielsen Knights <tauoverpiu@yandex.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 licenses) #:prefix license:)
+ #:use-module (guix download)
+ #:use-module (guix build-system cmake)
+ #:use-module (gnu packages xml)
+ #:use-module (gnu packages compression)
+ #:use-module (gnu packages llvm))
+
+(define-public zig-0.5.0
+ (package
+ (version "0.5.0")
+ (name "zig")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "https://ziglang.org/download/"
+ version "/zig-"
+ version ".tar.xz"))
+ (sha256
+ (base32
+ "0ccahg6bfm9m1mzr5gqs2jd5a3idj1q8akwbz6fcnaqm1yb1dbjm"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (add-before 'build 'fix-build
+ (lambda _ (setenv "HOME" "/tmp") #t)))))
+ (inputs
+ `(("llvm" ,llvm-9)
+ ("clang" ,clang-9)
+ ("libxml2" ,libxml2)
+ ("zlib" ,zlib)))
+ (description
+ "Programming languaged designed for robustness, optimality, and clarity")
+ (synopsis
+ "Programming languaged designed for robustness, optimality, and clarity")
+ (home-page "https://ziglang.org")
+ (license license:expat)))
+
+(define-public zig zig-0.5.0)
--
2.25.0
L
L
Leo Famulari wrote on 21 Feb 2020 19:07
(name . Simon Nielsen)(address . tauoverpi@yandex.com)(address . 39480@debbugs.gnu.org)
20200221180750.GA4850@jasmine.lan
On Fri, Feb 07, 2020 at 01:40:41PM +0100, Simon Nielsen wrote:
Toggle quote (4 lines)
> Hi,
>
> Adds the zig compiler as a new file in `gnu/packages/`

Thanks! Please add it to 'gnu/local.mk'.

Toggle quote (2 lines)
> +(define-public zig-0.5.0

We can name it 'zig' until there are multiple versions in Guix.

Toggle quote (2 lines)
> + `(#:tests? #f

Why are the tests disabled? Is it because there is no test suite? Or
something else? Please add a brief code comment explaining it.

Toggle quote (5 lines)
> + #:phases
> + (modify-phases %standard-phases
> + (add-before 'build 'fix-build
> + (lambda _ (setenv "HOME" "/tmp") #t)))))

I guess that the build tries to access $HOME?

Toggle quote (3 lines)
> + (description
> + "Programming languaged designed for robustness, optimality, and clarity")

Can you try to make a more detailed description here? At least it should
be a complete sentence.

Toggle quote (3 lines)
> + (synopsis
> + "Programming languaged designed for robustness, optimality, and clarity")

Typo: languaged
C
C
Christopher Baines wrote on 20 Nov 2020 21:38
(name . Simon Nielsen)(address . tauoverpi@yandex.com)(address . 39480@debbugs.gnu.org)
87k0ufkbls.fsf@cbaines.net
Leo Famulari <leo@famulari.name> writes:

Toggle quote (34 lines)
> On Fri, Feb 07, 2020 at 01:40:41PM +0100, Simon Nielsen wrote:
>> Hi,
>>
>> Adds the zig compiler as a new file in `gnu/packages/`
>
> Thanks! Please add it to 'gnu/local.mk'.
>
>> +(define-public zig-0.5.0
>
> We can name it 'zig' until there are multiple versions in Guix.
>
>> + `(#:tests? #f
>
> Why are the tests disabled? Is it because there is no test suite? Or
> something else? Please add a brief code comment explaining it.
>
>> + #:phases
>> + (modify-phases %standard-phases
>> + (add-before 'build 'fix-build
>> + (lambda _ (setenv "HOME" "/tmp") #t)))))
>
> I guess that the build tries to access $HOME?
>
>> + (description
>> + "Programming languaged designed for robustness, optimality, and clarity")
>
> Can you try to make a more detailed description here? At least it should
> be a complete sentence.
>
>> + (synopsis
>> + "Programming languaged designed for robustness, optimality, and clarity")
>
> Typo: languaged

It's been a few months, is this patch still relevant?

Thanks,

Chris
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAl+4KT9fFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XcBDw//QPUZ0Ibw/xnwyKp4kMQIcer6i2fVhl1I
NN+//JhgkDgxQ+omMZ+kbUghzmSngmEfGYgYrgTkbj3NxcXmo7cxhr3NJG+MpsKK
hvj6ZF48M0OynIUQ/P1HHBsMYdHYE80ge/duger3HNqbUAfLyLs29gWgDUgoGTc0
E9JcJeDw162/ilKYIe81cT8Cw8yxM2iOO3BsJt72kn/SmRFHMJZIc6Cx+5UsiUMF
FQOoD7bTo/zgMwCr54Jkxke8ELGGwTxNG79SYB97uO0CzjwcVPHnTtl8KQpCXw1U
GOiHe8EshOHnY0z4VgypDSiZxTl/fjV3GNZkdKSjgEMp15/O12fblKKNls0u2y+M
yOiRDyiow3+N3J6OKp7RE1VIAjP7f4XoxB0ShmLIWI9pY5vZijfYJDzchJBi0qbo
ghouxNY81YTPureTUIyhE3mcwdSqhTplOuCpij2ykRRfMGU/OBpXdh/PPmH2LiGy
H1HFc/KmcqjgAdfqd/DtKu7RVIqd0ASYq6yHzeCBZFaIAtaRyOBenvyLKxYBG5Eg
bXaUS8LvGdyayDN/sgkOG8e0DGq6qnRXuID4XTV5lSIhBnkfYZgu/eDjnsWTRGHv
zSkUx+deiCQXMU5YLZzAhgmV3LE/wpAgtyaZ3gY7GhTQYIWTfS/qAUUNVDCiXfOG
sW/q+uvOHiQ=
=qSiz
-----END PGP SIGNATURE-----

L
L
Leo Prikler wrote on 31 May 2021 09:01
(address . control@debbugs.gnu.org)
77da12cd9c38416a108c0efd4ba00f7cc814cdff.camel@student.tugraz.at
merge 39480 47006
thanks
L
L
Liliana Marie Prikler wrote on 9 Sep 2021 00:16
(address . control@debbugs.gnu.org)(name . Andrew Patterson)(address . andrewpatt7@gmail.com)
a1922b0a2ec237d217af54ed3ff7065e360d994c.camel@gmail.com
merge 47006 50449
thanks

Hi Andrew,

there is sadly no lack of package definitions for Zig, but rather a
lack in review (and somewhat related a confidence to push them). IIRC,
our currently best approach is the one written by Léo Le Bouter back in
March, but Maxime Devos raised legitimate concerns regarding cross-
compilation that so far (again, to my knowledge) have not been
addressed in any package definition.

When it comes to packaging 0.8.x, there is a patch for lld waiting in
the mailing list as well [1], but it has to jump through some hoops to
compile and is thus somewhat lacking in what I call for lack of a
better word "prettiness".

Greetings

S
S
Sarah Morgensen wrote on 11 Sep 2021 21:24
Re: [bug#47006] [WIP PATCH v2 2/2] gnu: Add zig.
(name . Liliana Prikler)(address . liliana.prikler@gmail.com)
86wnnmnceg.fsf@mgsn.dev
All,

Apologies for the empty email earlier. That shows me for trying to send
from mobile!

Liliana,

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

Toggle quote (10 lines)
> I've added a patch to use explicit search paths rather than whatever Zig used
> before and tried fixing some (syntactic) errors with the tests, but was
> unsuccesful, as there appear to be failing tests in the suite itself. Could
> you have a look at the revised patch and check what flags you could add to
> the check phase to make it meaningful?
>
> Btw. I haven't checked whether my cosmetic changes to #:configure-flags break
> things or not. The end of the build phase puts a large amount of stress onto
> my system that I'd like to avoid at this hour.

I'm still working through the tests, but I did find one issue that has
cropped up either from your patch or from the 0.7.1 -> 0.8.1 upgrade.
This is from attempting to build tetris [0] (though I had to make a few
syntax fixes, attached below, to build with 0.8.1):

Toggle snippet (5 lines)
Zig attempted to find the path to native system libc headers by executing this command:
cc -E -Wp,-v -xc /dev/null
error: unable to create compilation: UnableToSpawnCCompiler

No combination of ZIG_LIB_DIRS and ZIG_INCLUDE_DIRS seems to fix
it. Neither does --search-prefix.

If I set CC=gcc, it works fine. But I think something changed such that
it now has to fall back to this method of detection. I have no idea
why.


--
Sarah
Toggle diff (77 lines)
diff --git a/src/all_shaders.zig b/src/all_shaders.zig
index a855bba..fb7eac8 100644
--- a/src/all_shaders.zig
+++ b/src/all_shaders.zig
@@ -107,7 +107,7 @@ pub const ShaderProgram = struct {
pub fn attribLocation(sp: ShaderProgram, name: [*]const u8) c.GLint {
const id = c.glGetAttribLocation(sp.program_id, name);
if (id == -1) {
- panic("invalid attrib: {}\n", .{name});
+ panic("invalid attrib: {*}\n", .{name});
}
return id;
}
@@ -115,7 +115,7 @@ pub const ShaderProgram = struct {
pub fn uniformLocation(sp: ShaderProgram, name: [*]const u8) c.GLint {
const id = c.glGetUniformLocation(sp.program_id, name);
if (id == -1) {
- panic("invalid uniform: {}\n", .{name});
+ panic("invalid uniform: {*}\n", .{name});
}
return id;
}
@@ -169,7 +169,7 @@ pub const ShaderProgram = struct {
c.glGetProgramiv(sp.program_id, c.GL_INFO_LOG_LENGTH, &error_size);
const message = try c_allocator.alloc(u8, @intCast(usize, error_size));
c.glGetProgramInfoLog(sp.program_id, error_size, &error_size, message.ptr);
- panic("Error linking shader program: {}\n", .{message.ptr});
+ panic("Error linking shader program: {*}\n", .{message.ptr});
}
pub fn destroy(sp: *ShaderProgram) void {
@@ -205,5 +205,5 @@ fn initGlShader(source: []const u8, name: [*]const u8, kind: c.GLenum) !c.GLuint
const message = try c_allocator.alloc(u8, @intCast(usize, error_size));
c.glGetShaderInfoLog(shader_id, error_size, &error_size, message.ptr);
- panic("Error compiling {} shader:\n{}\n", .{ name, message.ptr });
+ panic("Error compiling {*} shader:\n{*}\n", .{ name, message.ptr });
}
diff --git a/src/debug_gl.zig b/src/debug_gl.zig
index 2fdcda0..543202b 100644
--- a/src/debug_gl.zig
+++ b/src/debug_gl.zig
@@ -2,7 +2,7 @@ const c = @import("c.zig");
const std = @import("std");
const os = std.os;
const panic = std.debug.panic;
-const builtin = @import("builtin");
+const builtin = std.builtin;
pub const is_on = if (builtin.mode == builtin.Mode.ReleaseFast) c.GL_FALSE else c.GL_TRUE;
diff --git a/src/main.zig b/src/main.zig
index fd83f8a..fa5f264 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -19,7 +19,7 @@ var static_geometry: StaticGeometry = undefined;
var font: Spritesheet = undefined;
fn errorCallback(err: c_int, description: [*c]const u8) callconv(.C) void {
- panic("Error: {}\n", .{@as([*:0]const u8, description)});
+ panic("Error: {s}\n", .{@as([*:0]const u8, description)});
}
fn keyCallback(win: ?*c.GLFWwindow, key: c_int, scancode: c_int, action: c_int, mods: c_int) callconv(.C) void {
@@ -95,9 +95,10 @@ pub fn main() !void {
defer font.deinit();
var seed_bytes: [@sizeOf(u64)]u8 = undefined;
- std.crypto.randomBytes(seed_bytes[0..]) catch |err| {
- panic("unable to seed random number generator: {}", .{err});
- };
+ std.crypto.random.bytes(seed_bytes[0..]);
+// catch {
+// panic("unable to seed random number generator", .{});
+// };
t.prng = std.rand.DefaultPrng.init(std.mem.readIntNative(u64, &seed_bytes));
t.rand = &t.prng.random;
L
L
Liliana Marie Prikler wrote on 11 Sep 2021 22:01
(name . Sarah Morgensen)(address . iskarian@mgsn.dev)
d6c444c9a774780d5a3c63816925c34c2d809a65.camel@gmail.com
Hi Sarah,

Am Samstag, den 11.09.2021, 12:24 -0700 schrieb Sarah Morgensen:
Toggle quote (4 lines)
> All,
>
> Apologies for the empty email earlier. That shows me for trying to
> send from mobile!
Curse those mobile applications with their small buttons amirite? :P

Toggle quote (24 lines)
> Liliana,
>
> Liliana Prikler <liliana.prikler@gmail.com> writes:
>
> > I've added a patch to use explicit search paths rather than
> > whatever Zig used
> > before and tried fixing some (syntactic) errors with the tests, but
> > was
> > unsuccesful, as there appear to be failing tests in the suite
> > itself. Could
> > you have a look at the revised patch and check what flags you could
> > add to
> > the check phase to make it meaningful?
> >
> > Btw. I haven't checked whether my cosmetic changes to #:configure-
> > flags break
> > things or not. The end of the build phase puts a large amount of
> > stress onto
> > my system that I'd like to avoid at this hour.
>
> I'm still working through the tests, but I did find one issue that
> has cropped up either from your patch or from the 0.7.1 -> 0.8.1
> upgrade. This is from attempting to build tetris [0] (though I had
> to make a few syntax fixes, attached below, to build with 0.8.1):
W.r.t. the syntax fixes, that is probably an upstream issue or perhaps
an incompatibility introduced by zig itself. (Maybe already from 0.7.1
to 0.8.0?)

Toggle quote (6 lines)
> --8<---------------cut here---------------start------------->8---
> Zig attempted to find the path to native system libc headers by
> executing this command:
> cc -E -Wp,-v -xc /dev/null
> error: unable to create compilation: UnableToSpawnCCompiler
> --8<---------------cut here---------------end--------------->8---
It appears zig tries to execute @command{cc}. Note, that this command
does not exist in Guix unless you install a symlink, so it will always
fail. We might want to investigate the source of this error to check
whether spawning a C compiler is indeed the right choice for what
they're claiming to try or whether our hard coding already takes care
of that.

Toggle quote (6 lines)
> No combination of ZIG_LIB_DIRS and ZIG_INCLUDE_DIRS seems to fix
> it. Neither does --search-prefix.
>
> If I set CC=gcc, it works fine. But I think something changed such
> that it now has to fall back to this method of detection. I have no
> idea why.
Thanks for the info. I'll let you know once I find out more.
L
L
Liliana Marie Prikler wrote on 31 Oct 2021 09:20
Re: [PATCH v5] gnu: Add zig.
(address . control@debbugs.gnu.org)
ba1bedafafa2607f3c8217799572baa9def2ab65.camel@gmail.com
close 47006
close 50449
thanks
?
Your comment

This issue is archived.

To comment on this conversation send an email to 39480@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 39480
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch