From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 2DHKF23YNGfqewEA62LTzQ:P1 (envelope-from ) for ; Wed, 13 Nov 2024 16:48:45 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 2DHKF23YNGfqewEA62LTzQ (envelope-from ) for ; Wed, 13 Nov 2024 17:48:45 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=YDZbPqN0; dkim=fail ("headers rsa verify failed") header.d=ultrarare.space header.s=dkim header.b=AB2PODjQ; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1731516525; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=QAiN9SnDAOiuDa1MuVO5xtN6eLJUIz7NrdVK6sAWJBw=; b=uVZA2BDPgLxC9PAOW4AQmDmQ5OvCO9sry42X9LhdVrkPXX8o9/nIONiyp++1qdBy89aOl9 zy8ptrVW7zGR8w0TXhw2LGjb6S3lKrtep4lmRPxu5QI7iP11uAIYrb6kpHa1IUrqbYyqHe KuW9sCoOgNPk1+0ShaMAfN/OWCYhYOEeeG5Eougjj+IH9Thbz2lCx3Ekovnizfi7L0Y5ZE OTsJmDxQt9Qh8u1hmeX1xykH+9ZI5QHoY2/w6FarnfDjceWS8UBEiA1tN5LpVMAaYXtxvg J21M7iN4TbRkoqxVZ34Xke9cgNrgackLoXmGpU9DfuaNqHdBzPTVFzBEa4R5/w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1731516525; a=rsa-sha256; cv=none; b=nK57vjwPIPO36z2f4na/9GJyA10UiErOANlPVaU7Hu6ttkjwj207d+TfXPT0vk4jtTpfmI Np+WRXb7ruZb99KpVZCJtGEMLXPymJz4dU+ccPq8aSp2vgkYEQOg21aIZtxSoxAU65Ms8f 8kskw0Yn3SsbC7K1rKV+dMO35clTwj6nhZTOk+4OYsfDwOX01ZK0R/L7vXwf3rM8tN+xVn 4r57Put4YFenHQxgtMW40xDQJdSAUdNJhz/XFt/NCAKt+I9aSrmtWLvwctKJVNOr9TDvxW IQNW+1pnKpCwvjnVY7NyCSKpIUwTyByvGO12+YweY++x4sjRyydpQDvCLwWQDg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=YDZbPqN0; dkim=fail ("headers rsa verify failed") header.d=ultrarare.space header.s=dkim header.b=AB2PODjQ; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DD18087B30 for ; Wed, 13 Nov 2024 17:48:44 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBGXM-0007zU-0Q; Wed, 13 Nov 2024 11:48:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBGXD-0007u6-Nd for bug-guix@gnu.org; Wed, 13 Nov 2024 11:48:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tBGXD-0000Wq-Ec for bug-guix@gnu.org; Wed, 13 Nov 2024 11:48:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:From:Date:To:Subject; bh=QAiN9SnDAOiuDa1MuVO5xtN6eLJUIz7NrdVK6sAWJBw=; b=YDZbPqN0PXi4WGcRW2ZDdjR4CyxvtbQLu7hWZ9JvMpLcBqZwPIM1zs/ots5fn86Rl8xMIBP8EGhQiqRjheFYL8RGIx1ftov2ivhOq/iMgE9brxa+fvYDWmiG1vVQqOFQWog8c2T/woY5boJOID+LDwJXcV4u5j73czHQMDaRc9LD+hJuG1AafInilFMEiHLI5lsg1mnQOAIlEv9Oi+S5AXOHH1BlB/LwiDhn1JpUdJDQo02BkDLypbPbhz4cBWtYTSQys/7HWTNBlE7S6zcYQYaY2/M6AoJTT4AfHMneRWH2WHM2tZQDNMt7W0JLRloYpiQO1GFyinJNYHqaEP/ZjQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBGXC-0008JA-HD; Wed, 13 Nov 2024 11:48:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#74217: Bootstrapping Zig with no Binary Blobs Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org, Ekaitz Zarraga Resent-Date: Wed, 13 Nov 2024 16:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74217 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 74217@debbugs.gnu.org Cc: Motiejus =?UTF-8?Q?Jak=C5=A1tys?= , =?UTF-8?Q?No=C3=A9?= Lopez , dan , Efraim Flashner , Ekaitz Zarraga Received: via spool by 74217-submit@debbugs.gnu.org id=B74217.173151646031903 (code B ref 74217); Wed, 13 Nov 2024 16:48:02 +0000 Received: (at 74217) by debbugs.gnu.org; 13 Nov 2024 16:47:40 +0000 Received: from localhost ([127.0.0.1]:43328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBGWp-0008IU-ET for submit@debbugs.gnu.org; Wed, 13 Nov 2024 11:47:39 -0500 Received: from mail.boiledscript.com ([144.168.59.46]:33384) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBGWm-0008IC-OF for 74217@debbugs.gnu.org; Wed, 13 Nov 2024 11:47:37 -0500 Date: Thu, 14 Nov 2024 00:46:59 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=dkim; t=1731516448; 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=QAiN9SnDAOiuDa1MuVO5xtN6eLJUIz7NrdVK6sAWJBw=; b=AB2PODjQTHjCwGk/2pQri0BLZpfoE71ymCOI3vVU8MUIwY6RDhWIoMJmUzLJ1rlotI0l40 fHSZVERiiWymTy8OueWEJ8UZijAoiog7ky9FS/JPO5qGuM9qOnI+DxgDEYEjs87+ZRPPei lexNEseWjxiYnk/C0Ixwdm+Tuz813YaVckLySTUENjW7fUKJ0p/Za2rdvn1RXuLbIqbrTs /t8cypaIWT5Hd7wIM3UhmtbEfpvvgeykFn7jtksRnJUy9dK391zKbpLOA2Hc9ydgfDsBjg QNs8s9PXHQpriwF4KYK3ROXfZMlrFwKdCve5Bb6sN0aPZLQY8BB5eHzGfitv6Q== Message-ID: <87ldxngjy4.wl-hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spamd-Bar: -- X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Hilton Chain From: Hilton Chain via Bug reports for GNU Guix Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -1.62 X-Spam-Score: -1.62 X-Migadu-Queue-Id: DD18087B30 X-Migadu-Scanner: mx13.migadu.com X-TUID: E5E6/kOax+B9 Hello everyone, With a new forced push (and new rebuilds, sorry), wip-zig-bootstrap is mostly ready (for me) now. Please take a look at the first few commits, as I'm changing Zig's behavior there, here are some additional notes: To Efraim: Can adding pkg-config to native-inputs avoid the ncdu snippet? I'm building this branch on my personal Cuirass instance[1][2], for x86_64-linux and aarch64-linux (qemu-binfmt), in previous revisions I have indentified reproduciblity issue, and aarch64 builds timed-out. I haven't investigated them yet. Then for what's the RUNPATH issue I have mentioned in commits: + For current zig@0.10 on Guix master: glibc is missing from RUNPATH, which fails the validate-runpath check. + For zig@0.11, some other inputs are missing, making the binary failing to run on Guix[3]. + dan also mentioned privately to me that they needed to add paths from LIBRARY_PATH to RUNPATH for their own projects, so programs built by Zig is also affected. I think this is due to Zig's implemention of its own linking logic, which bypasses our ld-wrapper. I'm not going to implement ld-wrapper within Zig. :) So my proposed workaround in wip-zig-bootstrap is to patch the handling logic added for Guix: (In lib/std/zig/system/NativePaths.zig) --8<---------------cut here---------------start------------->8--- // Distros like guix don't use FHS, so they rely on environment // variables to search for headers and libraries. // We use os.getenv here since this part won't be executed on // windows, to get rid of unnecessary error handling. - if (std.posix.getenv("C_INCLUDE_PATH")) |c_include_path| { + if (std.posix.getenv("CROSS_C_INCLUDE_PATH") orelse std.posix.getenv("C_INCLUDE_PATH")) |c_include_path| { var it = mem.tokenizeScalar(u8, c_include_path, ':'); while (it.next()) |dir| { try self.addIncludeDir(dir); } } - if (std.posix.getenv("CPLUS_INCLUDE_PATH")) |cplus_include_path| { + if (std.posix.getenv("CROSS_CPLUS_INCLUDE_PATH") orelse std.posix.getenv("CPLUS_INCLUDE_PATH")) |cplus_include_path| { var it = mem.tokenizeScalar(u8, cplus_include_path, ':'); while (it.next()) |dir| { try self.addIncludeDir(dir); } } - if (std.posix.getenv("LIBRARY_PATH")) |library_path| { + if (std.posix.getenv("CROSS_LIBRARY_PATH") orelse std.posix.getenv("LIBRARY_PATH")) |library_path| { var it = mem.tokenizeScalar(u8, library_path, ':'); while (it.next()) |dir| { try self.addLibDir(dir); + try self.addRPath(dir); } } } --8<---------------cut here---------------end--------------->8--- Adding directories from CROSS_LIBRARY_PATH or LIBRARY_PATH to RUNPATH, "CROSS_" part is for our cross toolchain, I haven't tested it yet. I think this behavior change is reasonable since the search path (CROSS_)?LIBRARY_PATH is only automatically set by our compilers. I added this change to 0.9 as well to make all Zigs behave consistently. I also used shrink-runpath phase from meson-build-system in Zig and zig-build-system. I want to move shrink-runpath to (guix build utils) and export it too, so that it can be used easier. But I'm not sure if this change will trigger rebuilds of other packages, so I didn't do it. Thanks to Guile, for builds not managed by guix-daemon, something like the following script can be used, we can ship a program-file if we agree on this workaround. --8<---------------cut here---------------start------------->8--- (use-modules (guix build meson-build-system)) (define shrink-runpath (assoc-ref %standard-phases 'shrink-runpath)) (define (main directories) (for-each (lambda (dir) (false-if-exception (shrink-runpath #:elf-directories '(".") #:outputs `(("out" . ,dir))))) directories)) (main (cdr (command-line))) --8<---------------cut here---------------end--------------->8--- Usage: guile DIRECTORY... Thanks --- [1]: https://ci.boiledscript.com/jobset/guix-zig [2]: https://substitute.boiledscript.com, if you want to challenge it. [3]: https://github.com/ziglang/zig/issues/18434