From 0e260c99276120eb282533761db8a4d62e67905d Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Wed, 29 Apr 2026 12:49:07 -0300 Subject: [PATCH] fix(ci): sccache wrapper + incremental=false for correct caching - Add sccache wrapper that unsets CARGO_INCREMENTAL (sccache 0.14.0 refuses to work when that env var is present, even if =0) - Remove rustc-wrapper from .cargo/config.toml (use RUSTC_WRAPPER env in CI) - Set [profile.dev] incremental = false to avoid sccache 'prohibited' error - DEV-DEPENDENCIES.sh now installs sccache 0.14.0 + wrapper correctly - CI workflow: unset CARGO_INCREMENTAL env (let sccache wrapper handle it) Tested on alm-ci: 50% cache hit rate on rebuild after target/ removal. --- .cargo/config.toml | 1 - .forgejo/workflows/botserver.yaml | 1 - Cargo.toml | 2 +- DEV-DEPENDENCIES.sh | 28 ++++++++++++++++------------ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 8493605a..a625243b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,4 @@ [build] -rustc-wrapper = "sccache" jobs = 6 [target.x86_64-unknown-linux-gnu] diff --git a/.forgejo/workflows/botserver.yaml b/.forgejo/workflows/botserver.yaml index 4fafc3b0..1c944c39 100644 --- a/.forgejo/workflows/botserver.yaml +++ b/.forgejo/workflows/botserver.yaml @@ -16,7 +16,6 @@ jobs: runs-on: gbo env: RUSTC_WRAPPER: sccache - CARGO_INCREMENTAL: "1" PATH: "/home/gbuser/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/sbin:/bin" steps: - name: Setup diff --git a/Cargo.toml b/Cargo.toml index 275da137..fa46b0c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -249,7 +249,7 @@ opt-level = "s" [profile.dev] debug = 1 -incremental = true +incremental = false codegen-units = 32 opt-level = 0 diff --git a/DEV-DEPENDENCIES.sh b/DEV-DEPENDENCIES.sh index 255c0cfc..5cc5249e 100755 --- a/DEV-DEPENDENCIES.sh +++ b/DEV-DEPENDENCIES.sh @@ -33,16 +33,23 @@ install_sccache() { fi if [ "$CURRENT_VER" = "$WANT_VER" ]; then echo "sccache $WANT_VER already installed" - return + else + echo "Upgrading sccache from ${CURRENT_VER:-none} to $WANT_VER..." + rm -f /usr/local/bin/sccache /usr/local/bin/sccache-dist + ARCH=$(uname -m) + curl -L "https://github.com/mozilla/sccache/releases/download/v${WANT_VER}/sccache-v${WANT_VER}-${ARCH}-unknown-linux-musl.tar.gz" -o /tmp/sccache.tar.gz + tar -xzf /tmp/sccache.tar.gz -C /tmp + cp "/tmp/sccache-v${WANT_VER}-${ARCH}-unknown-linux-musl/sccache" /usr/local/bin/sccache.real + chmod +x /usr/local/bin/sccache.real + rm -rf /tmp/sccache* fi - echo "Upgrading sccache from ${CURRENT_VER:-none} to $WANT_VER..." - rm -f /usr/local/bin/sccache /usr/local/bin/sccache-dist - ARCH=$(uname -m) - curl -L "https://github.com/mozilla/sccache/releases/download/v${WANT_VER}/sccache-v${WANT_VER}-${ARCH}-unknown-linux-musl.tar.gz" -o /tmp/sccache.tar.gz - tar -xzf /tmp/sccache.tar.gz -C /tmp - cp "/tmp/sccache-v${WANT_VER}-${ARCH}-unknown-linux-musl/sccache" /usr/local/bin/sccache + # Install wrapper that unsets CARGO_INCREMENTAL before calling sccache.real + cat > /usr/local/bin/sccache << 'EOF' +#!/bin/bash +unset CARGO_INCREMENTAL +exec /usr/local/bin/sccache.real "$@" +EOF chmod +x /usr/local/bin/sccache - rm -rf /tmp/sccache* sccache --version } @@ -77,11 +84,8 @@ jobs = -1 [target.x86_64-unknown-linux-gnu] linker = "clang" rustflags = ["-C", "link-arg=-fuse-ld=mold"] - -[env] -RUSTC_WRAPPER = "sccache" CARGOCONF - echo "Created .cargo/config.toml with mold + sccache" + echo "Created .cargo/config.toml with mold" else echo ".cargo/config.toml already exists, skipping" fi