The Sparkles toolchain — Delivery plan
This is the milestone tracker for the toolchain specification, WASI and WebAssembly modules pages, and the tracker of the WebAssembly tech-debt catalogue below. Requirements live in those pages and evidence in testing.md; a milestone names them, it does not restate them.
Work spans three repositories. dlang.nix carries the toolchain packages, the LDC and LLVM forks carry compiler changes as atomic commits (TC3), and Sparkles carries its consumption of the toolchain, its WebAssembly modules and this specification as one pull request of atomic commits.
Milestones
| Milestone | Deliverable and obligations | Prerequisites | Acceptance gate | Exclusions | State |
|---|---|---|---|---|---|
| TC-M0 Specification | These pages, the decision record, and the repaired pin in the shaders and test-runner specifications | — | Cold read of the opening; adversarial review of the requirements; sidebar, spec-evidence and glossary checks; site build | Implementation | in progress |
| TC-M1 The dlang.nix branch | dlang.nix's toolchain branch, which Sparkles pins, carries build status on every package and no obsolete WASI fork packages. Establishes TC1, TC2, TC3 and TC5 | TC-M0 | dlang.nix's CI matrix evaluates; Sparkles ci test passes on the pinned revision | Merging into dlang.nix main (TCD2); toolchain changes | done |
| TC-M2 nixpkgs | Sparkles and dlang.nix on the latest nixos-unstable; dlang.nix's nixpkgs follows Sparkles' (TC4); the host-ELF compiler wrapper and DMD wrapper removed if the glibc split is gone | TC-M1 | Sparkles ci test, docs build and Android packages pass on the bump alone, before any toolchain change | LLVM configuration changes | done |
| TC-M3 The LLVM rebuild | One rebuild delivering TC6–TC14, TC16, TC17 and TC21–TC23: split outputs, shared LLVM library and trimmed tools, clang-sparkles and its stdenv, compiler-rt shipped with LDC, LDC built by its own clang, the assertions decision measured and applied, the closure table, Nix-run tests, warm caches | TC-M2 | TC22 tests pass on all hosts of TC21; closure table of TC16 recorded; caches warm (TC23) | WASI from source; all-LLVM profile | done |
| TC-M4 All-LLVM runtime profile | libunwind and libc++ from the fork; the opt-in profile (TC18–TC19); static terminal, hue and font-explorer builds (TC20) | TC-M3 | TC19 interop scenarios; the three applications' suites under the profile; size and start-up recorded | musl builds (open question Q2) | done |
| TC-M5 WASI from source | TCW1–TCW11: sysroots for p1, p2 and experimental p3, LTO variants, drivers, components, reactors, D runtimes per preview, runtime test suites under wasmtime; the LDC fork fixes for TCW11 and -ffile-prefix-map (TC15) | TC-M3 | druntime and Phobos test runners pass for p1 and p2 with listed known failures; p3 probe result recorded | Browser component-model hosting | done |
| TC-M6 WebAssembly modules | TCM1–TCM9: dub-built reactor modules on the shared interface, one site loader, no committed binary, native-agreement check; the test runner's WASI execution mode | TC-M5 | TCM9 check passes; site build from a clean tree; ci test --special-modes all runs @wasm tests on WASI | — | done |
WebAssembly tech-debt catalogue
Recovered from the audit of the first WebAssembly toolchain. A row closes when its milestone's gate passes; rows closed by work that predates this plan name the pull request that closed them, and closed rows stay for reference.
| ID | Debt | Repayment | Milestone | Status |
|---|---|---|---|---|
| WTD1 | Three D compilers and three LLVMs in the closure | One fork of each (TC1, TC2), PetarKirov/sparkles#691 | — | closed |
| WTD2 | An obsolete WASI fork of LDC duplicated upstream's WASI support | Dropped; the unified fork carries upstream's support (#691) | — | closed |
| WTD3 | Driver patches read the sysroot from the environment and forced one link mode for every preview | Link through the per-preview clang driver (TCW5) | TC-M5 | closed |
| WTD4 | Phobos redirected to a fork that stubbed directory iteration | Upstream Phobos (#691) | — | closed |
| WTD5 | The D runtime built for one preview, the modules compiled for another | One runtime per preview (TCW8) | TC-M5 | closed |
| WTD6 | The WASI runtime is not tested in Nix | TCW10: druntime and Phobos runners under wasmtime | TC-M5 | closed |
| WTD7 | The component linker built from source with a workaround, builtins wired by absolute path | Rebuilt as part of the WASI toolchain (TCW6, TCW1) | TC-M5 | closed |
| WTD8 | The modules build only on x86_64 Linux | TCM2 | TC-M6 | closed |
| WTD9 | Duplicated WebAssembly defaults in Sparkles' compiler configuration | LDC's own configuration (#691) | — | closed |
| WTD10 | A shell wrapper parses -mtriple to keep host linker flags off cross links | Removed with the glibc split (TC4) | TC-M2 | closed |
| WTD11 | Every module's references are scrubbed because __FILE__ names the toolchain | TC15: the compiler maps its own paths and builds assert their absence; the WebAssembly modules' nuke-refs goes with their hand-written build (TCM1) | TC-M5 | closed |
| WTD12 | Sparkles pinned to a stacked feature branch of dlang.nix | Accepted until upstreaming (TCD2); the stack is one linear branch | TC-M1 | accepted |
| WTD13 | The modules are built by a hand-written compiler invocation that re-derives the dependency graph | TCM1 | TC-M6 | closed |
| WTD14 | The modules' entry points are compiled by no test or per-commit build | TCM1, TCM2 | TC-M6 | closed |
| WTD15 | The test runner's attribute module is on the modules' import path | Resolved by dub (TCM1) | TC-M6 | closed |
| WTD16 | The modules duplicate their memory interface | TCM5 | TC-M6 | closed |
| WTD17 | The table module avoids exceptions | TCW9, TCM6 | TC-M6 | closed |
| WTD18 | Module constructors are assumed not to run | TCW7, TCM4 | TC-M6 | closed |
| WTD19 | Command modules are used as reactors | TCM4 | TC-M6 | closed |
| WTD20 | Each site component stubs the WASI imports itself | TCM7 | TC-M6 | closed |
| WTD21 | The text module's binary is committed and never rebuilt | TCM3 | TC-M6 | closed |
| WTD22 | Module size | TCW3, TCM8 | TC-M6 | closed |
| WTD23 | Comments describe the obsolete WASI fork | Rewritten with the repayment | TC-M6 | closed |
| WTD24 | The test runner's --wasm mode is -betterC on bare wasm32 | WASI execution mode in the test-runner specification | TC-M6 | closed |
| WTD25 | The shipped modules have no tests | TCM9 | TC-M6 | closed |
| WTD26 | The toolchain is pinned in the aggregate build and CI timeouts are inflated for cold builds | The pin set holds the toolchain (TC24); the aggregate pin is gone and the timeouts are back to 30 minutes | TC-M3 | closed |
| WTD27 | --wasm needs wasm-ld on PATH | WASI links go through the WASI driver (TCW5); --wasm-bare links internally | TC-M6 | closed |
| WTD28 | Compile-time real arithmetic folds with x87 precision for quadruple-precision targets | TCW11 | TC-M5 | closed |
| WTD31 | LLVM assertions cost about 10 % in optimized builds | TC17 | TC-M3 | accepted |
| WTD32 | The Android LDC was a separate, stock compiler | Built on the fork (#686) | — | closed |
| WTD33 | The stock LDC's closure carried its bootstrap compiler and a second LLVM | The stock LDC left the toolchain (#691) | — | closed |
| WTD35 | Compute-stage commits of the shader work are not on the fork's sparkles/main | Rebased onto it by their owner | — | planned |
| WTD36 | Three LLVM fork commits reach the WASI sysroots as patches, and LLVM still installs unused tools | The fork commits reach the sysroots through the fork itself, with a fourth for wasm-ld; ClangIR and the unused tools are off (TCD11, TC9) | TC-M3 | closed |
WTD29, WTD30 and WTD34 were fork-internal fixes (LLVM 24's exception personality, interpolated-expression precedence, the clang static analyzer build) and are recorded in the forks' commit messages.
Cache pins
TC24 makes nix/pin-targets.nix the pin set, and ci/toolchain-pin.d (implementation in apps/ci/src/derivation_pin*.d) applies it:
- The set, not a catalogue. The tool evaluates
legacyPackages.<system>.pinTargetsfor x86_64-linux, aarch64-darwin and aarch64-linux, onenix evalper system, and pins each entry as<name>-<system>from.#legacyPackages.<system>.pinTargets.<name>. A system that fails to evaluate, or evaluates to nothing, fails the run. - Name filters.
--toolchainskeeps the names with thetoolchain-prefix,--androidthose with the-androidsuffix,--libsthe rest; positional entry names and a repeatable--systemnarrow further. A name or system outside the set, or a selection that matches nothing, is an error. - One revision.
--revisionsandCI_PIN_REVISIONSdefault to 1 and must be positive. - No pin outside the set. After every selected pin succeeds, the tool lists the cache's pins (
GET https://app.cachix.org/api/v1/cache/<cache>/pin) and deletes each one the whole expansion does not name (DELETE …/pin/<name>), whatever the selection, so a run narrowed to one host keeps the others' pins. A dry run lists the deletions and makes none. - The cap. The summary states the selected closures' non-upstream size against the cache's 10 GiB.
- The TC23 gate.
--checkevaluates every selected out path, from any host for all three systems, and askshttps://<cache>.cachix.org/<hash>.narinfo; it exits non-zero listing each output that is missing or unanswered. It builds nothing and needs no token.
Building aarch64-linux and aarch64-darwin outputs needs a builder for that system, so each host pins its own with --system.
CI's pin-cache job runs the gate on every trigger: nix run .#ci-minimal -- check pin-cache checks the set's toolchain-* entries for all three hosts, the outputs TC23 names. A pull request that leaves the toolchain alone passes it. One that moves the lock is planned first (TCD13): pin-plan (toolchain-pin-check --plan) lists the missing outputs, pin-build builds those within the budget, by their recorded costs (ci cache pin-costs), on a runner of their system and pushes them to R2, recording each build, and the gate then runs. An output over the budget stays red, reported with the ci/toolchain-pin.d command that builds it on a developer host. The other entries change with ordinary pull requests and are pinned after they merge, so the job leaves them to --check.
Acceptance for the plan: a lock move whose outputs no cache serves turns green through pin-build alone; an output given a cost over the budget, and an output whose closure needs it, is reported and not built. Each pin-build build is recorded as a pin-build:<pin> task, and the next plan's cost for that pin is the median of those records.
Acceptance: a dry run on each host lists exactly the set and no deletion; a real run leaves the cache's pin list equal to the set for all three hosts. --check passes before every lock move.