-
Notifications
You must be signed in to change notification settings - Fork 42
101 lines (91 loc) · 3.61 KB
/
llvm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: LLVM
on:
workflow_call:
outputs:
cache-key:
value: ${{ jobs.llvm.outputs.cache-key }}
jobs:
llvm:
runs-on: ubuntu-22.04
name: llvm
outputs:
cache-key: ${{ steps.cache-key.outputs.cache-key }}
steps:
- id: ls-remote
run: |
set -euxo pipefail
value=$(git ls-remote https://github.com/aya-rs/llvm-project.git refs/heads/rustc/19.1-2024-09-17 | cut -f1)
echo "sha=$value" >> "$GITHUB_OUTPUT"
- id: cache-key
run: echo "cache-key=llvm-${{ steps.ls-remote.outputs.sha }}-1" >> "$GITHUB_OUTPUT"
- name: Cache
id: cache-llvm
uses: actions/cache@v4
with:
path: llvm-install
key: ${{ steps.cache-key.outputs.cache-key }}
lookup-only: true
- name: Install Tools
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
set -euxo pipefail
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \
gpg --dearmor - | \
sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | \
sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
sudo apt update
sudo apt -y install cmake ninja-build clang lld
- name: Checkout LLVM Source
if: steps.cache-llvm.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: aya-rs/llvm-project
ref: ${{ steps.ls-remote.outputs.sha }}
path: llvm-project
- name: Configure LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
set -euxo pipefail
cmake \
-S llvm-project/llvm \
-B llvm-build \
-G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/llvm-install" \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_PROJECTS= \
-DLLVM_ENABLE_RUNTIMES= \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_TARGETS_TO_BUILD=BPF \
-DLLVM_USE_LINKER=lld
- name: Install LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
env:
# Create symlinks rather than copies to conserve disk space. At the time of this writing,
# GitHub-hosted runners have 14GB of SSD space
# (https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources).
#
# Since the LLVM build creates a bunch of symlinks (and this setting does not turn those
# into symlinks-to-symlinks), use absolute symlinks so we can distinguish the two cases.
CMAKE_INSTALL_MODE: ABS_SYMLINK
run: cmake --build llvm-build --target install
- name: Rewrite LLVM Symlinks
if: steps.cache-llvm.outputs.cache-hit != 'true'
# Move targets over the symlinks that point to them.
#
# This whole dance would be simpler if CMake supported CMAKE_INSTALL_MODE=MOVE.
run: |
set -euxo pipefail
find llvm-install -type l -execdir sh -eux -c '
for link in "$@"; do
target=$(readlink "$link")
case $target in
/*) mv "$target" "$link" ;;
esac
done
' sh {} +