ci: stop the LLVM caches from being evicted

The Actions cache of the repository was at 10.24 GB against a quota of
10 GB, so GitHub removed entries by least recent use. The LLVM entries
were among the first to go, and CI then built LLVM again although the
LLVM version did not change.

The Docker buildx layer blobs held 6.0 GB of the quota. All LLVM caches
together held 1.97 GB. Move the Docker layer cache to a registry cache in
GHCR, which does not use the Actions quota. Both jobs have the necessary
permission and login already.

Pin the LLVM commit in llvm-version.txt and fetch that commit, in place
of a clone of the branch tip tinygo_22.x. Add a hash of that file to each
LLVM cache key, so a change of the LLVM version invalidates the caches
and no other change does.

Also rename the LLVM image tags from llvm-20 to llvm-22.
This commit is contained in:
deadprogram
2026-08-29 10:58:49 +02:00
committed by Ron Evans
parent b420a8be17
commit 421d98b248
13 changed files with 34 additions and 21 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
build/ build/
llvm-*/ llvm-*/
!llvm-version.txt
.github .github
+2 -2
View File
@@ -46,7 +46,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-source id: cache-llvm-source
with: with:
key: llvm-source-22-${{ matrix.os }}-v1 key: llvm-source-22-${{ matrix.os }}-v1-${{ hashFiles('llvm-version.txt') }}
path: | path: |
llvm-project/clang/lib/Headers llvm-project/clang/lib/Headers
llvm-project/clang/include llvm-project/clang/include
@@ -71,7 +71,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-build id: cache-llvm-build
with: with:
key: llvm-build-22-${{ matrix.os }}-v1 key: llvm-build-22-${{ matrix.os }}-v1-${{ hashFiles('llvm-version.txt') }}
path: llvm-build path: llvm-build
- name: Build LLVM - name: Build LLVM
if: steps.cache-llvm-build.outputs.cache-hit != 'true' if: steps.cache-llvm-build.outputs.cache-hit != 'true'
+1 -1
View File
@@ -46,7 +46,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-source id: cache-llvm-source
with: with:
key: llvm-source-22-linux-compat key: llvm-source-22-linux-compat-${{ hashFiles('llvm-version.txt') }}
path: llvm-project/compiler-rt path: llvm-project/compiler-rt
- name: Download LLVM source - name: Download LLVM source
if: steps.cache-llvm-source.outputs.cache-hit != 'true' if: steps.cache-llvm-source.outputs.cache-hit != 'true'
+2 -2
View File
@@ -64,5 +64,5 @@ jobs:
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/tinygo-dev:buildcache
cache-to: type=gha,mode=max cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/tinygo-dev:buildcache,mode=max
+6 -6
View File
@@ -66,7 +66,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-source id: cache-llvm-source
with: with:
key: llvm-source-22-linux-alpine-v1 key: llvm-source-22-linux-alpine-v1-${{ hashFiles('llvm-version.txt') }}
path: | path: |
llvm-project/clang/lib/Headers llvm-project/clang/lib/Headers
llvm-project/clang/include llvm-project/clang/include
@@ -91,7 +91,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-build id: cache-llvm-build
with: with:
key: llvm-build-22-linux-alpine-v1 key: llvm-build-22-linux-alpine-v1-${{ hashFiles('llvm-version.txt') }}
path: llvm-build path: llvm-build
- name: Build LLVM - name: Build LLVM
if: steps.cache-llvm-build.outputs.cache-hit != 'true' if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -268,7 +268,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-source id: cache-llvm-source
with: with:
key: llvm-source-22-linux-asserts-v1 key: llvm-source-22-linux-asserts-v1-${{ hashFiles('llvm-version.txt') }}
path: | path: |
llvm-project/clang/lib/Headers llvm-project/clang/lib/Headers
llvm-project/clang/include llvm-project/clang/include
@@ -293,7 +293,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-build id: cache-llvm-build
with: with:
key: llvm-build-22-linux-asserts-v1 key: llvm-build-22-linux-asserts-v1-${{ hashFiles('llvm-version.txt') }}
path: llvm-build path: llvm-build
- name: Build LLVM - name: Build LLVM
if: steps.cache-llvm-build.outputs.cache-hit != 'true' if: steps.cache-llvm-build.outputs.cache-hit != 'true'
@@ -377,7 +377,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-source id: cache-llvm-source
with: with:
key: llvm-source-22-linux-v1 key: llvm-source-22-linux-v1-${{ hashFiles('llvm-version.txt') }}
path: | path: |
llvm-project/clang/lib/Headers llvm-project/clang/lib/Headers
llvm-project/clang/include llvm-project/clang/include
@@ -402,7 +402,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-build id: cache-llvm-build
with: with:
key: llvm-build-22-linux-${{ matrix.goarch }}-v1 key: llvm-build-22-linux-${{ matrix.goarch }}-v1-${{ hashFiles('llvm-version.txt') }}
path: llvm-build path: llvm-build
- name: Build LLVM - name: Build LLVM
if: steps.cache-llvm-build.outputs.cache-hit != 'true' if: steps.cache-llvm-build.outputs.cache-hit != 'true'
+4 -4
View File
@@ -35,8 +35,8 @@ jobs:
uses: docker/metadata-action@v6 uses: docker/metadata-action@v6
with: with:
images: | images: |
tinygo/llvm-20 tinygo/llvm-22
ghcr.io/${{ github.repository_owner }}/llvm-20 ghcr.io/${{ github.repository_owner }}/llvm-22
tags: | tags: |
type=sha,format=long type=sha,format=long
type=raw,value=latest type=raw,value=latest
@@ -59,5 +59,5 @@ jobs:
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/llvm-22:buildcache
cache-to: type=gha,mode=max cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/llvm-22:buildcache,mode=max
+1 -1
View File
@@ -29,7 +29,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-source id: cache-llvm-source
with: with:
key: llvm-source-22-linux-nix-v1 key: llvm-source-22-linux-nix-v1-${{ hashFiles('llvm-version.txt') }}
path: | path: |
llvm-project/compiler-rt llvm-project/compiler-rt
- name: Download LLVM source - name: Download LLVM source
+1 -1
View File
@@ -34,7 +34,7 @@ jobs:
uses: actions/cache@v5 uses: actions/cache@v5
id: cache-llvm-source id: cache-llvm-source
with: with:
key: llvm-source-22-sizediff-v1 key: llvm-source-22-sizediff-v1-${{ hashFiles('llvm-version.txt') }}
path: | path: |
llvm-project/compiler-rt llvm-project/compiler-rt
- name: Download LLVM source - name: Download LLVM source
+2 -2
View File
@@ -40,7 +40,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-source id: cache-llvm-source
with: with:
key: llvm-source-22-windows-v3 key: llvm-source-22-windows-v3-${{ hashFiles('llvm-version.txt') }}
path: | path: |
llvm-project/clang/lib/Headers llvm-project/clang/lib/Headers
llvm-project/clang/include llvm-project/clang/include
@@ -65,7 +65,7 @@ jobs:
uses: actions/cache/restore@v5 uses: actions/cache/restore@v5
id: cache-llvm-build id: cache-llvm-build
with: with:
key: llvm-build-22-windows-v1 key: llvm-build-22-windows-v1-${{ hashFiles('llvm-version.txt') }}
path: llvm-build path: llvm-build
- name: Build LLVM - name: Build LLVM
if: steps.cache-llvm-build.outputs.cache-hit != 'true' if: steps.cache-llvm-build.outputs.cache-hit != 'true'
+4
View File
@@ -53,6 +53,10 @@ the git repository). Then, inside the directory, download the LLVM source:
make llvm-source make llvm-source
The LLVM commit to use is pinned in `llvm-version.txt`. A change to that file
makes CI build LLVM again, because the file is part of the LLVM cache key. All
other changes reuse the cached LLVM build.
You can also store LLVM outside of the TinyGo root directory by setting the You can also store LLVM outside of the TinyGo root directory by setting the
`LLVM_BUILDDIR`, `CLANG_SRC` and `LLD_SRC` make variables, but that is not `LLVM_BUILDDIR`, `CLANG_SRC` and `LLD_SRC` make variables, but that is not
covered by this guide. covered by this guide.
+1
View File
@@ -11,6 +11,7 @@ RUN apt-get update && \
COPY ./GNUmakefile /tinygo/GNUmakefile COPY ./GNUmakefile /tinygo/GNUmakefile
COPY ./make /tinygo/make COPY ./make /tinygo/make
COPY ./llvm-version.txt /tinygo/llvm-version.txt
RUN cd /tinygo/ && \ RUN cd /tinygo/ && \
make llvm-source make llvm-source
+1
View File
@@ -0,0 +1 @@
2be7242b6a4d59fe89fb43f7d1e7333dc9b307a2
+8 -1
View File
@@ -75,8 +75,15 @@ endif
CGO_LDFLAGS+=-L$(abspath $(LLVM_BUILDDIR)/lib) -lclang $(CLANG_LIBS) $(LLD_LIBS) $(shell $(LLVM_CONFIG_PREFIX) $(LLVM_BUILDDIR)/bin/llvm-config --ldflags --libs --system-libs $(LLVM_COMPONENTS)) -lstdc++ $(CGO_LDFLAGS_EXTRA) CGO_LDFLAGS+=-L$(abspath $(LLVM_BUILDDIR)/lib) -lclang $(CLANG_LIBS) $(LLD_LIBS) $(shell $(LLVM_CONFIG_PREFIX) $(LLVM_BUILDDIR)/bin/llvm-config --ldflags --libs --system-libs $(LLVM_COMPONENTS)) -lstdc++ $(CGO_LDFLAGS_EXTRA)
endif endif
# Pinned in llvm-version.txt. Branch tinygo_22.x of tinygo-org/llvm-project.
LLVM_REVISION = $(shell cat llvm-version.txt)
$(LLVM_PROJECTDIR)/llvm: $(LLVM_PROJECTDIR)/llvm:
git clone -b tinygo_22.x --depth=1 https://github.com/tinygo-org/llvm-project $(LLVM_PROJECTDIR) git init $(LLVM_PROJECTDIR)
cd $(LLVM_PROJECTDIR) && \
git remote add origin https://github.com/tinygo-org/llvm-project && \
git fetch --depth=1 origin $(LLVM_REVISION) && \
git checkout FETCH_HEAD
llvm-source: $(LLVM_PROJECTDIR)/llvm ## Get LLVM sources llvm-source: $(LLVM_PROJECTDIR)/llvm ## Get LLVM sources
# Configure LLVM. # Configure LLVM.