From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.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 kBECAg/sNGdzQwAAe85BDQ:P1 (envelope-from ) for ; Wed, 13 Nov 2024 18:12:31 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id kBECAg/sNGdzQwAAe85BDQ (envelope-from ) for ; Wed, 13 Nov 2024 19:12:31 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=DYmr7BjT; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=ZGM9N92n; 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=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1731521551; h=from:from:sender:sender: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=Ifmv0OreLBa1pg2qKbwha9uI1P4MslEE6CtJ1g+rVg8=; b=Gz1/Z6AXFRtDeQ9R51hoVSKcQvd92IPyRQbHuAr1dskbdP30lDMb5Hc5EOHrwUgt7hLb4A b155qgPZR3zibMORlC8q2ws7A4dDWWZpVqva7jJGsMtmqG0V+ZuGQFTKISw1uf6lcTxPPg yIsGDi0qBkObkP0ZQWVg6FxyQjGIl5uKgV1QmdgMD0LvsMG+0SPBawwNO+2dmjdKaP7SxT 2bOu++Ldylmzj0WtBOqieeq45MqM38BL+plPrbLVBfDYhdVhR2laUpJaF/w/hy4hQAOQAq 4EGeE4vHDxChV+9+P6SQrl5lQItV2WUdSFuhXwvzHGf8bpj5i4QkxH/GVt7h1w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1731521551; a=rsa-sha256; cv=none; b=Q86vZMQ7TuGo0Yuc2e9RfntoMxpEMfGjy1nPdRMRBQ/53FqsoTM/CwnkYfau7Ds+lAsXue tIYlPNB0JvoD/DkEBMtMYfW7s7dizwwfb0ItadiZI5FbMBkZeiNEP1QEJcBdP9r0t0xdjx K35iFdXLl8R5Jo/XmRVrg58ydTo+tTm3aXWreFT3hdtlZ9djryykQ0msLerJkYwA0wbGte IA/5jYu8WrCmKpA7a4B70/h5eYo0KRl0SxL7NA82WjXVyv1OKweMwSQskbLLAOx/wu0jbm GdS17Ruy3+V9IqOYYop43C6Jcc1OF2W04jLUWMpDqKq/PGUHPKTkz5z8IvLtZw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=DYmr7BjT; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=ZGM9N92n; 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=none 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 0F6534D75 for ; Wed, 13 Nov 2024 19:12:29 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBHqX-0000gT-20; Wed, 13 Nov 2024 13:12:05 -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 1tBHqV-0000gA-Hl for bug-guix@gnu.org; Wed, 13 Nov 2024 13:12:03 -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 1tBHqV-0001D7-9L for bug-guix@gnu.org; Wed, 13 Nov 2024 13:12:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:MIME-Version:References:From:Date:To:Subject; bh=Ifmv0OreLBa1pg2qKbwha9uI1P4MslEE6CtJ1g+rVg8=; b=DYmr7BjT/77AiBIiXwPBzcBd6SL6V68p5uGTZJcd86Sv9B/yZ1Fq/E0JQnp/sCkn2zy2Ftp2eR0MYQMJAqpiWWs3v4QNjBwBcxUZi9oDenGLDk9fPQwVfY9SbJN0JUKUlyrd/KxRXxPq5ZOeWw1PvHz43Fb1FaL8C/gN1cwitlxSvn+qNVJKwUp73YFlEaKFvNTKJ1HZpZo/e4thq5H+fZLgztStNgVAPul7WH5B1o1KO7chtOAVWHe3DOBFQMx5fanSKsKE6NUttMuSZG8gODviduNTBJ76NEJwJYhpf06lPk5GBuD1u1tpEv6n2D8J/wtFPzQceXi5vhK58yUkpA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBHqU-0003fO-9d; Wed, 13 Nov 2024 13:12:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#74217: Bootstrapping Zig with no Binary Blobs Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org, Ekaitz Zarraga Resent-Date: Wed, 13 Nov 2024 18:12: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: Hilton Chain Cc: Motiejus =?UTF-8?Q?Jak=C5=A1tys?= , =?UTF-8?Q?No=C3=A9?= Lopez , dan , Ekaitz Zarraga , 74217@debbugs.gnu.org Received: via spool by 74217-submit@debbugs.gnu.org id=B74217.173152151214077 (code B ref 74217); Wed, 13 Nov 2024 18:12:02 +0000 Received: (at 74217) by debbugs.gnu.org; 13 Nov 2024 18:11:52 +0000 Received: from localhost ([127.0.0.1]:43543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBHqJ-0003ey-7d for submit@debbugs.gnu.org; Wed, 13 Nov 2024 13:11:51 -0500 Received: from mail-wm1-f52.google.com ([209.85.128.52]:61696) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBHqG-0003en-Cn for 74217@debbugs.gnu.org; Wed, 13 Nov 2024 13:11:50 -0500 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-43168d9c6c9so62541555e9.3 for <74217@debbugs.gnu.org>; Wed, 13 Nov 2024 10:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731521447; x=1732126247; darn=debbugs.gnu.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to :cc:subject:date:message-id:reply-to; bh=Ifmv0OreLBa1pg2qKbwha9uI1P4MslEE6CtJ1g+rVg8=; b=ZGM9N92n4grDElPjZBKXivHOfo2CuzTWH1CgVgPDFeL7WnQPyfPcbEhRPRigpk2BJC PYbg/+dn0jDTsW9qy4ymCOt3pI3kaWrIYB6TQRJ3zXYWjlPsYeQUMFGs9MCKe0Fj+6pB 1/m1v8yqLaSAVfznhp6RxtXVvRch+E7gt8E2b9S3PaxCBkCaegVzhjOiQXPQn/8m9D5S 0cssnLZka271ObRbm77JOB6kpZeHS8IfKeRvw65Av/MfnM7J+EjMaS0/0IwNR27jBRz7 C7BiJpG16Q9O58wv/ZsS78RV81zMleTj9vH0pi+vTZT7tuEdMp2r+7dvvp8Ut3DuC7j3 mY5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731521447; x=1732126247; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ifmv0OreLBa1pg2qKbwha9uI1P4MslEE6CtJ1g+rVg8=; b=UOByhMN6XLSoZT7J+QK29lCqvmAnW58C+EXOgZsWPa/mLkDb9fQHyIzWkgh3T94nF9 rZg0oumQTJ362lLz1emiFe/PenYd/5MCrbfWU7hi4B+w0XorMPGnjDDsBdppWFwNJJdd 7Wb2oonVXVx7W7HpRgyEFg/x9NTKd1DLKKGkm4GaH13ldvSFc21X5KRZXb+cycN+pYdM qW0CHuFTwuf9dzjmIYZscb9yWZ7tYIQ4WFRfezZR6fnGE9Zfc9H1cod/pTAX2gcDJMCI QfQY3IuMNUH5zgvpZ4Q/Amu03Ta8Gv+taxqxt+Xgr2aLsOJd0X6wyDzjey+Mq7V61QOy 9J/g== X-Gm-Message-State: AOJu0YwP3VXpc1FHokuf4FU6qGnZuqRtAcaDIQxu9ZSFFfaSXcKrVnoj geiRmw1mz1d1a4V80E7vES8Kz/5mcsRYSI/Ryne29e7zEB7jM/RW X-Google-Smtp-Source: AGHT+IGrG88U4v0r3vfO3SJvSp7c5l8KJ0lQ7HXktMP83rGUlqWFGQMvE/I2enUjSQSWBC8EHQ/E4Q== X-Received: by 2002:a5d:6da8:0:b0:37d:4846:42c3 with SMTP id ffacd0b85a97d-381f186cc3emr19068880f8f.22.1731521447011; Wed, 13 Nov 2024 10:10:47 -0800 (PST) Received: from localhost ([141.226.162.35]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381ed9ea653sm18769982f8f.65.2024.11.13.10.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 10:10:46 -0800 (PST) Date: Wed, 13 Nov 2024 20:10:44 +0200 From: Efraim Flashner Message-ID: Mail-Followup-To: Efraim Flashner , Hilton Chain , 74217@debbugs.gnu.org, dan , Ekaitz Zarraga , Motiejus =?UTF-8?Q?Jak=C5=A1tys?= , =?UTF-8?Q?No=C3=A9?= Lopez References: <87ldxngjy4.wl-hako@ultrarare.space> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="klKYw7Fd5mtswz7Y" Content-Disposition: inline In-Reply-To: <87ldxngjy4.wl-hako@ultrarare.space> X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 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: , 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: -4.71 X-Spam-Score: -4.71 X-Migadu-Queue-Id: 0F6534D75 X-Migadu-Scanner: mx13.migadu.com X-TUID: 7S+hGD4QJenT --klKYw7Fd5mtswz7Y Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 14, 2024 at 12:46:59AM +0800, Hilton Chain wrote: > Hello everyone, >=20 > With a new forced push (and new rebuilds, sorry), wip-zig-bootstrap is mo= stly > 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: >=20 > To Efraim: Can adding pkg-config to native-inputs avoid the ncdu snippe= t? Unfortunately no. The code reads: exe.root_module.linkSystemLibrary("ncursesw", .{}); exe.root_module.linkSystemLibrary("libzstd", .{}); and so it searches (something like the following, I lost the log): /usr/lib/liblibzstd.so /usr/lib/liblibzstd.a =2E.. /gnu/store/...-glibc.../lib/liblibzstd.so /gnu/store/...-glibc.../lib/liblibzstd.a =2E.. /gnu/store/...-zstd.../lib/liblibzstd.so /gnu/store/...-zstd.../lib/liblibzstd.a so it looks like it automatically adds the 'lib' at the front. When I've built out to ncdu again I'll check it again. > I'm building this branch on my personal Cuirass instance[1][2], for x86_6= 4-linux > and aarch64-linux (qemu-binfmt), in previous revisions I have indentified > reproduciblity issue, and aarch64 builds timed-out. I haven't investigat= ed them > yet. I've also been having berlin build zig on the wip-zig-bootstrap branch for x86_64. Unfortunately there's quite a bit to go on aarch64 for it to get there, but I can confirm from my machine that it's working. > 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, whi= ch > 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 didn't test it. ncdu@2.3 builds with zig-0.11, so that's an option for testing it out. https://dev.yorhel.nl/ncdu/changes2 > I think this is due to Zig's implemention of its own linking logic, which > bypasses our ld-wrapper. I wonder if switching from lld to make-lld-wrapper would make a difference here. > I'm not going to implement ld-wrapper within Zig. :) So my proposed worka= round > in wip-zig-bootstrap is to patch the handling logic added for Guix: >=20 > (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.ge= tenv("C_INCLUDE_PATH")) |c_include_path| { > var it =3D mem.tokenizeScalar(u8, c_include_path, ':'); > while (it.next()) |dir| { > try self.addIncludeDir(dir); > } > } >=20 > - if (std.posix.getenv("CPLUS_INCLUDE_PATH")) |cplus_include_path|= { > + if (std.posix.getenv("CROSS_CPLUS_INCLUDE_PATH") orelse std.posi= x.getenv("CPLUS_INCLUDE_PATH")) |cplus_include_path| { > var it =3D mem.tokenizeScalar(u8, cplus_include_path, ':'); > while (it.next()) |dir| { > try self.addIncludeDir(dir); > } > } >=20 > - if (std.posix.getenv("LIBRARY_PATH")) |library_path| { > + if (std.posix.getenv("CROSS_LIBRARY_PATH") orelse std.posix.gete= nv("LIBRARY_PATH")) |library_path| { > var it =3D mem.tokenizeScalar(u8, library_path, ':'); > while (it.next()) |dir| { > try self.addLibDir(dir); > + try self.addRPath(dir); > } > } > } > --8<---------------cut here---------------end--------------->8--- >=20 > Adding directories from CROSS_LIBRARY_PATH or LIBRARY_PATH to RUNPATH, "C= ROSS_" > part is for our cross toolchain, I haven't tested it yet. I like this, and it seems like it should make it work for cross compiling zig programs. That's part of why I added the updated ncdu commit, to use it for testing. > I think this behavior change is reasonable since the search path > (CROSS_)?LIBRARY_PATH is only automatically set by our compilers. >=20 > 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-sy= stem. >=20 > 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 rebu= ilds of > other packages, so I didn't do it. I found that there was still the full LIBRARY_PATH embedded in the ncdu binary as a string. So with that I'm not sure about using RPath instead of LibDir for the LIBRARY_PATH. > 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 t= his > workaround. > --8<---------------cut here---------------start------------->8--- > (use-modules (guix build meson-build-system)) >=20 > (define shrink-runpath > (assoc-ref %standard-phases 'shrink-runpath)) >=20 > (define (main directories) > (for-each (lambda (dir) > (false-if-exception > (shrink-runpath > #:elf-directories '(".") > #:outputs `(("out" . ,dir))))) > directories)) >=20 > (main (cdr (command-line))) > --8<---------------cut here---------------end--------------->8--- > Usage: guile DIRECTORY... >=20 >=20 > 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 I spent a bunch of time trying to get zig-0.10 or 0.10.0-610 to build on riscv64 and ppc64le but haven't been able to crack it yet. --=20 Efraim Flashner =D7=90=D7=A4=D7=A8=D7=99=D7=9D = =D7=A4=D7=9C=D7=A9=D7=A0=D7=A8 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --klKYw7Fd5mtswz7Y Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmc066AACgkQQarn3Mo9 g1EnFQ/7BUV3KU9BDhqjdcN/3UHzaNFP0+zfL1eMsFykYB55ebJ+KXuSyB5pQSpI QtXHeIKR0uk+WUfnSVZNvAz3LvwOFK84X5g7mpKiQJT2AacvkYzvU9ZzDEu9uRqW D5LfqZNkbVirAWm3ObafPAbRUE1W7TQpgXyzQpFTuBrPEPzFEXYcnKMR29JW73GI nvD4xlE25xNSQLp66U4QN9CciAehh2YDE/2VGkFIW6xObdmPPAl708gi2WTuW78V 4cqmikiq3ZuJSp9gC1JIKDrlOPVGQluNy8sAI58uyHkLqWF0xh3z6qS/6hGWwtgW /AjlNmcAhC/0GkknG/AdEsxs2tYqH9Bbsc4TLHOpGl7wXjrGKV5UgjgarviMBcPA DLr7VjKOOlHPy5tOUMsy0xDL2y1WGt1yhO/Hkumwui8Hd5Cka83rXPy1BkNIWlA0 B8A0g68GVYV9Uu7BfUk5+tmW7dXML8c/1M7tMJIkdCaV7z8WeP1b0QKcMUkO61Sz 1H9VZldUTOQjx8RfXv3Gwl/SDl6uOQibp0qMgGXIVKjgJwuEqwE7LMVOTvgWsQ3T Ax14pycXy5qaGLOe1lYATr4PCbMsp6eN59bmtiuiKg4YaqFrOaUfmNvQgoX/8jHL A+1JXT2cPLMXLmkZ+s9RkmARY3qMkJ2JwAwSxp3s6Hr0MRn1kQA= =+4fE -----END PGP SIGNATURE----- --klKYw7Fd5mtswz7Y--