diff mbox series

[bug#39480,bug#47006,WIP,v2,2/2] gnu: Add zig.

Message ID 86wnnmnceg.fsf@mgsn.dev
State Accepted
Headers show
Series None | expand

Commit Message

Sarah Morgensen Sept. 11, 2021, 7:24 p.m. UTC
All,

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

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

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

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.

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

--
Sarah

Comments

Liliana Marie Prikler Sept. 11, 2021, 8:01 p.m. UTC | #1
Hi Sarah,

Am Samstag, den 11.09.2021, 12:24 -0700 schrieb Sarah Morgensen:
> 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

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

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

> 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.
diff mbox series

Patch

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;