Le mardi 10 novembre 2026, 20:59:26 heure normale d’Europe centrale Edmund Lodewijks a écrit : > Hi all, > > > Apologies for the lengthy email. This is based on a good two weeks or so > of work on making Zig packageable for Debian. > > > Short version: Zig's bootstrap blob can now be produced from source, and > the result is bit-for-bit identical to the blob that upstream ships in > the signed 0.17.1 release. I have a working `zig` source package built > on that basis. Before I take it further I would like to check two things > with the list, and find a sponsor. > > This follows on the January 2025 "getting ziggy with it" thread > <https://lists.debian.org/debian-devel/2025/01/msg00098.html>, which > ended without a bootstrap plan. > > > ## The problem in short > > Zig is written in Zig, and therefore needs Zig to compile itself. > Upstream breaks the build circularity by committing `stage1/zig1.wasm` > to the source tree: `wasm2c` converts it to C, the system C compiler > builds that, and the result builds the compiler. That artifact is a > build product, not source in the sense of DFSG §2, so Debian cannot ship it. > > A first attempt: Nick Black's proposal in msg00153 (i.e.: bootstrap with > the blob, then regenerate it) proves the blob is honest but does not > remove it from what the source package needs. The first upload is the > part that was unsolved, and which I am solving here. > > ## What is new > > GNU Guix solved the hard part (issue 74217, merged as > 40b9f33066..42e32d52c3): A chain starting from the C++ compiler upstream > used before the WebAssembly seed existed, walking forward through Zig's > history and regenerating the seed at each step. At the time of writing > this email, it reaches Zig 0.16.0. > > I extended that chain from 0.16.0 to 0.17.1 in nine further builds > across six seed-regeneration boundaries. The seed regenerated at the > last of those is identical to upstream's: > > $ minisign -Vm zig-0.17.1.tar.xz \ > -P RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U > Signature and comment signature verified > > $ tar xf zig-0.17.1.tar.xz zig-0.17.1/stage1/zig1.wasm -O | sha256sum > 77c02ad2496aab66fb408f831a49ee8f7ed6746326388c972735707881cac770 > > regenerated from source, never executing upstream's copy: > 77c02ad2496aab66fb408f831a49ee8f7ed6746326388c972735707881cac770 > 3,246,758 bytes > > This is upstream's minisign signature rather than a git clone, so the > claim does not rest on my checkout being authentic. The same seed ships > in 0.17.0, since the last regeneration commit precedes both releases. > > For those who are interested: The chain, the hops, the hashes, the > driver script, the logs... they are all documented and uploaded to Salsa: > > 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 > > ## One Zig package for the archive > > One source package: > > https://salsa.debian.org/ejjl/zig > > * `Files-Excluded: stage1/zig1.wasm` in debian/copyright, producing > zig_0.17.1+dfsg.orig.tar.xz. > * `Build-Depends: zig`: each zig built by the previous zig in the > archive, as gcc and rustc are. > * `debian/README.source` documents the bootstrap and how to reproduce > the seed. > * The bootstrap chain itself is *not* uploaded. It lives on Salsa. > > What the +dfsg repack removes is stage1/zig1.wasm, which cannot be > produced without an existing zig. > > I am deliberately keeping the four lib/libc/*/abilists symbol tables. > These can be regenerated at any time from glibc's and the BSDs' own > LGPL/BSD sources by an MIT tool. That tool is itself written in Zig; > however, regenerating them needs a zig, but they are not needed to > *build* zig, only to cross-compile to glibc and BSD targets. A zig built > without them works, and can then regenerate them. > > So the claim I want to make is not that the archive contains no > binaries. It is that it contains no binary whose source cannot be > rebuilt, and nothing circular at all. > > The package builds in a clean unstable chroot, and lintian reports no > errors or warnings beyond the expected unreleased-changes. What is left > at info and pedantic level is in Open Issues below. > > There is, of course, the question of how to solve the packaging problem > of the circular dependency on Zig for building Zig in Debian. I see two > ways around it for the package as it stands, plus a third that may > already have been proposed by Ivan (see Coordination below). I would be > happy to hear your thoughts on which should be preferred. > > (a) Ship the seed in the source package, upload source-only. This is > what the rust package does. > Based on what rust does, I would suggest we copy two out of their > three options: > > - no stage0/ present? --> build with the distro's zig. > - stage0/ present? --> bootstrap from that shipped seed. > > Following Rust, the detection would be by file presence rather than > by a build profile, so one debian/rules serves both cases and a normal > build cannot accidentally take the bootstrap path. Rust has a third > path, the pkg.rustc.dlstage0 build profile, which downloads a stage0 > during the build. That one won't work here: Debian buildds have no > network access during a build. > > For zig, that stage0 file would be > zig_0.17.1+dfsg.orig-stage0.tar.xz, carrying bin/zig and lib/zig from > the compiler my chain produced. dpkg-source unpacks a supplementary orig > tarball named orig-stage0 into stage0/ in the build tree, and > debian/rules would use that compiler instead of the system one. For that > upload only, Build-Depends: zig is disabled ([!amd64]). The seed is used > only to compile; it is never installed into a binary package. The next > upload leaves the tarball out and restores Build-Depends: zig (this > needs to be done manually, of course). > > Worth imitating from Rust as well: rust's d/rules refuses to build > if a stage0 is present while rustc is still listed as a Build-Depends > for the architecture being built (or vice-versa). A bootstrap upload has > two halves (ship the seed, *and* drop the build dependency), and we > might as well have that protection in place. > > Rather than only describe this, I have implemented it on a branch, > so that it can be reviewed and tried: > > https://salsa.debian.org/ejjl/zig/-/tree/debian/stage0 > > It differs from debian/latest in three files, and includes a script > that builds the seed tarball reproducibly and refuses to package a seed > carrying a WebAssembly artifact, a /gnu/store ELF interpreter or an > embedded build path. The source package comes to about 50 MB rather than > 24, for one upload cycle. > > (b) A maintainer binary upload. I (or the sponsor) build(s) the binaries > locally against the bootstrap compiler, and a sponsor uploads those > rather than just signing a .dsc. > > Between those options, I lean towards option (a). Against option (b), > rust's README.source puts it quite nicely into words: > > "[The traditional Debian way is that] a developer locally installs > some upstream > bootstrapping binaries [and] builds a Debian package, using these > binaries as > undeclared build dependencies. [...] The problem with this is, Debian > does not > have any policy nor infrastructure that can try to reproduce what this > developer supposedly did." > > The objection to (a) is that for one upload cycle the source package > would contain a compiled binary; rust's README concedes the mechanism > "stretches the definition of source package". My answer is below, under > question 1. > > After all this text: Two questions > > 1. Is a Guix-produced, hash-recorded seed an acceptable one-time > bootstrap for the first upload? > > I would argue it is stronger than the rustc precedent, which seeded > from an upstream prebuilt binary with no verification at all. Guix's > seed is free software built from source, its builder is in Debian main, > and the seed it produces is now shown to match upstream's bit for bit. > > Just for reference: Debian already accommodates this class of > problem, in several different ways. ghc and rustc self-host from the > archive, with rustc's pkg.rustc.dlstage0 profile falling back to > downloading upstream's prebuilt stage0 unverified. sbcl bootstraps from > clisp, an independent implementation. gcc self-hosts and its original > seed predates DFSG. And ocaml 5.4.1-1 ships boot/ocamlc, a bytecode > image, in its orig tarball in main, with no ocaml in Build-Depends. > debian/rules executes it on every build. > > I think that the solution here proposed for Zig is a good attempt at > being DFSG compliant for such a situation: A seed derived entirely from > source, and that seed shown to be identical to what upstream ships. > > 2. Is an amd64-only first upload acceptable? > > Guix's chain is x86_64-linux only. Efraim Flashner reported in 74217 > that he could not get the early steps building on riscv64 or ppc64el. > Other architectures need either that work done upstream or a > cross-bootstrap. I just wanted to mention this upfront. I would be happy > to figure out if and how more architectures can be added. For a first > upload, I hope this will be enough, so that we can get this into Forky > still, together with other Zig-software. > > ## Current Status and Open Issues > > 1. The seed I used for hop 00 came from `guix build [email protected]` **with** > substitutes. A `--no-substitutes` run is in progress as I write this; it > rebuilds the entire toolchain from Guix's stage0-posix seed upward, > including seven LLVM builds, so it will probably take days. I will > report the result when they come in. > > 2. debian/copyright is not finished (barely started). The bundled > mingw-w64, wasi-libc, BSD libc and aro trees still need auditing. I > would appreciate guidance from anyone who has done this at scale (Rust, > Go, npm?). There are ~30,000 files in the tarball, and from what I can > see, there will be a variety of licenses. Perhaps there are tools > available to extract this information? Thank you in advance! > > 3. Should the abilists tables (above) stay? Guix removes them; I have > kept them, because removing them costs cross-compilation for no gain I > can see, and the tables shipped in 0.17.1 are current -- glibc 2.0 > through 2.44, so both unstable's 2.43 and 2.44 are covered. Advice welcome. > > 4. One file needs a second opinion. > lib/libc/include/generic-freebsd/netlink/netlink.h carries > SPDX-License-Identifier: BSD-2-Clause with FreeBSD copyright, and then a > separate "Copyright (C) The Internet Society (2003)" notice for the > material quoted from RFC 3549, including the no-derivatives clause that > lintian's license-problem-non-free-RFC notices. I read that as a > dual-licensed file and overrode the tag, which is what lintian's own > description of the tag suggests for multi-licensed files. It is the only > file in the tree carrying RFC terms. If that is not the correct > approach, I can also remove that. > > ## Coordination > > There are overlapping ITPs and I do not want to cause any trouble here > (which is why I haven't filed an ITP myself yet): > > #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): > described as "a port of Guix's Zig bootstrap to Debian", which is close > to what I have done > Jonathan Carter created debian/zig on Salsa in Sep 2024, which didn't > see much action > > What would be the best way forward? Jonathan, Nick, Ivan: Happy to work > together with you, and anyone else, on getting Zig into Debian! This is > my attempt of trying to get Zig and other Zig programmes into Debian, in > time for Forky, if possible. > > (c) Besides options (a) and (b), there is the option of adding a second > source package to the archive: zig-bootstrap. That would run the chain I > ran in the VM, producing a from-source seed that can compile Zig, with > zig build-depending on it. That is the cleanest outcome of the three, > since no compiled binary would enter the archive at any point. My chain > takes around 1.5 to 2 hours on 8 cores, which may or may not be out of > reach for a buildd. I think this may also be what Ivan's ITP is about, > though arrived at in a slightly different way. Whatever works for Debian! > > ## What I am asking for > > Views on the two questions above, and on (a) versus (b) versus (c). If > (a) is acceptable, then this is an ordinary source-only sponsorship > request rather than anything unusual, which I hope makes it easier to > help with. > > My own interest is, besides Zig, also ghostty, which needs zig >= > 0.17.0; I have built it end-to-end with the blob-free compiler on my > builder VM, and it builds and works. But this one is about Zig, which > would unblock other Zig packages. > > Finally, if I should file an ITP for this, or not? > > ## A final note > > I have also written to the Guix people who work on Zig there, and have > had favourable replies, though nobody has yet walked through the steps I > took. I will report back here either way. > > Thank you very much for reading this, for your time and advice, and for > any assistance. > > Kind regards, > > Edmund Lodewijks > > > P.S.: Again, for good measure, the links: > > https://salsa.debian.org/ejjl/zig/ the package > https://salsa.debian.org/ejjl/zig/-/tree/debian/stage0 option > (a), implemented > https://salsa.debian.org/ejjl/zig-bootstrap the > bootstrap chain > > > -- > Edmund Lodewijks <[email protected]> > TZ: UTC+2 / GMT+2 > >
signature.asc
Description: This is a digitally signed message part.

