From de108e05f0b3df48efff93a8bec15e6ff8333f09 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 19 Sep 2026 06:19:01 -0500 Subject: [PATCH] ci: Cache LLVM downloads separately rust-cache made some changes (presumably [1]) that delete most non-Rust files before caching, including the LLVM source, but leave the directories. This causes `download-llvm.sh` to think the source exists and skip a re-download, but the build fails because the needed files are missing. It's not clear whether the download was being cached previously, or if rust-cache deleted the directories so it was always re-downloaded. Move the directory in CI and set up a separate cache step so rust-cache isn't responsible for these files anymore. [1]: https://github.com/Swatinem/rust-cache/commit/3bf42ac996de475743278f3187c4fd89f23b8630 --- .github/workflows/main.yaml | 8 ++++++++ etc/download-llvm.sh | 2 +- fuzz/build.rs | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 20044d7..4fec031 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -9,6 +9,7 @@ env: RUSTDOCFLAGS: -Dwarnings RUSTFLAGS: -Dwarnings RUST_BACKTRACE: full + LLVM_DOWNLOAD_DIR: "${{ github.workspace }}/llvm-downloads" jobs: test: @@ -31,8 +32,15 @@ jobs: - uses: Swatinem/rust-cache@v2 with: key: ${{ matrix.target }} + + - name: Cache LLVM source + uses: actions/cache@v6 + with: + path: llvm-downloads + key: llvm-downloads-${{ hashFiles('Cargo.toml', 'etc/download-llvm.sh') }} - name: Download llvm source run: ./etc/download-llvm.sh + - name: Build and run tests run: cargo test --workspace diff --git a/etc/download-llvm.sh b/etc/download-llvm.sh index 4dd4d23..68bcf0a 100755 --- a/etc/download-llvm.sh +++ b/etc/download-llvm.sh @@ -12,7 +12,7 @@ version="$( llvm_hash="${version##*-}" target_dir="${CARGO_TARGET_DIR:-target}" -out_dir="$target_dir/llvm-downloads" +out_dir="${LLVM_DOWNLOAD_DIR:-$target_dir/llvm-downloads}" mkdir -p "$out_dir" if [ -d "$out_dir/llvm-project-$llvm_hash" ] && [ "${1:-}" != "-f" ]; then diff --git a/fuzz/build.rs b/fuzz/build.rs index 5c049e3..a119af6 100644 --- a/fuzz/build.rs +++ b/fuzz/build.rs @@ -47,11 +47,15 @@ fn main() -> io::Result<()> { let target_dir = env::var_os("CARGO_TARGET_DIR") .map(PathBuf::from) .unwrap_or_else(|| manifest_dir.parent().unwrap().join("target")); - let llvm_root = target_dir.join(format!("llvm-downloads/llvm-project-{llvm_commit_hash}")); + let version_dir = format!("llvm-project-{llvm_commit_hash}"); + let llvm_root = match env::var_os("LLVM_DOWNLOAD_DIR") { + Some(dir) => PathBuf::from(dir).join(version_dir), + None => target_dir.join("llvm-downloads").join(version_dir), + }; if !llvm_root.try_exists().is_ok_and(|val| val) { panic!( - "llvm dir `{llvm_root:?}` does not exist or cannot be reached. \ + "llvm dir {llvm_root:?} does not exist or cannot be reached. \ Perhaps you need to run etc/download-llvm.sh?" ) }