Skip to content

Commit e32508b

Browse files
jakebaileydeadprogram
authored andcommitted
ci: share LLVM setup steps
1 parent ae47aa4 commit e32508b

2 files changed

Lines changed: 67 additions & 50 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Set up LLVM
2+
description: Restore or build LLVM with assertions enabled
3+
4+
inputs:
5+
save-cache:
6+
description: Save LLVM caches after a cache miss
7+
required: false
8+
default: "true"
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Restore LLVM source cache
14+
uses: actions/cache/restore@v5
15+
id: cache-llvm-source
16+
with:
17+
key: llvm-source-22-linux-ubuntu-24.04-asserts-v1-${{ hashFiles('llvm-version.txt') }}
18+
path: |
19+
llvm-project/clang/lib/Headers
20+
llvm-project/clang/include
21+
llvm-project/compiler-rt
22+
llvm-project/lld/include
23+
llvm-project/llvm/include
24+
- name: Download LLVM source
25+
if: steps.cache-llvm-source.outputs.cache-hit != 'true'
26+
shell: bash
27+
run: make llvm-source
28+
- name: Save LLVM source cache
29+
uses: actions/cache/save@v5
30+
if: inputs.save-cache == 'true' && steps.cache-llvm-source.outputs.cache-hit != 'true'
31+
with:
32+
key: ${{ steps.cache-llvm-source.outputs.cache-primary-key }}
33+
path: |
34+
llvm-project/clang/lib/Headers
35+
llvm-project/clang/include
36+
llvm-project/compiler-rt
37+
llvm-project/lld/include
38+
llvm-project/llvm/include
39+
- name: Restore LLVM build cache
40+
uses: actions/cache/restore@v5
41+
id: cache-llvm-build
42+
with:
43+
key: llvm-build-22-linux-ubuntu-24.04-asserts-v1-${{ hashFiles('llvm-version.txt') }}
44+
path: llvm-build
45+
- name: Install Ninja
46+
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
47+
shell: bash
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get install --no-install-recommends ninja-build
51+
- name: Build LLVM
52+
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
53+
shell: bash
54+
run: |
55+
rm -rf llvm-project
56+
make llvm-source
57+
make llvm-build ASSERT=1
58+
find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \;
59+
- name: Save LLVM build cache
60+
uses: actions/cache/save@v5
61+
if: inputs.save-cache == 'true' && steps.cache-llvm-build.outputs.cache-hit != 'true'
62+
with:
63+
key: ${{ steps.cache-llvm-build.outputs.cache-primary-key }}
64+
path: llvm-build

.github/workflows/linux.yml

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ jobs:
220220
assert-test-linux:
221221
# Run all tests that can run on Linux, with LLVM assertions enabled to catch
222222
# potential bugs.
223-
runs-on: ubuntu-latest
223+
runs-on: ubuntu-24.04
224224
steps:
225225
- name: Checkout
226226
uses: actions/checkout@v6
@@ -239,8 +239,7 @@ jobs:
239239
qemu-system-arm \
240240
qemu-system-riscv32 \
241241
qemu-user \
242-
simavr \
243-
ninja-build
242+
simavr
244243
- name: Install Go
245244
uses: actions/setup-go@v6
246245
with:
@@ -264,53 +263,7 @@ jobs:
264263
"https://github.com/espressif/qemu/releases/download/$release/$archive"
265264
tar -xJf "$RUNNER_TEMP/$archive" -C "$RUNNER_TEMP"
266265
echo "$RUNNER_TEMP/qemu/bin" >> "$GITHUB_PATH"
267-
- name: Restore LLVM source cache
268-
uses: actions/cache/restore@v5
269-
id: cache-llvm-source
270-
with:
271-
key: llvm-source-22-linux-asserts-v1-${{ hashFiles('llvm-version.txt') }}
272-
path: |
273-
llvm-project/clang/lib/Headers
274-
llvm-project/clang/include
275-
llvm-project/compiler-rt
276-
llvm-project/lld/include
277-
llvm-project/llvm/include
278-
- name: Download LLVM source
279-
if: steps.cache-llvm-source.outputs.cache-hit != 'true'
280-
run: make llvm-source
281-
- name: Save LLVM source cache
282-
uses: actions/cache/save@v5
283-
if: steps.cache-llvm-source.outputs.cache-hit != 'true'
284-
with:
285-
key: ${{ steps.cache-llvm-source.outputs.cache-primary-key }}
286-
path: |
287-
llvm-project/clang/lib/Headers
288-
llvm-project/clang/include
289-
llvm-project/compiler-rt
290-
llvm-project/lld/include
291-
llvm-project/llvm/include
292-
- name: Restore LLVM build cache
293-
uses: actions/cache/restore@v5
294-
id: cache-llvm-build
295-
with:
296-
key: llvm-build-22-linux-asserts-v1-${{ hashFiles('llvm-version.txt') }}
297-
path: llvm-build
298-
- name: Build LLVM
299-
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
300-
run: |
301-
# fetch LLVM source
302-
rm -rf llvm-project
303-
make llvm-source
304-
# build!
305-
make llvm-build ASSERT=1
306-
# Remove unnecessary object files (to reduce cache size).
307-
find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \;
308-
- name: Save LLVM build cache
309-
uses: actions/cache/save@v5
310-
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
311-
with:
312-
key: ${{ steps.cache-llvm-build.outputs.cache-primary-key }}
313-
path: llvm-build
266+
- uses: ./.github/actions/setup-llvm
314267
- name: Cache Binaryen
315268
uses: actions/cache@v5
316269
id: cache-binaryen

0 commit comments

Comments
 (0)