Skills2026年5月5日·1 分钟阅读

sccache — Shared Compilation Cache for C/C++ and Rust

A compiler caching tool by Mozilla that stores compilation results in local disk, S3, GCS, Azure, or Redis to avoid redundant rebuilds across developers and CI runs.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
sccache Overview
通用 CLI 安装命令
npx tokrepo install 0b13a73f-4839-11f1-9bc6-00163e2b0d79

Introduction

sccache is a compiler caching daemon that intercepts compilation commands and returns cached results when inputs have not changed. It extends ccache concepts to support Rust, cloud storage backends, and distributed team sharing.

What sccache Does

  • Caches C, C++, Rust, and CUDA compilation outputs based on input hashing
  • Supports local disk, Amazon S3, Google Cloud Storage, Azure Blob, Redis, and Memcached as cache backends
  • Acts as a drop-in RUSTC_WRAPPER for Rust projects or CC/CXX wrapper for C/C++
  • Runs as a local daemon that multiple build processes connect to
  • Provides cache hit statistics and storage usage reporting via sccache --show-stats

Architecture Overview

sccache runs a local server process that listens for compilation requests. When a compiler invocation arrives, it hashes the preprocessed source, compiler flags, and compiler version to produce a cache key. If the key exists in the configured backend, the cached artifact is returned immediately. Otherwise, the compilation runs normally and the output is stored. The daemon handles concurrent requests and manages backend connections.

Self-Hosting & Configuration

  • Install via cargo install sccache, Homebrew, or download prebuilt binaries
  • Configure the storage backend in ~/.config/sccache/config or via environment variables
  • Set SCCACHE_BUCKET and AWS_ACCESS_KEY_ID for S3 backend
  • For Rust, set RUSTC_WRAPPER=sccache in your shell profile or .cargo/config.toml
  • For C/C++, set CMAKE_C_COMPILER_LAUNCHER=sccache in CMake projects

Key Features

  • Cloud-backed caching means CI runs benefit from caches built by other developers or jobs
  • Supports preprocessing-based and content-based hashing modes for accuracy
  • Handles multiple compiler toolchains (GCC, Clang, MSVC, rustc, nvcc) simultaneously
  • Read-only mode allows CI workers to pull from cache without write permissions
  • Integrates with GitHub Actions, GitLab CI, and other CI systems via environment variables

Comparison with Similar Tools

  • ccache — local-only by default; sccache natively supports cloud storage backends
  • Bazel remote cache — build-system-specific; sccache works with any compiler
  • Turbo Cache — JavaScript/monorepo focused; sccache targets native compilation
  • buildcache — similar concept; sccache has broader backend support and Rust integration
  • cachepot — sccache fork with extra features; sccache has larger community and Mozilla backing

FAQ

Q: How much build time does sccache save? A: On cache hits, compilation is essentially instant (milliseconds). Typical projects see 50-90% of compilations cached after the first build.

Q: Does it work with incremental compilation in Rust? A: sccache disables Rust incremental compilation because cached full builds are faster than partial incremental ones.

Q: Can multiple developers share the same cache? A: Yes. Point all team members at the same S3 bucket or Redis instance for shared caching.

Q: Does it support distributed compilation like distcc? A: sccache has experimental distributed compilation support but is primarily a caching tool, not a build farm.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产