From patchwork Sat Sep 11 19:24:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarah Morgensen X-Patchwork-Id: 32761 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5867F27BBE3; Sat, 11 Sep 2021 20:25:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C34D727BBE1 for ; Sat, 11 Sep 2021 20:25:12 +0100 (BST) Received: from localhost ([::1]:35382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mP8cg-0000gA-M6 for patchwork@mira.cbaines.net; Sat, 11 Sep 2021 15:25:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mP8cY-0000fr-M7 for guix-patches@gnu.org; Sat, 11 Sep 2021 15:25:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58127) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mP8cY-0001wi-Eo for guix-patches@gnu.org; Sat, 11 Sep 2021 15:25:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mP8cY-0002n4-BC for guix-patches@gnu.org; Sat, 11 Sep 2021 15:25:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#39480] [bug#47006] [WIP PATCH v2 2/2] gnu: Add zig. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 11 Sep 2021 19:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39480 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Liliana Prikler Cc: 47006@debbugs.gnu.org, 39480@debbugs.gnu.org, maximedevos@telenet.be, efraim@flashner.co.il Received: via spool by 39480-submit@debbugs.gnu.org id=B39480.163138829210701 (code B ref 39480); Sat, 11 Sep 2021 19:25:02 +0000 Received: (at 39480) by debbugs.gnu.org; 11 Sep 2021 19:24:52 +0000 Received: from localhost ([127.0.0.1]:41438 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mP8cN-0002mW-L9 for submit@debbugs.gnu.org; Sat, 11 Sep 2021 15:24:51 -0400 Received: from out0.migadu.com ([94.23.1.103]:55998) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mP8cK-0002mG-QJ; Sat, 11 Sep 2021 15:24:50 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1631388287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gzCYYvAd5+ZAIn3f7jLDtonREpLW3t7EC1zuBrV9oY4=; b=hr6mZ7jA/J+IArkZNvbqPVVUuLVnWpObwRGqTQCYklII68GMF0Etja6KvQWMAqSf4MSWKt 0lt3PVckkQwPzsVWeofE8oy8Xa7i1kgQn5qXemqoMBVQaX5kclHAbhontPWWKkh3/KSKE7 k3SzUtnfdhb1fncKxw/x3nUZFIdIjSc= From: Sarah Morgensen References: <0f6c5b692df8d06a0d7adddc9e5abf93894a366f.1631226695.git.liliana.prikler@gmail.com> Date: Sat, 11 Sep 2021 12:24:39 -0700 In-Reply-To: (Liliana Prikler's message of "Thu, 9 Sep 2021 15:32:22 +0200 (2 days, 5 hours, 3 minutes ago)") Message-ID: <86wnnmnceg.fsf@mgsn.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: iskarian@mgsn.dev X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches All, Apologies for the empty email earlier. That shows me for trying to send from mobile! Liliana, Liliana Prikler 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 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;