diff --git a/.github/actions/setup-llvm/action.yml b/.github/actions/setup-llvm/action.yml new file mode 100644 index 000000000..d1ca04059 --- /dev/null +++ b/.github/actions/setup-llvm/action.yml @@ -0,0 +1,64 @@ +name: Set up LLVM +description: Restore or build LLVM with assertions enabled + +inputs: + save-cache: + description: Save LLVM caches after a cache miss + required: false + default: "true" + +runs: + using: composite + steps: + - name: Restore LLVM source cache + uses: actions/cache/restore@v5 + id: cache-llvm-source + with: + key: llvm-source-22-linux-ubuntu-24.04-asserts-v1-${{ hashFiles('llvm-version.txt') }} + path: | + llvm-project/clang/lib/Headers + llvm-project/clang/include + llvm-project/compiler-rt + llvm-project/lld/include + llvm-project/llvm/include + - name: Download LLVM source + if: steps.cache-llvm-source.outputs.cache-hit != 'true' + shell: bash + run: make llvm-source + - name: Save LLVM source cache + uses: actions/cache/save@v5 + if: inputs.save-cache == 'true' && steps.cache-llvm-source.outputs.cache-hit != 'true' + with: + key: ${{ steps.cache-llvm-source.outputs.cache-primary-key }} + path: | + llvm-project/clang/lib/Headers + llvm-project/clang/include + llvm-project/compiler-rt + llvm-project/lld/include + llvm-project/llvm/include + - name: Restore LLVM build cache + uses: actions/cache/restore@v5 + id: cache-llvm-build + with: + key: llvm-build-22-linux-ubuntu-24.04-asserts-v1-${{ hashFiles('llvm-version.txt') }} + path: llvm-build + - name: Install Ninja + if: steps.cache-llvm-build.outputs.cache-hit != 'true' + shell: bash + run: | + sudo apt-get update + sudo apt-get install --no-install-recommends ninja-build + - name: Build LLVM + if: steps.cache-llvm-build.outputs.cache-hit != 'true' + shell: bash + run: | + rm -rf llvm-project + make llvm-source + make llvm-build ASSERT=1 + find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \; + - name: Save LLVM build cache + uses: actions/cache/save@v5 + if: inputs.save-cache == 'true' && steps.cache-llvm-build.outputs.cache-hit != 'true' + with: + key: ${{ steps.cache-llvm-build.outputs.cache-primary-key }} + path: llvm-build diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 3465f020d..95037acfb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -220,7 +220,7 @@ jobs: assert-test-linux: # Run all tests that can run on Linux, with LLVM assertions enabled to catch # potential bugs. - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@v6 @@ -239,8 +239,7 @@ jobs: qemu-system-arm \ qemu-system-riscv32 \ qemu-user \ - simavr \ - ninja-build + simavr - name: Install Go uses: actions/setup-go@v6 with: @@ -264,53 +263,7 @@ jobs: "https://github.com/espressif/qemu/releases/download/$release/$archive" tar -xJf "$RUNNER_TEMP/$archive" -C "$RUNNER_TEMP" echo "$RUNNER_TEMP/qemu/bin" >> "$GITHUB_PATH" - - name: Restore LLVM source cache - uses: actions/cache/restore@v5 - id: cache-llvm-source - with: - key: llvm-source-22-linux-asserts-v1-${{ hashFiles('llvm-version.txt') }} - path: | - llvm-project/clang/lib/Headers - llvm-project/clang/include - llvm-project/compiler-rt - llvm-project/lld/include - llvm-project/llvm/include - - name: Download LLVM source - if: steps.cache-llvm-source.outputs.cache-hit != 'true' - run: make llvm-source - - name: Save LLVM source cache - uses: actions/cache/save@v5 - if: steps.cache-llvm-source.outputs.cache-hit != 'true' - with: - key: ${{ steps.cache-llvm-source.outputs.cache-primary-key }} - path: | - llvm-project/clang/lib/Headers - llvm-project/clang/include - llvm-project/compiler-rt - llvm-project/lld/include - llvm-project/llvm/include - - name: Restore LLVM build cache - uses: actions/cache/restore@v5 - id: cache-llvm-build - with: - key: llvm-build-22-linux-asserts-v1-${{ hashFiles('llvm-version.txt') }} - path: llvm-build - - name: Build LLVM - if: steps.cache-llvm-build.outputs.cache-hit != 'true' - run: | - # fetch LLVM source - rm -rf llvm-project - make llvm-source - # build! - make llvm-build ASSERT=1 - # Remove unnecessary object files (to reduce cache size). - find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \; - - name: Save LLVM build cache - uses: actions/cache/save@v5 - if: steps.cache-llvm-build.outputs.cache-hit != 'true' - with: - key: ${{ steps.cache-llvm-build.outputs.cache-primary-key }} - path: llvm-build + - uses: ./.github/actions/setup-llvm - name: Cache Binaryen uses: actions/cache@v5 id: cache-binaryen