Skip to content

feat(toolchain): publish per-chip Xtensa toolchain slices - #1951

Merged
zackees merged 2 commits into
mainfrom
agent/toolchain-slice-publish
Nov 7, 2026
Merged

zackees merged 2 commits into
mainfrom
agent/toolchain-slice-publish

Conversation

@zackees

@zackees zackees commented Nov 7, 2026

Copy link
Copy Markdown
Member

Publishes the server half of the per-chip toolchain slices: @esp-toolchain now
exists as a mirror shard, and the three Xtensa chips' toolchain slices it points
at are uploaded and verified. Closes the "publishing the slices" item that #1944
has been waiting on since #1947 (slicer) and #1949 (client).

What lands

  • ci/publish_toolchain_slices.py — one invocation publishes ONE host package
    of ONE toolchain version: it runs the existing slicer, uploads each per-chip
    archive under v1/espressif/<toolchain>/release/<version>/<host>/<chip>/
    (public-read), HEAD-checks every upload, and only then writes the shard
    component plus its Index descriptor.
  • site/mirror/shards/esp-toolchain.json + one line in site/mirror/manifest.json
    — the @esp-toolchain shard keyed by the exact vendor URL
    crates/fbuild-toolchain resolves from the pioarduino metadata, listing one
    slice per chip the toolchain ships: esp32, esp32s2, esp32s3.
  • ci/test_publish_toolchain_slices.py — 28 offline contract tests.
  • crates/fbuild-packages-fetch/src/downloader_mirror_manifest_tests.rs — the
    committed shard is parsed by the REAL client parser, because one bad entry
    rejects the whole manifest for every client.

Design choices worth reviewing

  • Pins come from the vendor metadata, never from a local archive. sha256
    and size are the vendor's numbers for that exact URL, so a mismatched tree
    cannot relabel the asset. --archive mirrors the whole bundle and refuses a
    file that disagrees with those pins; without it the entry lists the vendor URL
    alone, i.e. the download behaviour of every host/chip without a slice is
    unchanged.
  • One host per invocation, chips additive. A slice carries that host's
    compilers, so a linux-amd64 slice is not a macos-arm64 install. Chips are
    merged into the existing component, so publishing esp32 later cannot retract
    the esp32s3 slice (test-pinned in both directions).
  • Write-after-verify. A failed or short upload leaves the shard and Index
    untouched, so an entry can never point at a missing object (test-pinned).
  • --check needs no network and fails when the Index descriptor no longer
    hashes the committed shard — the Index is generated, so a regeneration that
    does not know this owner would silently send every client back to whole
    archives.

Real run (not a projection)

Extracted xtensa-esp-elf 14.2.0_20260121 x86_64-linux-gnu tree (1.1 GB, 4187
members, chips esp32/esp32s2/esp32s3) from this host's fbuild cache; the vendor
archive is 176,559,292 B:

chip slice bytes payload members sha256
esp32s3 106,462,349 623.7 MB 3557 36a9f0e7…f0858
esp32s2 106,655,161 625.6 MB 3545 11564ea6…c553
esp32 141,361,956 625.9 MB 3554 037802e0…374d

Each was produced with --verify (extract, run that chip's compiler,
-print-libgcc-file-name resolving inside the extraction, then a real
-std=gnu++17 -Os -c); esp32s3 took 6m24s and the pair 11m.

Verified again AFTER upload by downloading each published object over HTTPS
(200, content-length = the pinned size) and hashing it to the exact pinned
sha256; the esp32s3 object was also byte-compared with the local slice, then
extracted from the DOWNLOAD of it and used: its xtensa-esp32s3-elf-gcc reports
crosstool-NG esp-14.2.0_20260121 14.2.0, libgcc resolves inside, and a probe
compiles. The archive carries no .install_complete.

--check passes against the committed documents; the Rust test parses them and
resolves the vendor URL to the slice, and goes RED when the slice format is
corrupted (the whole document is then rejected, which is the failure it guards).

Tests

  • uv run --no-project --with zstandard python -m unittest ci.test_publish_toolchain_slices — 28 passed.
  • soldr cargo test -p fbuild-packages-fetch --lib -- committed_toolchain_shard — 1 passed.
  • ci/test_local_suites, ci/test_gate_script_coverage, ci/test_slice_toolchain — pass.
  • Boundary 44/43 rc0, test layout ok, dylint allowlists ok, ruff check + ci/check_python_complexity clean.

Not done here

  • Every other host package (macos-arm64, win32, ...) is one command each and
    needs that host's extracted tree; until then those hosts keep the whole
    archive. Re-slicing a chip later is also a no-op for the others (the shard
    merges per chip, test-pinned).
  • The end-to-end "fbuild installs the slice and builds ESP32-S3" measurement
    needs the shard live on main (clients read the published manifest), so it is
    the follow-up this unblocks — CI's ESP32 board matrix exercises it on the next
    push to main.

The slicer (#1947) and the client (#1949) were done; nothing published had a
slice for a client to resolve, so every ESP32 build still downloaded the whole
176 MB unified Xtensa archive. This is the server side.

`ci/publish_toolchain_slices.py` publishes ONE host package of ONE version:
it runs the slicer, uploads each chip archive to
`v1/espressif/<toolchain>/release/<version>/<host>/<chip>/` as public-read,
HEAD-checks every upload, and only then writes the shard component plus its
Index descriptor. Integrity pins come from the vendor metadata, so a mismatched
local tree cannot relabel the asset; `--archive` mirrors the whole bundle only
when its bytes match those pins. Chips merge into an existing component, so a
later `--chips esp32` cannot retract an earlier `esp32s3`. `--check` verifies
the Index descriptor still hashes the committed shard -- the Index is a
generated document, and a regeneration that does not know this owner would
silently send every client back to whole archives.

Published and verified for linux-amd64 / 14.2.0_20260121: esp32s3 106,462,349 B,
esp32s2 106,655,161 B, esp32 141,361,956 B (vendor 176,559,292 B). Each was
sliced with --verify, then downloaded again post-upload and hashed to its pinned
sha256; the esp32s3 object was extracted from the download and its compiler
used (`crosstool-NG esp-14.2.0_20260121 14.2.0`, libgcc resolving inside,
probe TU compiling).

The committed shard is parsed by the real client parser in a unit test: one bad
entry rejects the WHOLE manifest for every client, so this is checked, not
hoped.
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

The committed-manifest contract (enforced by
committed_manifest_is_accepted_and_prefers_the_bucket) requires every published
entry to serve the mirror first and keep the vendor URL as the fallback. My first
cut listed the vendor URL alone, so a slice-less chip or an unpublished host
would have depended on GitHub for every download. --archive is now required and
must hash to the metadata pins; it is uploaded and listed first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant