Skip to content

ci: adopt setup-soldr caching + cache-gated Python linker setup + cross-compile release builds on parallel Linux runners #50

Closed

Description

@zackees

Context

.github/workflows/ci.yml currently runs with no build caching of any kind — no actions/cache, no Swatinem/rust-cache, no soldr. CARGO_COMMAND is bare (env.CARGO_COMMAND, ci.yml:18), so every job recompiles the workspace and its dependency graph from a cold target/ on every run.

On top of that, every phase1-native matrix leg re-fetches and re-installs its system linkers from scratch on every run, with no persistence between runs:

  • linux-gnu — adds the apt.llvm.org repo and installs clang-22/llvm-22-linker-tools, downloads the libtinfo5 .deb, and pulls the mold and wild release tarballs (ci.yml:124–153).
  • windows-gnu — msys2/setup-msys2 installs mingw-w64-ucrt-x86_64-clang, then downloads the pinned binutils .pkg.tar.zst (ci.yml:79–85, 187–189).
  • windows-msvc / linux / macOS — KyleMayes/install-llvm-action (LLVM 18.1.8) on non-macOS legs (ci.yml:92–95); brew install llvm@18 on macOS (ci.yml:216–221).

These downloads (LLVM, mold, wild, binutils, brew formulae) are the "heavy price" paid on every single CI run. All versions are already pinned via env: (ci.yml:19–29) and checksum-verified, which makes them ideal cache keys.

Separately, the four build targets each compile natively on their own OS runner (ubuntu-24.04, windows-2022 ×2, macos-14). Windows and macOS GitHub-hosted runners bill at a higher minute multiplier than Linux, and there are fewer of them, so they dominate wall-clock and cost.

There is a first-party action for the caching half of this: zackees/setup-soldr (@v0, default soldr 0.8.43) installs one soldr binary, provisions the resolved Rust toolchain, and restores content-addressed Soldr/zccache build state — advertised as ~2× faster cross-PR builds vs. per-key caches. Usage is soldr cargo build .... reld already namechecks soldr in the README ("soldr makes the compile fast; reld is the other half of the loop").

Proposal

Three related CI improvements:

  1. Adopt setup-soldr for compiler/build caching. Add zackees/setup-soldr@v0 with cache: true to hygiene, phase1-native, and python (if it builds), and route cargo through soldr. The cleanest lever is setting env.CARGO_COMMAND to soldr cargo (the workflow already invokes $CARGO_COMMAND everywhere, so most steps need no change) — but confirm quoting/interpolation works in bash, pwsh, and msys2 {0} shells; a per-step wrapper may be needed where & $env:CARGO_COMMAND is used (ci.yml:332+). Use setup-soldr/cleanup@v0 between build and cache-lifecycle-sensitive test phases if self-build cache daemon interference appears.

  2. Cache the system linkers behind cache-gated Python setup scripts. Replace the inline shell linker-provisioning blocks with Python setup scripts (consistent with the existing ci/*.py tooling such as phase1_summary.py and ci/tests). Each script:

    • Checks whether the required linker/toolchain is already present in the GHA cache (restored earlier in the job); if present, it does nothing (no download, no apt/brew/msys2/tarball fetch).
    • Only on a cache miss does it perform the heavy install/download and checksum-verify, then lay the artifacts down in a stable, cacheable location.
    • After the script runs, the populated location is saved back to the GHA cache (via actions/cache restore-before / save-after, or cache/restore + cache/save) so subsequent runs skip the work entirely.
      Cache keys are derived from the already-pinned env: versions (CLANG_PACKAGE_VERSION, LLD_VERSION, MOLD_VERSION, WILD_VERSION, MSYS2_BINUTILS_VERSION, LIBTINFO5_VERSION, APPLE_LD_VERSION), so a version bump invalidates exactly the affected linker's cache. The existing "Verify and smoke" steps remain the correctness gate on both cache-hit and cache-miss paths.
  3. Cross-compile release builds on parallel Linux runners. Add a release cross-compilation path that builds the Windows/macOS targets from ubuntu-24.04 (e.g. --release --target x86_64-pc-windows-msvc / aarch64-apple-darwin via cross toolchains), exploiting cheaper, more-plentiful Linux runners for the compile+link phases and producing release artifacts. See Decisions for the important scoping constraint about native test execution.

Acceptance criteria

  • ci.yml uses zackees/setup-soldr@v0 with caching enabled on the build jobs, and cargo invocations route through soldr.
  • Linker provisioning is driven by Python setup scripts (under ci/) that are no-ops on a cache hit and only download/install on a miss; the populated linker location is saved to the GHA cache for reuse.
  • A cold run populates caches; a subsequent warm run on the same pinned versions shows a measurable reduction in (a) dependency/workspace compile time and (b) linker-provisioning time (the LLVM/mold/wild/binutils/brew steps hit cache instead of re-downloading). Capture before/after timings from two consecutive Actions runs in the PR.
  • Linker version-drift guards (the grep -q "${VERSION}" checks in the smoke steps) still pass on a cache hit — a stale cache must fail loudly, never silently serve a wrong linker.
  • A Linux-hosted release cross-compile produces linked Windows and macOS target binaries (artifacts uploaded), running green.
  • No reduction in test coverage: all native/self-host/e2e steps that must run on-target still run on their native runners (see Decisions).
  • RED -> GREEN evidence: land a minimal workflow change first that demonstrates the cache miss -> hit transition (e.g. a run showing "cache not found" / script performing the install, followed by a run showing "cache restored" / script skipping the install), then the timing-improvement change on top.

Decisions

  • Priority: P2. Pure CI cost/speed optimization; no user-facing behavior change and nothing is broken today. Upgrade to P1 if CI minutes/queue time become a shipping bottleneck.
  • Linker setup is Python, cache-gated. Per the requesting note, the linker provisioning is reimplemented as Python scripts that only execute the heavy download/install path on a cache miss and are otherwise no-ops, with the result cached in GHA. This matches the repo's existing ci/*.py convention and keeps the miss/hit logic testable outside the YAML.
  • Native tests stay on native runners. reld's CI is dominated by executing linked binaries on-target: Linux acceptance/difftest/mold-corpus, the windows-msvc self-host + sqlite-bridge e2e + reld-bench, and the macOS self-host + e2e + bench. Cross-compilation from Linux can move the compile+link phases (and release-artifact production) to cheap parallel Linux runners, but on-target test execution cannot move to Linux without emulation. Scope item docs: phased implementation plan for GPT-5.6 handoff #3 to the build/link/artifact phases and keep the native test matrix where it is. This is the honest reading of the request — "take advantage of parallel Linux runners to build the software" is achievable; relocating the whole test suite is not.
  • Release mode noted despite the non-goal. The README lists "Release / shipping builds" as an explicit non-goal for reld's own linker output, but the request here is about CI build configuration (--release of reld itself for cross-compiled artifacts / faster optimized self-host), which is unrelated to that non-goal. Proceeding on that reading.
  • Cache keys reuse existing pins. Every linker version is already an env: constant with a checksum, so cache keys are derived from those constants — no new source of version truth is introduced.
  • CARGO_COMMAND as the soldr seam. Reusing the existing $CARGO_COMMAND indirection minimizes diff surface; fall back to per-step wrappers only where shell interpolation of a two-word command breaks (notably the pwsh & $env:CARGO_COMMAND call sites).

Open questions

  • Does setup-soldr@v0 (soldr 0.8.43) support the msys2 {0} shell and the Windows GNU/MSVC toolchains used here, or is its caching Linux/native-cargo focused? Verify on a spike before wiring all four legs.
  • For the macOS cross-compile from Linux, is an Apple SDK/sysroot lawfully and practically available in CI (osxcross-style), or should the macOS leg keep native compilation and only Windows cross-compile from Linux? Determine during implementation.
  • Does soldr cargo compose with the CARGO_TARGET_*_LINKER=reld overrides used in the self-host/e2e steps, or should those steps bypass soldr? Confirm no interference with the linker-override env vars.
  • Per-OS cache scoping: GHA caches are branch/OS-scoped — confirm the Python-script cache keys include the runner OS/arch so a macOS linker cache never restores onto a Linux leg.
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