Skip to content

Commit

Permalink
Add caching for downloading compiler-rt
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed May 24, 2024
1 parent f739769 commit 9a71786
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on: [push, pull_request]
env:
RUSTDOCFLAGS: -Dwarnings
RUSTFLAGS: -Dwarnings
RUST_LLVM_VERSION: 18.0-2024-02-13
RUST_COMPILER_RT_ROOT: ./compiler-rt

jobs:
test:
Expand Down Expand Up @@ -115,12 +117,18 @@ jobs:
path: /tmp/.buildx-cache
key: ${{ matrix.target }}-buildx-${{ github.sha }}
restore-keys: ${{ matrix.target }}-buildx-


- name: Cache compiler-rt
id: cache-compiler-rt
uses: actions/cache@v4
with:
path: compiler-rt
key: ${{ runner.os }}-compiler-rt-${{ env.RUST_LLVM_VERSION }}
- name: Download compiler-rt reference sources
if: steps.cache-compiler-rt.outputs.cache-hit != 'true'
run: |
curl -L -o code.tar.gz https://github.com/rust-lang/llvm-project/archive/rustc/18.0-2024-02-13.tar.gz
tar xzf code.tar.gz --strip-components 1 llvm-project-rustc-18.0-2024-02-13/compiler-rt
echo RUST_COMPILER_RT_ROOT=./compiler-rt >> $GITHUB_ENV
curl -L -o code.tar.gz "https://github.com/rust-lang/llvm-project/archive/rustc/${RUST_LLVM_VERSION}.tar.gz"
tar xzf code.tar.gz --strip-components 1 llvm-project-rustc-${RUST_LLVM_VERSION}/compiler-rt
shell: bash

# Non-linux tests just use our raw script
Expand Down
32 changes: 32 additions & 0 deletions ci/download-rt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Download LLVM's compiler-rt only if it does not exist or is out of date

set -eauxo pipefail

url="https://github.com/rust-lang/llvm-project/archive/rustc/18.0-2024-02-13.tar.gz"
rt_path="llvm-project-rustc-18.0-2024-02-13/compiler-rt"
expected_sha=""

download () {
curl -L -o code.tar.gz "$url"
tar xzf code.tar.gz --strip-components 1 "$rt_path"
}

existing_hash=$(
find compiler-rt -type f -print0 |
sort -z |
xargs -0 shasum -a 256 |
shasum -U -a 256 |
cut -d' '' -f1 |
tr -d '\n'
)
if [ "$existing_hash" = "$expected_sha" ]; then
echo "Got expected sha '$expected_sha'; nothing to do"
exit
fi
echo "Got $existing_hash; expected $expected_sha. Downloading"
download()

0 comments on commit 9a71786

Please sign in to comment.