@@ -322,7 +322,7 @@ Our CI workflow uses various caching mechanisms, mainly for two things:
322
322
### Docker images caching
323
323
324
324
The Docker images we use to run most of the Linux-based builders take a * long*
325
- time to fully build. To speed up the build, we cache it using [ Docker registry
325
+ time to fully build. To speed up the build, we cache them using [ Docker registry
326
326
caching] , with the intermediate artifacts being stored on [ ghcr.io] . We also
327
327
push the built Docker images to ghcr, so that they can be reused by other tools
328
328
(rustup) or by developers running the Docker build locally (to speed up their
@@ -334,16 +334,32 @@ override the cache for the others. Instead, we store the images under different
334
334
tags, identifying them with a custom hash made from the contents of all the
335
335
Dockerfiles and related scripts.
336
336
337
+ The CI calculates a hash key, so that the cache of a Docker image is
338
+ invalidated if one of the following changes:
339
+
340
+ - Dockerfile
341
+ - Files copied into the Docker image in the Dockerfile
342
+ - The architecture of the GitHub runner (x86 or ARM)
343
+
337
344
[ ghcr.io ] : https://github.com/rust-lang-ci/rust/pkgs/container/rust-ci
338
345
[ Docker registry caching ] : https://docs.docker.com/build/cache/backends/registry/
339
346
340
347
### LLVM caching with sccache
341
348
342
349
We build some C/C++ stuff in various CI jobs, and we rely on [ sccache] to cache
343
350
the intermediate LLVM artifacts. Sccache is a distributed ccache developed by
344
- Mozilla, which can use an object storage bucket as the storage backend. In our
345
- case, the artefacts are uploaded to an S3 bucket that we control
346
- (` rust-lang-ci-sccache2 ` ).
351
+ Mozilla, which can use an object storage bucket as the storage backend.
352
+
353
+ With sccache there's no need to calculate the hash key ourselves. Sccache
354
+ invalidates the cache automatically when it detects changes to relevant inputs,
355
+ such as the source code, the version of the compiler, and important environment
356
+ variables.
357
+ So we just pass the sccache wrapper on top of cargo and sccache does the rest.
358
+
359
+ We store the persistent artifacts on the S3 bucket ` rust-lang-ci-sccache2 ` . So
360
+ when the CI runs, if sccache sees that LLVM is being compiled with the same C/C++
361
+ compiler and the LLVM source code is the same, sccache retrieves the individual
362
+ compiled translation units from S3.
347
363
348
364
[ sccache ] : https://github.com/mozilla/sccache
349
365
0 commit comments