-
Notifications
You must be signed in to change notification settings - Fork 7
197 lines (173 loc) · 7.25 KB
/
llvm-prebuilt.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: LLVM prebuilt
on: workflow_dispatch
jobs:
build:
name: LLVM ${{matrix.version}} [${{matrix.arch}}-${{matrix.os}}] ${{matrix.distro}}
runs-on: ${{matrix.runner}}
strategy:
fail-fast: false
matrix:
arch: [ x86_64, aarch64 ]
os: [ windows, macos, ubuntu-20.04, ubuntu-22.04 ]
version: [ 14.0.6, 16.0.6 ]
include:
- version: 14.0.6
branch: release/14.x
- version: 16.0.6
branch: release/16.x
- os: windows
runner: windows-2022
- os: macos
runner: macos-latest
- os: ubuntu-20.04
runner: ubuntu-20.04
- os: ubuntu-22.04
runner: ubuntu-22.04
- arch: x86_64
os: windows
msvc: amd64
- arch: aarch64
os: windows
msvc: amd64_arm64
- arch: x86_64
os: macos
osx_arch: x86_64
- arch: aarch64
os: macos
osx_arch: arm64
steps:
- name: Configure Windows runner
if: runner.os == 'Windows'
run: |
choco install ninja 7zip
- name: Configure macOS runner
if: runner.os == 'macOS'
run: |
brew install ninja
echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> $GITHUB_ENV
- name: Configure Linux runner
if: runner.os == 'Linux'
shell: pwsh
run: |
sudo apt update
sudo apt install zstd xz-utils
sudo apt install ninja-build
sudo apt install g++-aarch64-linux-gnu
sudo apt install libxml2-dev
mkdir libxml2-dev-arm64 && cd libxml2-dev-arm64
$LibXmlDebFile = if ($(lsb_release -rs) -eq '20.04') {
"libxml2-dev_2.9.10+dfsg-5ubuntu0.20.04.7_arm64.deb"
} else {
"libxml2-dev_2.9.13+dfsg-1build1_arm64.deb"
}
wget -q "http://ports.ubuntu.com/pool/main/libx/libxml2/$LibXmlDebFile"
ar -x "$LibXmlDebFile"
if (Test-Path 'data.tar.zst') {
tar --use-compress-program=unzstd -xf data.tar.zst
} else {
tar -xf data.tar.xz
}
sudo cp -R ./usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu
cd ..
sudo apt install zlib1g-dev
mkdir zlib1g-dev-arm64 && cd zlib1g-dev-arm64
$ZlibDebFile = if ($(lsb_release -rs) -eq '20.04') {
"zlib1g-dev_1.2.11.dfsg-2ubuntu1_arm64.deb"
} else {
"zlib1g-dev_1.2.11.dfsg-2ubuntu9_arm64.deb"
}
wget -q "http://ports.ubuntu.com/pool/main/z/zlib/$ZlibDebFile"
ar -x "$ZlibDebFile"
if (Test-Path 'data.tar.zst') {
tar --use-compress-program=unzstd -xf data.tar.zst
} else {
tar -xf data.tar.xz
}
sudo cp -R ./usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu
cd ..
- name: Clone project
uses: actions/checkout@v4
with:
path: llvm-prebuilt
- name: Clone LLVM ${{matrix.version}}
uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: ${{matrix.branch}}
path: llvm-project
- name: Patch LLVM
shell: pwsh
run: |
if ('${{matrix.version}}' -eq '14.0.6') {
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-14-add-lld-install-targets.patch
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-14-add-llvm-name-prefix-to-llc-lli-opt-tools.patch
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-14-force-disable-clang-ast-introspection.patch
} else {
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-16-add-lld-install-targets.patch
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-16-add-llvm-name-prefix-to-llc-lli-opt-tools.patch
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-16-force-disable-clang-ast-introspection.patch
}
- name: Enable Windows host environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
- name: Configure LLVM host tools
shell: pwsh
run: |
cmake -G Ninja -S llvm-project/llvm -B llvm-host `
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" `
-DCMAKE_BUILD_TYPE=Release -Wno-dev
- name: Build LLVM host tools
shell: pwsh
run: |
cmake --build llvm-host --target llvm-tblgen clang-tblgen llvm-config
if ('${{matrix.version}}' -eq '16.0.6') {
cmake --build llvm-host --target clang-tidy-confusable-chars-gen clang-pseudo-gen
}
$HostBinPath = "$Env:GITHUB_WORKSPACE/llvm-host/bin"
$ExeExt = if ($IsWindows) { ".exe" } else { "" }
echo "LLVM_NATIVE_TOOL_DIR=$HostBinPath" >> $Env:GITHUB_ENV
echo "LLVM_TABLEGEN=$HostBinPath/llvm-tblgen$ExeExt" >> $Env:GITHUB_ENV
echo "CLANG_TABLEGEN=$HostBinPath/clang-tblgen$ExeExt" >> $Env:GITHUB_ENV
echo "LLVM_CONFIG_PATH=$HostBinPath/llvm-config$ExeExt" >> $Env:GITHUB_ENV
echo "LLVM_VERSION=${{matrix.version}}" >> $Env:GITHUB_ENV
- name: Enable Windows target environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.msvc}}
- name: Configure LLVM
shell: pwsh
run: |
$TargetName = "${{matrix.arch}}-${{matrix.os}}"
$CMakeToolchainFile = "$Env:GITHUB_WORKSPACE/llvm-prebuilt/cmake/$TargetName.cmake"
$CMakeInitialCache = "$Env:GITHUB_WORKSPACE/llvm-prebuilt/cmake/llvm-distribution.cmake"
$CMakeArgs = @()
if ('${{matrix.os}}' -eq 'macos') {
$AppleArch = @{'x86_64'='x86_64';'aarch64'='arm64'}['${{matrix.arch}}']
$CMakeArgs += @("-DCMAKE_OSX_ARCHITECTURES=$AppleArch")
}
cmake -G Ninja -S llvm-project/llvm -B llvm-build $CMakeArgs `
-DCMAKE_INSTALL_PREFIX=llvm-install `
-DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile" `
-C $CMakeInitialCache -Wno-dev
- name: Build LLVM
run: cmake --build llvm-build
- name: Install LLVM
run: cmake --build llvm-build --target install-distribution
- name: Package LLVM
if: runner.os != 'Windows'
run: |
mv llvm-install clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}
tar -cJf clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar.xz clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}
- name: Package LLVM
if: runner.os == 'Windows'
run: |
ren llvm-install clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}
cmd.exe /c "7z a -ttar -snl -so clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}} | 7z a -si clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar.xz"
- name: Upload LLVM package
uses: actions/upload-artifact@v4
with:
name: clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}
path: clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar.xz