Article View: linux.debian.devel
Article #467Re: RFS: Bringing [zig] to Debian: A from-source bootstrap that reproduces upstream's seed
From: Bastien Roucaries
Date: Sat, 14 Nov 2026 20:30
Date: Sat, 14 Nov 2026 20:30
371 lines
18290 bytes
18290 bytes
--nextPartjI51Z_HmSPKrwrJaskipMA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; protected-headers="v1" From: Bastien Roucaries <rouca@debian.org> To: debian-devel@lists.debian.org Date: Sat, 14 Nov 2026 21:28:57 +0100 Message-ID: <lo_nAyrlTJuVeuyHeDHf-Q@debian.org> In-Reply-To: <898cd302-bf9e-4466-a604-62871bf3a8c5@proteamail.com> References: <898cd302-bf9e-4466-a604-62871bf3a8c5@proteamail.com> MIME-Version: 1.0 Le mardi 10 novembre 2026, 20:59:26 heure normale d=E2=80=99Europe centrale= Edmund Lodewijks a =C3=A9crit : > Hi all, >=20 >=20 > Apologies for the lengthy email. This is based on a good two weeks or so= =20 > of work on making Zig packageable for Debian. >=20 >=20 > Short version: Zig's bootstrap blob can now be produced from source, and= =20 > the result is bit-for-bit identical to the blob that upstream ships in=20 > the signed 0.17.1 release. I have a working `zig` source package built=20 > on that basis. Before I take it further I would like to check two things= =20 > with the list, and find a sponsor. >=20 > This follows on the January 2025 "getting ziggy with it" thread=20 > <https://lists.debian.org/debian-devel/2025/01/msg00098.html>, which=20 > ended without a bootstrap plan. >=20 >=20 > ## The problem in short >=20 > Zig is written in Zig, and therefore needs Zig to compile itself.=20 > Upstream breaks the build circularity by committing `stage1/zig1.wasm`=20 > to the source tree: `wasm2c` converts it to C, the system C compiler=20 > builds that, and the result builds the compiler. That artifact is a=20 > build product, not source in the sense of DFSG =C2=A72, so Debian cannot = ship it. >=20 > A first attempt: Nick Black's proposal in msg00153 (i.e.: bootstrap with= =20 > the blob, then regenerate it) proves the blob is honest but does not=20 > remove it from what the source package needs. The first upload is the=20 > part that was unsolved, and which I am solving here. >=20 > ## What is new >=20 > GNU Guix solved the hard part (issue 74217, merged as=20 > 40b9f33066..42e32d52c3): A chain starting from the C++ compiler upstream= =20 > used before the WebAssembly seed existed, walking forward through Zig's=20 > history and regenerating the seed at each step. At the time of writing=20 > this email, it reaches Zig 0.16.0. >=20 > I extended that chain from 0.16.0 to 0.17.1 in nine further builds=20 > across six seed-regeneration boundaries. The seed regenerated at the=20 > last of those is identical to upstream's: >=20 > $ minisign -Vm zig-0.17.1.tar.xz \ > -P RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U > Signature and comment signature verified >=20 > $ tar xf zig-0.17.1.tar.xz zig-0.17.1/stage1/zig1.wasm -O | sha256sum > 77c02ad2496aab66fb408f831a49ee8f7ed6746326388c972735707881cac770 >=20 > regenerated from source, never executing upstream's copy: > 77c02ad2496aab66fb408f831a49ee8f7ed6746326388c972735707881cac770 > 3,246,758 bytes >=20 > This is upstream's minisign signature rather than a git clone, so the=20 > claim does not rest on my checkout being authentic. The same seed ships=20 > in 0.17.0, since the last regeneration commit precedes both releases. >=20 > For those who are interested: The chain, the hops, the hashes, the=20 > driver script, the logs... they are all documented and uploaded to Salsa: >=20 > https://salsa.debian.org/ejjl/zig-bootstrap I am interest to have a full documentation for your system (on wiki.d.o) I have a similar problem with gwt a java toolkit needed for building js Particularly how to use guix to solve bootstrap problem rouca >=20 > ## One Zig package for the archive >=20 > One source package: >=20 > https://salsa.debian.org/ejjl/zig >=20 > * `Files-Excluded: stage1/zig1.wasm` in debian/copyright, producing=20 > zig_0.17.1+dfsg.orig.tar.xz. > * `Build-Depends: zig`: each zig built by the previous zig in the=20 > archive, as gcc and rustc are. > * `debian/README.source` documents the bootstrap and how to reproduce= =20 > the seed. > * The bootstrap chain itself is *not* uploaded. It lives on Salsa. >=20 > What the +dfsg repack removes is stage1/zig1.wasm, which cannot be=20 > produced without an existing zig. >=20 > I am deliberately keeping the four lib/libc/*/abilists symbol tables.=20 > These can be regenerated at any time from glibc's and the BSDs' own=20 > LGPL/BSD sources by an MIT tool. That tool is itself written in Zig;=20 > however, regenerating them needs a zig, but they are not needed to=20 > *build* zig, only to cross-compile to glibc and BSD targets. A zig built= =20 > without them works, and can then regenerate them. >=20 > So the claim I want to make is not that the archive contains no=20 > binaries. It is that it contains no binary whose source cannot be=20 > rebuilt, and nothing circular at all. >=20 > The package builds in a clean unstable chroot, and lintian reports no=20 > errors or warnings beyond the expected unreleased-changes. What is left=20 > at info and pedantic level is in Open Issues below. >=20 > There is, of course, the question of how to solve the packaging problem=20 > of the circular dependency on Zig for building Zig in Debian. I see two=20 > ways around it for the package as it stands, plus a third that may=20 > already have been proposed by Ivan (see Coordination below). I would be=20 > happy to hear your thoughts on which should be preferred. >=20 > (a) Ship the seed in the source package, upload source-only. This is=20 > what the rust package does. > Based on what rust does, I would suggest we copy two out of their=20 > three options: >=20 > - no stage0/ present? --> build with the distro's zig. > - stage0/ present? --> bootstrap from that shipped seed. >=20 > Following Rust, the detection would be by file presence rather than= =20 > by a build profile, so one debian/rules serves both cases and a normal=20 > build cannot accidentally take the bootstrap path. Rust has a third=20 > path, the pkg.rustc.dlstage0 build profile, which downloads a stage0=20 > during the build. That one won't work here: Debian buildds have no=20 > network access during a build. >=20 > For zig, that stage0 file would be=20 > zig_0.17.1+dfsg.orig-stage0.tar.xz, carrying bin/zig and lib/zig from=20 > the compiler my chain produced. dpkg-source unpacks a supplementary orig= =20 > tarball named orig-stage0 into stage0/ in the build tree, and=20 > debian/rules would use that compiler instead of the system one. For that= =20 > upload only, Build-Depends: zig is disabled ([!amd64]). The seed is used= =20 > only to compile; it is never installed into a binary package. The next=20 > upload leaves the tarball out and restores Build-Depends: zig (this=20 > needs to be done manually, of course). >=20 > Worth imitating from Rust as well: rust's d/rules refuses to build=20 > if a stage0 is present while rustc is still listed as a Build-Depends=20 > for the architecture being built (or vice-versa). A bootstrap upload has= =20 > two halves (ship the seed, *and* drop the build dependency), and we=20 > might as well have that protection in place. >=20 > Rather than only describe this, I have implemented it on a branch,=20 > so that it can be reviewed and tried: >=20 > https://salsa.debian.org/ejjl/zig/-/tree/debian/stage0 >=20 > It differs from debian/latest in three files, and includes a script= =20 > that builds the seed tarball reproducibly and refuses to package a seed=20 > carrying a WebAssembly artifact, a /gnu/store ELF interpreter or an=20 > embedded build path. The source package comes to about 50 MB rather than= =20 > 24, for one upload cycle. >=20 > (b) A maintainer binary upload. I (or the sponsor) build(s) the binaries= =20 > locally against the bootstrap compiler, and a sponsor uploads those=20 > rather than just signing a .dsc. >=20 > Between those options, I lean towards option (a). Against option (b),=20 > rust's README.source puts it quite nicely into words: >=20 > "[The traditional Debian way is that] a developer locally installs=20 > some upstream > bootstrapping binaries [and] builds a Debian package, using these=20 > binaries as > undeclared build dependencies. [...] The problem with this is, Debian= =20 > does not > have any policy nor infrastructure that can try to reproduce what this > developer supposedly did." >=20 > The objection to (a) is that for one upload cycle the source package=20 > would contain a compiled binary; rust's README concedes the mechanism=20 > "stretches the definition of source package". My answer is below, under=20 > question 1. >=20 > After all this text: Two questions >=20 > 1. Is a Guix-produced, hash-recorded seed an acceptable one-time=20 > bootstrap for the first upload? >=20 > I would argue it is stronger than the rustc precedent, which seeded=20 > from an upstream prebuilt binary with no verification at all. Guix's=20 > seed is free software built from source, its builder is in Debian main,=20 > and the seed it produces is now shown to match upstream's bit for bit. >=20 > Just for reference: Debian already accommodates this class of=20 > problem, in several different ways. ghc and rustc self-host from the=20 > archive, with rustc's pkg.rustc.dlstage0 profile falling back to=20 > downloading upstream's prebuilt stage0 unverified. sbcl bootstraps from=20 > clisp, an independent implementation. gcc self-hosts and its original=20 > seed predates DFSG. And ocaml 5.4.1-1 ships boot/ocamlc, a bytecode=20 > image, in its orig tarball in main, with no ocaml in Build-Depends.=20 > debian/rules executes it on every build. >=20 > I think that the solution here proposed for Zig is a good attempt at= =20 > being DFSG compliant for such a situation: A seed derived entirely from=20 > source, and that seed shown to be identical to what upstream ships. >=20 > 2. Is an amd64-only first upload acceptable? >=20 > Guix's chain is x86_64-linux only. Efraim Flashner reported in 74217= =20 > that he could not get the early steps building on riscv64 or ppc64el.=20 > Other architectures need either that work done upstream or a=20 > cross-bootstrap. I just wanted to mention this upfront. I would be happy= =20 > to figure out if and how more architectures can be added. For a first=20 > upload, I hope this will be enough, so that we can get this into Forky=20 > still, together with other Zig-software. >=20 > ## Current Status and Open Issues >=20 > 1. The seed I used for hop 00 came from `guix build zig@0.16.0` **with**= =20 > substitutes. A `--no-substitutes` run is in progress as I write this; it= =20 > rebuilds the entire toolchain from Guix's stage0-posix seed upward,=20 > including seven LLVM builds, so it will probably take days. I will=20 > report the result when they come in. >=20 > 2. debian/copyright is not finished (barely started). The bundled=20 > mingw-w64, wasi-libc, BSD libc and aro trees still need auditing. I=20 > would appreciate guidance from anyone who has done this at scale (Rust,=20 > Go, npm?). There are ~30,000 files in the tarball, and from what I can=20 > see, there will be a variety of licenses. Perhaps there are tools=20 > available to extract this information? Thank you in advance! >=20 > 3. Should the abilists tables (above) stay? Guix removes them; I have=20 > kept them, because removing them costs cross-compilation for no gain I=20 > can see, and the tables shipped in 0.17.1 are current -- glibc 2.0=20 > through 2.44, so both unstable's 2.43 and 2.44 are covered. Advice welcom= e. >=20 > 4. One file needs a second opinion.=20 > lib/libc/include/generic-freebsd/netlink/netlink.h carries=20 > SPDX-License-Identifier: BSD-2-Clause with FreeBSD copyright, and then a= =20 > separate "Copyright (C) The Internet Society (2003)" notice for the=20 > material quoted from RFC 3549, including the no-derivatives clause that=20 > lintian's license-problem-non-free-RFC notices. I read that as a=20 > dual-licensed file and overrode the tag, which is what lintian's own=20 > description of the tag suggests for multi-licensed files. It is the only= =20 > file in the tree carrying RFC terms. If that is not the correct=20 > approach, I can also remove that. >=20 > ## Coordination >=20 > There are overlapping ITPs and I do not want to cause any trouble here=20 > (which is why I haven't filed an ITP myself yet): >=20 > #995670 ITP: zig (Nick Black), stalled > #1092895 ITP: zig 0.13.0 (Nick Black, Jan 2025), stalled > #1150314 ITP: zig-wasm-bootstrap (Ivan Carvalho, Oct 2026):=20 > described as "a port of Guix's Zig bootstrap to Debian", which is close=20 > to what I have done > Jonathan Carter created debian/zig on Salsa in Sep 2024, which didn't= =20 > see much action >=20 > What would be the best way forward? Jonathan, Nick, Ivan: Happy to work=20 > together with you, and anyone else, on getting Zig into Debian! This is=20 > my attempt of trying to get Zig and other Zig programmes into Debian, in= =20 > time for Forky, if possible. >=20 > (c) Besides options (a) and (b), there is the option of adding a second=20 > source package to the archive: zig-bootstrap. That would run the chain I= =20 > ran in the VM, producing a from-source seed that can compile Zig, with=20 > zig build-depending on it. That is the cleanest outcome of the three,=20 > since no compiled binary would enter the archive at any point. My chain=20 > takes around 1.5 to 2 hours on 8 cores, which may or may not be out of=20 > reach for a buildd. I think this may also be what Ivan's ITP is about,=20 > though arrived at in a slightly different way. Whatever works for Debian! >=20 > ## What I am asking for >=20 > Views on the two questions above, and on (a) versus (b) versus (c). If=20 > (a) is acceptable, then this is an ordinary source-only sponsorship=20 > request rather than anything unusual, which I hope makes it easier to=20 > help with. >=20 > My own interest is, besides Zig, also ghostty, which needs zig >=3D=20 > 0.17.0; I have built it end-to-end with the blob-free compiler on my=20 > builder VM, and it builds and works. But this one is about Zig, which=20 > would unblock other Zig packages. >=20 > Finally, if I should file an ITP for this, or not? >=20 > ## A final note >=20 > I have also written to the Guix people who work on Zig there, and have=20 > had favourable replies, though nobody has yet walked through the steps I= =20 > took. I will report back here either way. >=20 > Thank you very much for reading this, for your time and advice, and for=20 > any assistance. >=20 > Kind regards, >=20 > Edmund Lodewijks >=20 >=20 > P.S.: Again, for good measure, the links: >=20 > https://salsa.debian.org/ejjl/zig/ the package > https://salsa.debian.org/ejjl/zig/-/tree/debian/stage0 option=20 > (a), implemented > https://salsa.debian.org/ejjl/zig-bootstrap the=20 > bootstrap chain >=20 >=20 > --=20 > Edmund Lodewijks <edmund@proteamail.com> > TZ: UTC+2 / GMT+2 >=20 >=20 --nextPartjI51Z_HmSPKrwrJaskipMA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEXQGHuUCiRbrXsPVqADoaLapBCF8FAmr4xIkACgkQADoaLapB CF+IBhAAhNsgMskmRC+0vM/IaPgJH/muGfB/+BTAFbPuXh6wrfbRjEx5oV59l+y/ r7eau9DKSf73LpAYs7bHWAQJgNcOOeffhvrYyjMTydUT5G289GIpwPycgY8guQD5 R1GGrte7k7+1J9UYMMp4N1SRQbs/EzCYf1k+5BEh3in3/18L58DnL049KpH4EhUM SAmDqb+gme8cH88UYnSiyuJ/Ul56LHTVBJM8kVCT3Gi28WdPDPqmQjenAJblESx+ kJHCshkod8PLjYXhXDFJlVjOA1nAGNEWQpcJoFmLzpME/SKFPLnjcHWKcweUFbf/ eN1l9tEtEhExTVdaURaaYEFGiiX1Z9HtvmvuYdZ/Q1LTxtqQcxD8WNoTtES1BaSo /NuyeBDFmRMgiKZ22ETDQx7wlBBW2m+B7qvgOaZB33LmT7hJA3YHIvPAVlFWg16n aon57LKTpcmjgfXtL5NABfO+bI8bMag7XW0T5iIL0VvImFxQkO4GBNeo1zDkPvsU DsYx2dP1+iKSlhNlKSmVA9s2OPpaKJZ8rrIbaKw+UZ8SdLiCAAfrhZwksiH8QDzr PtRzUsngrZ1JmyRJSLyxj47c/mXC3tVncKUDgLyediUS7fQRn4goAKCYyXc+9TwE X5cjF7QIZx5njEXjFPNNBQS+wXlQuYlmD4hKWrHlFz2fpdW5qXI= =aM5q -----END PGP SIGNATURE----- --nextPartjI51Z_HmSPKrwrJaskipMA--
Technical Details
Message-ID:
<NZsxQ-bU2e-9@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomodReferences:
<NY0aB-b4Wx-9@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod From: Bastien Roucaries <rouca@debian.org> Newsgroups: linux.debian.devel Subject: Re: RFS: Bringing [zig] to Debian: A from-source bootstrap that reproduces upstream's seed Date: Sat, 14 Nov 2026 21:30:02 +0100 Message-ID: <NZsxQ-bU2e-9@gated-at.bofh.it> References: <NY0aB-b4Wx-9@gated-at.bofh.it> X-Original-To: debian-devel@lists.debian.org X-Mailbox-Line: From debian-devel-request@lists.debian.org Sat Nov 14 20:29:46 2026 Old-Return-Path: <rouca@debian.org> X-Amavis-Spam-Status: No, score=-4.401 tagged_above=-10000 required=5.3 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham autolearn_force=no MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPartjI51Z_HmSPKrwrJaskipMA"; micalg="pgp-sha512"; protocol="application/pgp-signature" X-Debian-User: rouca X-Mailing-List: <debian-devel@lists.debian.org> archive/latest/373197 List-ID: <debian-devel.lists.debian.org> List-URL: <https://lists.debian.org/debian-devel/> List-Archive: https://lists.debian.org/msgid-search/lo_nAyrlTJuVeuyHeDHf-Q@debian.org Approved: robomod@news.nic.it Lines: 371 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Cc: Jonathan Carter <jcc@debian.org>, ivancarvalho@google.com, dankamongmen@gmail.com, Edmund Lodewijks <edmund@proteamail.com> X-Original-Date: Sat, 14 Nov 2026 21:29:26 +0100 X-Original-Message-ID: <lo_nAyrlTJuVeuyHeDHf-Q@debian.org> X-Original-References: <898cd302-bf9e-4466-a604-62871bf3a8c5@proteamail.com>