From 13d1d013e9899e2bbfda67ba8953c964addc1862 Mon Sep 17 00:00:00 2001 From: funman300 Date: Fri, 1 May 2026 05:15:59 +0000 Subject: [PATCH] chore: route rustc through sccache for cold-build wins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds .cargo/config.toml setting `rustc-wrapper = "sccache"` so cold rebuilds (CI, fresh checkouts, post-`cargo clean`) replay previously- compiled crates from disk instead of recompiling. Warm incremental builds are unaffected — cargo's own target/ cache dominates there. Cache lives at `.sccache-cache/` inside the project (gitignored). The [env] entry uses `force = false` so a developer-set $SCCACHE_DIR in their shell wins, matching whichever directory the sccache daemon already adopted. Requires sccache on PATH. Install: `pacman -S sccache`, `brew install sccache`, or `cargo install sccache --locked`. Bypass without editing: `RUSTC_WRAPPER= cargo build`. --- .cargo/config.toml | 31 +++++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 32 insertions(+) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..e6fa3c0 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,31 @@ +# Project-wide cargo configuration. +# +# Routes every rustc invocation through `sccache` so cold rebuilds and +# fresh checkouts (CI, new dev box, after a `cargo clean`) replay +# previously-compiled crates from a local on-disk cache rather than +# recompiling them. Warm incremental builds still go through cargo's +# own `target/` cache, which dominates locally — sccache buys you the +# big wins on cold paths. +# +# Requires sccache on PATH. Install it once per machine: +# +# Arch : pacman -S sccache +# macOS : brew install sccache +# Cargo : cargo install sccache --locked +# +# Without sccache the build fails with "rustc-wrapper not found". To +# bypass this config without editing the file, prepend +# `RUSTC_WRAPPER= ` (empty value) to your cargo command: +# +# RUSTC_WRAPPER= cargo build +# +[build] +rustc-wrapper = "sccache" + +# Project-local cache so the shared dev box (or a Docker volume) keeps +# the artefacts isolated per checkout instead of mixing them in +# `~/.cache/sccache`. Set with `force = false` so a developer-set +# `SCCACHE_DIR` in their shell wins — important because the sccache +# daemon, once started, sticks with whichever directory it saw first. +[env] +SCCACHE_DIR = { value = ".sccache-cache", relative = true, force = false } diff --git a/.gitignore b/.gitignore index bba1d91..977ce87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target +/.sccache-cache *.db *.db-shm *.db-wal