Skip to content

Commit 5a084bf

Browse files
committed
Auto merge of #136942 - Kobzol:stage0-sccache, r=<try>
Use ccache for stage0 tool builds r? `@ghost`
2 parents 54cdc75 + d3d174f commit 5a084bf

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
7171
DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7272
SCCACHE_BUCKET: rust-lang-ci-sccache2
73+
SCCACHE_REGION: us-west-1
7374
CACHE_DOMAIN: ci-caches.rust-lang.org
7475
continue-on-error: ${{ matrix.continue_on_error || false }}
7576
strategy:

src/bootstrap/src/core/build_steps/tool.rs

+14
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,20 @@ pub fn prepare_tool_cargo(
164164
}
165165
}
166166

167+
// The stage0 compiler changes infrequently and does not directly depend on code
168+
// in the current working directory. Therefore, caching it with sccache should be
169+
// useful.
170+
// This is only performed for non-incremental builds, as ccache cannot deal with these.
171+
if let Some(ref ccache) = builder.config.ccache {
172+
eprintln!(
173+
"TOOL SCCACHE CONFIGURED at {}, mode: {:?}, incremental: {}",
174+
ccache, mode, builder.config.incremental
175+
);
176+
if matches!(mode, Mode::ToolBootstrap) && !builder.config.incremental {
177+
cargo.env("RUSTC_WRAPPER", ccache);
178+
}
179+
}
180+
167181
// clippy tests need to know about the stage sysroot. Set them consistently while building to
168182
// avoid rebuilding when running tests.
169183
cargo.env("SYSROOT", builder.sysroot(compiler));

src/ci/docker/run.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,15 @@ args=
236236
if [ "$SCCACHE_BUCKET" != "" ]; then
237237
args="$args --env SCCACHE_BUCKET"
238238
args="$args --env SCCACHE_REGION"
239-
args="$args --env AWS_ACCESS_KEY_ID"
240-
args="$args --env AWS_SECRET_ACCESS_KEY"
241239
args="$args --env AWS_REGION"
240+
241+
# Disable S3 authentication for PR builds, because the access keys are missing
242+
if [ "$PR_CI_JOB" != "" ]; then
243+
args="$args --env SCCACHE_S3_NO_CREDENTIALS=1"
244+
else
245+
args="$args --env AWS_ACCESS_KEY_ID"
246+
args="$args --env AWS_SECRET_ACCESS_KEY"
247+
fi
242248
else
243249
mkdir -p $HOME/.cache/sccache
244250
args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"

src/ci/docker/scripts/sccache.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ set -ex
66

77
case "$(uname -m)" in
88
x86_64)
9-
url="https://ci-mirrors.rust-lang.org/rustc/2021-08-24-sccache-v0.2.15-x86_64-unknown-linux-musl"
9+
url="https://ci-mirrors.rust-lang.org/rustc/2025-01-07-sccache-v0.9.1-x86_64-unknown-linux-musl"
1010
;;
1111
aarch64)
12-
url="https://ci-mirrors.rust-lang.org/rustc/2021-08-25-sccache-v0.2.15-aarch64-unknown-linux-musl"
12+
url="https://ci-mirrors.rust-lang.org/rustc/2025-01-07-sccache-v0.9.1-aarch64-unknown-linux-musl"
1313
;;
1414
*)
1515
echo "unsupported architecture: $(uname -m)"

src/ci/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,5 +279,5 @@ if [ "$RUN_CHECK_WITH_PARALLEL_QUERIES" != "" ]; then
279279
fi
280280

281281
echo "::group::sccache stats"
282-
sccache --show-stats || true
282+
sccache --show-adv-stats || true
283283
echo "::endgroup::"

0 commit comments

Comments
 (0)