Skip to content

Commit 9a71786

Browse files
committed
Add caching for downloading compiler-rt
1 parent f739769 commit 9a71786

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

.github/workflows/main.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on: [push, pull_request]
44
env:
55
RUSTDOCFLAGS: -Dwarnings
66
RUSTFLAGS: -Dwarnings
7+
RUST_LLVM_VERSION: 18.0-2024-02-13
8+
RUST_COMPILER_RT_ROOT: ./compiler-rt
79

810
jobs:
911
test:
@@ -115,12 +117,18 @@ jobs:
115117
path: /tmp/.buildx-cache
116118
key: ${{ matrix.target }}-buildx-${{ github.sha }}
117119
restore-keys: ${{ matrix.target }}-buildx-
118-
120+
121+
- name: Cache compiler-rt
122+
id: cache-compiler-rt
123+
uses: actions/cache@v4
124+
with:
125+
path: compiler-rt
126+
key: ${{ runner.os }}-compiler-rt-${{ env.RUST_LLVM_VERSION }}
119127
- name: Download compiler-rt reference sources
128+
if: steps.cache-compiler-rt.outputs.cache-hit != 'true'
120129
run: |
121-
curl -L -o code.tar.gz https://github.com/rust-lang/llvm-project/archive/rustc/18.0-2024-02-13.tar.gz
122-
tar xzf code.tar.gz --strip-components 1 llvm-project-rustc-18.0-2024-02-13/compiler-rt
123-
echo RUST_COMPILER_RT_ROOT=./compiler-rt >> $GITHUB_ENV
130+
curl -L -o code.tar.gz "https://github.com/rust-lang/llvm-project/archive/rustc/${RUST_LLVM_VERSION}.tar.gz"
131+
tar xzf code.tar.gz --strip-components 1 llvm-project-rustc-${RUST_LLVM_VERSION}/compiler-rt
124132
shell: bash
125133

126134
# Non-linux tests just use our raw script

ci/download-rt.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Download LLVM's compiler-rt only if it does not exist or is out of date
4+
5+
set -eauxo pipefail
6+
7+
url="https://github.com/rust-lang/llvm-project/archive/rustc/18.0-2024-02-13.tar.gz"
8+
rt_path="llvm-project-rustc-18.0-2024-02-13/compiler-rt"
9+
expected_sha=""
10+
11+
download () {
12+
curl -L -o code.tar.gz "$url"
13+
tar xzf code.tar.gz --strip-components 1 "$rt_path"
14+
}
15+
16+
existing_hash=$(
17+
find compiler-rt -type f -print0 |
18+
sort -z |
19+
xargs -0 shasum -a 256 |
20+
shasum -U -a 256 |
21+
cut -d' '' -f1 |
22+
tr -d '\n'
23+
)
24+
25+
if [ "$existing_hash" = "$expected_sha" ]; then
26+
echo "Got expected sha '$expected_sha'; nothing to do"
27+
exit
28+
fi
29+
30+
echo "Got $existing_hash; expected $expected_sha. Downloading"
31+
32+
download()

0 commit comments

Comments
 (0)