Skip to content

ci(perf): cross-build the OS product on Linux via setup-soldr (cook + heavy cache), ship the binary to native runners for tests/benchmarks #59

Closed
3 of 3 issues completed

Description

@zackees

Updated 2026-08-07 — reframed as adoption. After auditing soldr / setup-soldr / soldr-toolchain / forge, the cross-compile capability already exists and ships (soldr build --target, bundled zig + xwin, catalogue toolchains at a glibc-2.17 floor, provisioned by setup-soldr cross-targets). reld's blockers came from using the soldr cargo build passthrough, not the native front door. Nothing upstream needs to be built for this goal. See the detailed update comment. Original proposal preserved below.

Context

Scarce CI runners (windows-2022, macos-14) currently pay for the full compile + link + build of the OS-specific product on-target:

  • ci.yml → phase1-native builds --all-targets and runs the whole test suite natively on windows-msvc, windows-gnu, and macos-arm64.
  • The reld-bench smoke steps in ci.yml build reld-bench --release on the native windows/macos runners before benchmarking.
  • Windows/macOS minutes are the scarce, expensive, queue-prone capacity; Linux (ubuntu-24.04) is cheap and plentiful.

We already have two proofs that the "compile elsewhere, run here" split works in this repo:

  1. .github/workflows/linker-artifacts.yml demonstrates the exact build → host handoff shape we want to generalize: a per-target build job uses zackees/setup-soldr@main with cross-targets + soldr cargo build --locked --release, uploads the binary as an artifact, and a separate host job just downloads it and smoke-runs it (--version) on the native runner. No compilation on the native leg.
  2. .github/workflows/benchmark-assets.yml already froze the corpus build so the benchmark loop does zero compilation in the loop. This issue is the analogous move for the linker binary itself: cross-build it once on Linux, then the native runner does zero compilation before benchmarking.

soldr cook (the dependency prebuild/warmup) and setup-soldr's layered content-addressed cache (the zccache store) are the mechanism. This repo has a large existing cache budget, so it's a good real-world test case for how well setup-soldr's caching actually holds up under a heavy, multi-target workload.

Proposal

Generalize the linker-artifacts.yml build→host split to CI and the benchmarks:

  1. Cross-build on Linux. Add/extend jobs that cross-compile the release product (reld / reld-link) for x86_64-pc-windows-msvc, x86_64-pc-windows-gnu, and aarch64-apple-darwin on ubuntu-24.04 runners via zackees/setup-soldr@main:
    • cross-targets: <triple>, --release.
    • prebuild-deps: soldr-cook to warm dependencies via soldr cook before the workspace's own soldr cargo build.
    • cache: true with the per-layer toggles (build-cache, target-cache, cargo-registry-cache) enabled so we lean on the repo's cache budget.
    • Upload the finished binary as an artifact.
  2. Native leg = download + run only. The windows-* / macos-* legs stop compiling the product. They download the cross-built artifact and:
    • run the on-target tests/smoke that only need the shipped binary (see Open questions for the test-harness split), and
    • run reld-bench against the prebuilt binary + a frozen corpus (the cleanest first candidate — reld-bench needs only the binary and a corpus, no source tree).
  3. Measure the caching. Capture setup-soldr's cache outputs as the success signal: cache-hit, build-cache-hit, target-cache-hit, and especially compile-cache-hits / compile-cache-misses / compile-cache-hit-rate, plus wall-clock deltas vs. the current native-build path. Surface them in the job summary.

Dependency on upstream soldr (why this can't fully land today)

The existing cross-release job in ci.yml (currently only x86_64-pc-windows-gnu) deliberately does not use soldr cargo and hand-wires mingw-w64 instead. Its inline NOTE documents the two blockers this issue depends on:

Once those land, the cross-release job (and the new legs above) should switch to soldr + soldr cc --target and drop the manual mingw CC/CXX/AR wiring. This issue tracks the reld-side rollout; #2334 / #2335 are the upstream prerequisites.

Acceptance criteria

  • At least the benchmark path (windows-msvc + macos-arm64) runs reld-bench against a cross-built-on-Linux release binary, with zero product compilation on the native runner.
  • Cross-build jobs use zackees/setup-soldr@main with prebuild-deps: soldr-cook and cache: true, and the job summary reports setup-soldr's cache-hit / compile-cache-hit-rate outputs.
  • A recorded wall-clock comparison (native-build vs. cross-build + ship) demonstrating the scarce-runner time reduction, captured in the PR description or job summary.
  • The cross-release NOTE in ci.yml is updated to point at this issue and the current state of #2334 / #2335; when those are resolved, the job switches to soldr cc --target and drops the manual mingw wiring.
  • No loss of coverage: any on-target test that genuinely needs the source tree / cargo test harness (see Open questions) is either preserved on the native leg or explicitly documented as out of scope for the artifact-only path.

Decisions

  • Scope this as staged, benchmarks first. reld-bench only needs the binary + a corpus, so it's the lowest-risk first cut; acceptance-test offloading is a follow-up. Rationale: it delivers the scarce-runner savings immediately without waiting to untangle the cargo-test harness dependency.
  • Depend on, not duplicate, the upstream soldr fixes. Rather than re-solving the host-compiler / rust-std cache problems in reld's CI, this tracks #2334 / #2335 and flips to soldr cc --target once published. Rationale: the cross-release NOTE already committed to that plan.
  • Priority P2. A CI cost/speed optimization, not a correctness or shipping blocker. Upgrade if scarce-runner queueing becomes a merge bottleneck.
  • Treat this as the setup-soldr caching test case. The goal explicitly wants to validate setup-soldr under heavy caching, so emitting the cache-hit metrics is a first-class deliverable, not incidental.

Open questions

  • Test-harness split: which native tests can run against only the shipped binary vs. which need the source tree + cargo test (e.g. the acceptance / external / difftest suites in phase1-native all invoke cargo test)? Those still need a source checkout on-platform even if the product is prebuilt — so the win for them is narrower (skip the product build, still run tests). Benchmarks are the clean artifact-only case; the acceptance suite needs a decision on whether to prebuild + cargo test --no-build-style reuse or keep compiling.
  • msvc from Linux: does the setup-soldr / soldr cc --target x86_64-pc-windows-msvc path cover the MSVC ABI (link.exe/lld-link, import libs) from a Linux host, or is windows-gnu the only cross target that's realistic until msvc cross tooling exists? This bounds how much of the windows leg can actually move off-runner.
  • Corpus availability per target: the benchmark path needs a frozen corpus for each target on the native runner (see bench: frozen Bevy link corpus — compile once per platform, replay the link every iteration #55 / meta: frozen linker-object benchmark assets — benchmark-assets branch(es) + manifest.json (compile once, link every iteration) #57 benchmark-assets work) — confirm the manifest covers windows-msvc + macos-arm64.

Related issues

Sub-issues

Sub-issues

3 of 3 Issues completed
Loading 3 sub-issues

Activity

  1. zackees commented on Aug 7, 2026

    @zackees
    CollaboratorAuthor

    Update — soldr already ships the cross-compile front door; this is an adoption, not a build-it-ourselves

    I dug through zackees/soldr, zackees/setup-soldr, zackees/soldr-toolchain, and zackees/forge. The premise this issue (and the cross-release NOTE in ci.yml) was written under — "soldr's cross path is broken, so we hand-wire mingw/llvm" — is specific to the soldr cargo build passthrough. The native front door already does everything we want, with zero compiler tools to install on the runner.

    What already exists upstream (verified in the source)

    soldr — soldr build --target <triple|alias> is a native cross front door that "owns compiler, linker, SDK, sysroot, environment, and capability selection" (verbatim from setup-soldr/action.yml cross-targets doc). Under the hood:

    • crates/soldr-cli/src/cargo_front_door/zig_shim.rs — bundled zig cc/cxx/ar/ranlib wrappers per target: x86_64/aarch64-unknown-linux-gnu, *-linux-musl, x86_64-pc-windows-gnu, x86_64/aarch64-apple-darwin (with catalogue Apple SDK handling). This is the "no CC_/CXX_/AR_ hacks" path — the wrappers are the target C toolchain, and cc-built deps (zstd, blake3) build for the target, not the host.
    • crates/soldr-cli/src/cargo_front_door/clang_cl_shim.rs — MSVC cross via soldr cargo xwin build --target *-pc-windows-msvc (xwin + a clang --driver-mode=cl shim). Explicit charter comment: "they just type soldr cargo xwin build --target ... and it works on a stock device with no dependencies."
    • crates/soldr-cli/src/target_alias.rs — target aliases (win-x64, mac-arm64, linux-x64-musl, …) + a glibc-floor selector (x86_64-unknown-linux-gnu.2.17), baseline 2.17 for the two gnu-linux targets — i.e. the .2.17 mechanism #2335 proposed is already implemented for soldr build.

    soldr-toolchain — the catalogue already carries every sysroot/toolchain these paths consume: mingw-w64-gcc-windows-x64-gnu, gnu-linux-toolchain-* (glibc-floored), musl-linux-toolchain-*, apple-sdk-thin-*, xwin-cache-*, and an MSVC bundle via external-entries.v1.json.

    forge — builds those recipes on native GHA runners with a hard glibc-2.17 floor ("Every Linux -gnu recipe MUST build against glibc 2.17"), feeding soldr-toolchain → the soldr release archive.

    setup-soldr — cross-targets: <triple> runs soldr prepare for that target and exports the compiler/linker/SDK/sysroot/env plan; the build step is just soldr build --target <triple>. No apt-get install gcc-mingw, no choco install llvm, no brew install llvm@18.

    Consequence for reld

    The cross-release NOTE's two blockers (soldr#2334 host-compiler C deps, soldr#2335 rust-std cache) were hit on soldr cargo build --target … — the bare passthrough, which deliberately does not cross-route. Switching to soldr build --target … (or soldr cargo zigbuild / soldr cargo xwin build) sidesteps both, because that path provisions and wires the target toolchain itself.

    Revised plan for this issue (adoption)

    1. cross-release job → drop apt-get install gcc-mingw-w64 + the manual CC_/CXX_/AR_/LINKER env. Use zackees/setup-soldr@main with cross-targets: x86_64-pc-windows-gnu and build with soldr build --target x86_64-pc-windows-gnu -p reld --bin reld. Extend the matrix to aarch64-apple-darwin and x86_64-pc-windows-msvc (the latter via soldr cargo xwin build) so every OS product is cross-built on ubuntu.
    2. Native legs = download + run only. windows-2022 / macos-14 jobs stop compiling the product: download the cross-built artifact, then run the on-target tests/smoke that need only the binary, and run reld-bench against the prebuilt binary + a frozen corpus (cleanest first candidate).
    3. phase1-native linux leg can also move to soldr build for a glibc-2.17-floored release artifact if we want a portable Linux binary; the reference-linker install stays (that's test fixtures, not the product toolchain).
    4. Heavy-cache test case. Keep cache: true + prebuild-deps: soldr-cook and surface setup-soldr's compile-cache-hit-rate / *-cache-hit outputs in the job summary — this is our real-world stress test of setup-soldr caching across a 3-target cross matrix.

    Genuine remaining upstream gaps (narrow — filed/annotated separately, not blockers here)

    • soldr cargo build --target (bare passthrough) still doesn't auto-route C deps — soldr#2334. Not needed by reld once we use soldr build --target; worth fixing upstream for ergonomics or documenting soldr build as the front door.
    • A standalone user-facing soldr cc --target verb — soldr#2335. The wrappers exist internally (zig_shim); exposing them as a top-level command is a nice-to-have reld doesn't require.
    • soldr build --target glibc floor is baseline-2.17 only for x86_64/aarch64-unknown-linux-gnu; other floors error out and point at cargo-zigbuild (soldr#1060 / soldr#2139).

    Net: nothing in soldr/setup-soldr/soldr-toolchain/forge needs to be built for reld to hit this issue's goal — the cross toolchains are already ours, already published, already fetched on demand. The work is reld adopting soldr build --target and deleting the hand-installed toolchain steps. I'll open a draft PR wiring this and link it here; it needs a live CI run to validate the three cross legs end-to-end.

  2. zackees commented on Aug 7, 2026

    @zackees
    CollaboratorAuthor

    Correction — blessed cross targets are MSVC + Apple/Linux, not windows-gnu

    soldr's canonical target set (soldr/ci/canonical-targets.json) blesses MSVC for Windows — x86_64-pc-windows-msvc (win-x64) and aarch64-pc-windows-msvc (win-arm64) — with "ci":{"kind":"cross"}, plus x86_64/aarch64-apple-darwin and the linux gnu/musl set. There is no x86_64-pc-windows-gnu in the canonical set: soldr's design rule is "MSVC on Windows always," and windows-gnu is built on a Windows host with the managed MinGW-w64 bundle, not cross-from-Linux (examples/docker-cross-win/README.md).

    Consequences for the plan above:

    • reld's existing cross-release job targets x86_64-pc-windows-gnu — the wrong triple to move onto the blessed soldr build --target cross-from-Linux path. The scarce runners reld actually benchmarks/tests on are windows-msvc (phase1-native msvc leg + reld-bench windows-msvc + msvc self-host) and macos-arm64.

    • So the cross-from-ubuntu matrix should be x86_64-pc-windows-msvc and aarch64-apple-darwin. Exact invocation, straight from soldr's own cross-compile-all-targets.yml (all targets from linux-x86 runners):

      soldr build --package reld --bin reld --release --locked --target x86_64-pc-windows-msvc
      soldr build --package reld --bin reld --release --locked --target aarch64-apple-darwin

      soldr's cargo front door auto-injects the xwin CC_/CXX_/AR_/LD_<triple> for the msvc lanes (prepare_xwin_env / compute_subcommand_env_overrides in cargo_front_door/mod.rs) — no workflow-level CC_<triple>=clang-cl hedge, and the darwin lane injects the Apple SDK env internally.

    • Keep windows-gnu on a native Windows runner if it must be covered at all (it's secondary for reld); don't try to cross it from Linux.

    I'm opening a draft PR that adds an additive cross-ship workflow (build msvc + darwin release binaries on ubuntu via setup-soldr + soldr build --target, upload, then a native leg downloads + smoke-runs the artifact) so it can be iterated against a live CI run without touching the existing green jobs. Linking it here.

  3. zackees commented on Aug 7, 2026

    @zackees
    CollaboratorAuthor

    Draft implementation opened: #61 — additive cross-ship.yml that cross-builds reld for windows-msvc + macos-arm64 on ubuntu via soldr build --target (zero toolchain installs) and smoke-runs the shipped binary on the native runner. Needs a live CI run to validate the two cross legs; it doesn't touch the existing green jobs. Once green, migrate cross-release + the native reld-bench build steps onto it.

  4. zackees commented on Aug 7, 2026

    @zackees
    CollaboratorAuthor

    ✅ Proven in CI — cross-compile works with zero toolchain installs

    The cross-ship workflow (PR #61) ran green end-to-end on a live GHA run (run 31196543127):

    job result note
    Cross build (linux → windows-msvc) ✓ 6m22s soldr build --target x86_64-pc-windows-msvc on ubuntu, no compiler tools installed
    Cross build (linux → macos-arm64) ✓ 6m21s soldr build --target aarch64-apple-darwin on ubuntu
    Host run / windows-msvc ✓ 6s downloaded reld.exe; --version printed Reld; zero compilation on-target
    Host run / macos-arm64 ✓ 7s verified arm64 Mach-O; zero compilation on-target

    This settles the "fix missing cross-compile functionality upstream" branch of the plan: nothing is missing — soldr cross-built both foreign targets from Linux with no apt/choco/brew toolchain installs, exactly as intended. The scarce Windows/macOS runners did only download + run (6–7s).

    setup-soldr caching findings (the "how well does it work" test case)

    Run #1 was a cold cache (0 hits / 148–177 compile-cache misses — expected on first run). The workflow annotations surfaced three real, actionable signals:

    1. soldr cook reuse = 0 — annotation: "cook ran with prebuild-deps-flags='--release' … cargo check/clippy/doc/test compile in the dev (debug) profile → different cache key." On a cold run this is partly just an empty cache, but the profile-key mismatch is worth confirming against the warm run.
    2. build-cache payload 637–650 MB (>512 MB warn) — dominated by zccache/daemon-state/embedded-v1/.../artifacts/.staged-v2/** blobs (14–20 MB each). Candidate for payload trimming / excluding daemon-state from the saved layer.
    3. SOLDR_LINKER=fast default + a "pre-populated shared target dir → possible .rmeta error" known-limitation notice.

    I've kicked a warm rerun to measure the actual compile-cache hit-rate and wall-clock delta; posting those numbers next. That warm-cache hit-rate is the concrete metric for "how well setup-soldr caching works on this repo's heavy cache."

  5. zackees commented on Aug 7, 2026

    @zackees
    CollaboratorAuthor

    📊 Warm-cache result — setup-soldr caching measured

    Reran the same workflow with the cache populated (run 31196543127, attempt 2):

    cross-build cold (run 1) warm (run 2) speedup
    linux → windows-msvc 6m22s 1m32s ~4.1×
    linux → macos-arm64 6m21s 1m45s ~3.6×

    Compile-cache on the warm run (windows-msvc job log):

    soldr: cache 148 HIT, 0 MISS (100% hit rate)
    final zccache session stats: hits=148 misses=0 compilations=151 non_cacheable=0 errors=3 hit_rate=100.0%
    

    100% compile-cache hit rate, vs. 0/148 on the cold run. This is the concrete "how well does setup-soldr caching work" answer for this repo: with a warm cache the cross-build is fully served from cache and ~4× faster. It also explains the cold-run soldr cook "0 reuse" annotation — that was cold-cache noise; build-cache carries the work across runs and the second run hit everything.

    Verdict on the goal

    • Cross-compile off scarce platforms: proven. windows-msvc + macos-arm64 release binaries built on ubuntu via soldr build --target, no compiler tools installed, shipped to native runners that only download + run (6–8s, zero on-target compilation).
    • No upstream fix required. soldr/setup-soldr/soldr-toolchain/forge already provide the whole chain; nothing was missing to build.
    • Heavy caching validated: 100% warm hit-rate, ~4× wall-clock reduction.

    Small tuning follow-ups (non-blocking, tracked here)

  6. zackees commented on Aug 7, 2026

    @zackees
    CollaboratorAuthor

    Cross-repo follow-up (windows-gnu-from-Linux): the missing host-neutral mingw sysroot is now built + published in soldr-toolchain — zackees/soldr-toolchain#114 (recipe #115, catalogue asset via #116), forge-validated (run 31198742022), zero host executables. This is what a Linux-hosted x86_64-pc-windows-gnu link needs. The consumer side (soldr fetching it from a non-Windows host) is forge-ci/soldr#2336. Once that lands, reld's cross-release windows-gnu leg can drop its hand-installed mingw and move onto the blessed soldr build --target path like the msvc/darwin legs already did in #61.

  7. zackees commented on Aug 7, 2026

    @zackees
    CollaboratorAuthor

    win-gnu-from-Linux chain: producer done + published. The Linux-hosted mingw cross gcc toolchain is built + published (soldr-toolchain#114 Phase 2, PE-link-proven — links an x86-64 PE from Linux). soldr consumer building blocks are in soldr#2341; the final host-gate flip is soldr#2342. Once that lands, reld's cross-release win-gnu leg drops the apt gcc-mingw-w64 install and moves onto soldr build --target x86_64-pc-windows-gnu (like the msvc/darwin legs already did in #61).

  8. zackees commented on Sep 17, 2026

    @zackees
    CollaboratorAuthor

    The draft is validated

    cross-ship.yml carries a NOTE saying it is a draft that "must be validated against a live CI run before the cross legs in ci.yml (cross-release + the native reld-bench build steps) are migrated onto it." I dispatched that run against main as part of the #153 burn-down: run 35276124820, all six jobs green.

    Cross build (linux -> windows-gnu)    success
    Cross build (linux -> windows-msvc)   success
    Cross build (linux -> macos-arm64)    success
    Host run / windows-gnu                success
    Host run / windows-msvc               success
    Host run / macos-arm64                success
    

    Three targets cross-built on ubuntu through the blessed soldr front door with no toolchain installed on the runner, shipped as artifacts, and run on the native runners with no compilation there. That is this issue's mechanism, working, on main.

    So the precondition written into the workflow is met and the migration is unblocked. What remains is the migration itself, which is the part that can break green CI and therefore wants its own PR per leg rather than one sweep:

    1. ci.yml's cross-release job onto the cross-ship shape (it currently hand-wires mingw-w64 and deliberately avoids soldr cargo).
    2. The reld-bench release builds that currently run on the windows and macos runners — the cleanest candidate, since reld-bench needs only the binary and a frozen corpus.
    3. The phase1-native compile phase, which is Pilot: cross-compile the phase1 build from Linux to free Windows/macOS runners #130's pilot and the hardest of the three, because the payload is test binaries plus fixtures rather than one executable.

    I have not started any of those: each needs a live CI run to prove it, and doing them in one pass would make a failure ambiguous. Also worth deciding before step 3 — see my comment on #130 — whether that issue collapses into this one.

  9. zackees commented on Sep 18, 2026

    @zackees
    CollaboratorAuthor

    All three sub-issues are merged and validated live on main:

    The same cross builds also ran locally with the workflows' own commands: windows-gnu → PE, windows-msvc → PE, aarch64-darwin → Mach-O 64.

    Still open under this issue: moving the phase1-native compile phase off the native runners. That work is #130, and it's harder, because the payload is test binaries plus fixtures rather than a single executable. I'm leaving this issue open for it unless you'd rather close #130 into it.

  10. zackees commented on Sep 18, 2026

    @zackees
    CollaboratorAuthor

    Closing: all three migration legs are merged and verified on a live run (#167, #168, #169; follow-up #173). The one remaining piece, moving the phase1-native compile phase off the native runners, is tracked in #130 so it has one home.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions