Skip to content

Bootstrap from a checked-in with1.wasm: with migrate Zig's wasm2c to With, retire per-host seeds #2363

Open

Description

@ehartford

Goal

Bootstrap from a portable artifact checked into the repo, not from a seed binary per host fetched from a release. Today every host needs its own seed (darwin-aarch64, linux-x86_64, linux-aarch64, windows-x86_64), each cut on its own machine, and the seed operations fail in ways that keep showing up:

What Zig does (ziglang/zig, verified in stage1/ and bootstrap.c)

File Size Role
stage1/zig1.wasm 3.2 MB the compiler built for wasm32-wasi, checked in
stage1/wasm2c.c 122 KB translates a wasm module to C; a translator, not an interpreter (Zig dropped interpretation as too slow)
stage1/wasi.c 40 KB the WASI imports, as C
bootstrap.c builds wasm2c with the host cc, translates zig1.wasm to C, builds that, and uses the result to build the real compiler

Bootstrap needs only a C compiler, which every host has. zig1.wasm is updated rarely, by hand, when the compiler needs a newer language feature.

Decision (Eric, 2026-10-12)

with migrate stage1/wasm2c.c (and wasi.c) to With.

Open question: what builds the translator

A With wasm2c is With source, so building it needs a With compiler. Its output is C, so the bootstrap also needs a host C compiler, and today the tree has no C (only .s). Possible answers, for a ruling:

  1. Frozen per-host runner. Keep a per-host binary, but only of the translator plus WASI. It is small and changes rarely, while the compiler moves as one with1.wasm for every host. Seeds stop churning with every compiler change, but they still exist.
  2. Self-applied translator. Ship the translator itself as wasm too, translated once to C (Zig's shape) and kept as a generated, checked-in artifact. That needs a ruling against "not a line of non-With code", even for generated output.
  3. Native code instead of C. Have the With wasm2c emit platform assembly (.s is allowed), assembled by the host assembler. Each host target needs its own backend in the translator.

Prerequisites to verify

  • The compiler builds for wasm32 with a WASI-shaped runtime. Today wasm32 is a program target (build.w, :cross-rt-wasm, wasm32-unknown-unknown), not yet a target the compiler itself builds for.
  • with migrate handles wasm2c.c without stubs (No Silent Fallbacks): any function it can't translate is a loud failure to fix in the migrator.
  • How fast the translated compiler is: Zig accepts a slow zig1 because it builds only zig2.

Activity

  1. ehartford commented on Oct 12, 2026

    @ehartford
    ContributorAuthor

    Eric (2026-10-12): "we can checkin the binary like they do". As Zig checks in stage1/zig1.wasm, the bootstrap artifact is committed to the repo, not fetched from a release.

  2. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced: not started. The tree has no checked-in .wasm bootstrap artifact and no wasm2c path in build.w, build/ or src/. Eric (2026-10-12, comment above): "we can checkin the binary like they do".

    post-release: a bootstrap campaign.

  3. added this to the post-v0.16.0 milestone on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions