Skip to content

Set up sccache as a shared Rust compiler cache during bun install #3087

Closed

Description

@malibio

Problem

Every worktree builds Rust from cold into its own target/ (2.5–23 GB each), and there is no compiler cache shared between them. A new worktree pays a full cold build — minutes of the pre-push gate — on its first push. The same happens on each dev machine.

Solution

Set up sccache as the machine-wide Rust compiler cache as part of bun install (root prepare lifecycle), so every dev machine gets it without a manual step:

  • scripts/setup-build-cache.ts, run from the root prepare script
  • Install a pinned sccache release into ~/.cargo/bin (SHA-256 pinned in the script) when it is missing
  • Configure ~/.cargo/config.toml (build.rustc-wrapper = "sccache", CMake compiler launchers for llama.cpp) — merge only when safe, otherwise print the lines to add
  • Set a 40 GiB local disk cache
  • Near-zero-cost no-op when already configured; never fails bun install (offline, unsupported platform, no cargo); opt-out via NODESPACE_SKIP_BUILD_CACHE=1

Local cache per machine, not a shared remote cache: cross-machine hits need identical rustc and absolute paths, and the per-machine win (many worktrees sharing one cache) captures most of the benefit.

Acceptance criteria

  • bun install on a machine without sccache installs and configures it
  • bun install on a configured machine is a fast no-op (no network)
  • An existing ~/.cargo/config.toml is never clobbered
  • Failure to set up never fails bun install
  • Unit tests (DOM-free, under scripts/) for the config-merge decisions

Activity

  1. malibio commented on Sep 26, 2026

    @malibio
    CollaboratorAuthor

    Frontend: 5406 passed; scripts: 587 passed

  2. self-assigned this
    on Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions