-
Notifications
You must be signed in to change notification settings - Fork 0
372 lines (304 loc) · 13.3 KB
/
llvm-binaries.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
name: build-llvm-binaries
on:
workflow_dispatch:
inputs:
llvm_version:
description: 'LLVM Version'
default: '17.0.6'
required: false
type: string
debug_info:
description: 'Emit PDBs (Debug Info)'
default: false
type: boolean
env:
SCCACHE_DIRECT: yes
jobs:
build_tools:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
include:
# Default valuies
- c_compiler: clang
- cxx_compiler: clang++
- executable_suffix:
# Overrides
- c_compiler: cl
os: windows-latest
- cxx_compiler: cl
os: windows-latest
- executable_suffix: .exe
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: llvmorg-${{ inputs.llvm_version }}
path: ${{ github.workspace }}/SourceCache/llvm-project
show-progress: false
- uses: compnerd/gha-setup-vsdevenv@main
- uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.11.1
- name: Setup sccache
uses: compnerd/[email protected]
with:
max-size: 100M
key: sccache-${{ matrix.os }}-build_tools
variant: sccache
- name: Configure Tools
run: >-
cmake -B ${{ github.workspace }}/BinaryCache/0
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_C_COMPILER=${{ matrix.c_compiler }}
-D CMAKE_C_COMPILER_LAUNCHER=sccache
-D CMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }}
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache
-D CMAKE_MT=mt
-G Ninja
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm
-D LLVM_ENABLE_ASSERTIONS=NO
-D LLVM_ENABLE_LIBEDIT=NO
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lldb"
-D LLDB_ENABLE_PYTHON=NO
-D LLDB_INCLUDE_TESTS=NO
- name: Build llvm-tblgen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target llvm-tblgen
- name: Build clang-tblgen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target clang-tblgen
- name: Build lldb-tblgen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target lldb-tblgen
- name: Build llvm-config
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target llvm-config
- name: Build clang-pseudo-gen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target clang-pseudo-gen
- name: Build clang-tidy-confusable-chars-gen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target clang-tidy-confusable-chars-gen
- name: Archive tools
run: >-
tar cf tools.tar
bin/llvm-tblgen${{ matrix.executable_suffix }}
bin/clang-tblgen${{ matrix.executable_suffix }}
bin/lldb-tblgen${{ matrix.executable_suffix }}
bin/llvm-config${{ matrix.executable_suffix }}
bin/clang-pseudo-gen${{ matrix.executable_suffix }}
bin/clang-tidy-confusable-chars-gen${{ matrix.executable_suffix }}
working-directory: ${{ github.workspace }}/BinaryCache/0
- uses: actions/upload-artifact@v4
with:
name: build-tools-${{ matrix.os }}
path: ${{ github.workspace }}/BinaryCache/0/tools.tar
distribution:
needs: [build_tools]
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
arch: [amd64, arm64]
include:
# Default values
- c_compiler: clang
- cxx_compiler: clang++
- toolset_suffix:
- cmake_system_name:
- cmake_system_processor:
- lldb_enable_libxml2:
- into_environment: '>> $GITHUB_ENV'
- executable_suffix:
- llvm_enable_projects: 'clang;lld'
- static_lib_suffix: .a
# Overrides
- into_environment: '| Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append'
os: windows-latest
- c_compiler: cl
os: windows-latest
- cxx_compiler: cl
os: windows-latest
- toolset_suffix: -msvc17
os: windows-latest
- cmake_system_processor: -D CMAKE_SYSTEM_PROCESSOR=ARM64
arch: arm64
- cmake_system_name: -D CMAKE_SYSTEM_NAME=Windows
arch: arm64
os: windows-latest
- cmake_system_name: -D CMAKE_SYSTEM_NAME=Darwin
arch: arm64
os: macos-latest
- lldb_enable_libxml2: -D LLDB_ENABLE_LIBXML2=NO
arch: arm64
- executable_suffix: .exe
os: windows-latest
- llvm_enable_projects: 'clang;lld;lldb'
os: windows-latest
- static_lib_suffix: .lib
os: windows-latest
# Extensions
- triple_cpu: x86_64
arch: amd64
- triple_cpu: arm64
arch: arm64
- triple_suffix: unknown-windows-msvc17
os: windows-latest
- triple_suffix: unknown-linux-gnu
os: ubuntu-latest
- triple_suffix: apple-darwin23.3.0
os: macos-latest
runs-on: ${{ matrix.os }}
env:
# Must be a full version string from https://www.nuget.org/packages/pythonarm64
PYTHON_VERSION: 3.12.2
TARGET_TRIPLE: ${{ matrix.triple_cpu }}-${{ matrix.triple_suffix }}
LLVM_CONFIG: llvm-${{ matrix.triple_cpu }}-${{ matrix.triple_suffix }}-release
steps:
- uses: actions/download-artifact@v4
with:
name: build-tools-${{ matrix.os }}
path: ${{ github.workspace }}/BinaryCache/0
- name: Extract tools
run: tar xf tools.tar
working-directory: ${{ github.workspace }}/BinaryCache/0
- uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: llvmorg-${{ inputs.llvm_version }}
path: ${{ github.workspace }}/SourceCache/llvm-project
show-progress: false
- uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/SourceCache/llvm-build
show-progress: false
- name: Install Python ${{ env.PYTHON_VERSION }} (Host)
uses: actions/setup-python@v5
id: python
with:
python-version: '${{ env.PYTHON_VERSION }}'
- name: Export Host Python Location
run: echo "TARGET_PYTHON_LOCATION=${{ env.pythonLocation }}" ${{ matrix.into_environment }}
# TODO(lxbndr) use actions/cache to improve this step timings
- name: Install Python ${{ env.PYTHON_VERSION }} (arm64)
if: ${{ matrix.arch == 'arm64' && matrix.os == 'windows-latest' }}
run: |
nuget install pythonarm64 -Version ${{ env.PYTHON_VERSION }}
echo "TARGET_PYTHON_LOCATION=${{ github.workspace }}/pythonarm64.${{ env.PYTHON_VERSION }}/tools" ${{ matrix.into_environment }}
- name: Setup sccache
uses: compnerd/[email protected]
with:
max-size: 500M
key: sccache-${{ matrix.os }}-${{ matrix.arch }}-distribution
variant: sccache
- uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.11.1
- name: Fetch Python CMake Build System
if: ${{ matrix.arch == 'arm64' && matrix.os != 'windows-latest' && false }}
uses: actions/checkout@v4
with:
repository: python-cmake-buildsystem/python-cmake-buildsystem
ref: master
path: ${{ github.workspace }}/SourceCache/python-cmake-buildsystem
show-progress: false
- name: Build/Install Python ${{ env.PYTHON_VERSION }} (arm64)
if: ${{ matrix.arch == 'arm64' && matrix.os != 'windows-latest' && false }}
run: >-
cmake -GNinja ${{ matrix.cmake_system_name }} ${{ matrix.cmake_system_processor }}
-S ${{ github.workspace }}/SourceCache/python-cmake-buildsystem
-B ${{ github.workspace }}/BinaryCache/python
-D CMAKE_C_COMPILER_LAUNCHER=sccache
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache
-D CMAKE_C_COMPILER=clang
-D CMAKE_CXX_COMPILER=clang++
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/python-${{ env.PYTHON_VERSION }}-${{ env.TARGET_TRIPLE }}
-D CMAKE_BUILD_TYPE=Release
cmake --build ${{ github.workspace }}/BinaryCache/python --target install
echo "PYTHON_LOCATION_arm64=${{ github.workspace }}/BuildRoot/python-${{ env.PYTHON_VERSION }}-${{ env.TARGET_TRIPLE }}/tools"
${{ matrix.into_environment }}
- uses: compnerd/gha-setup-vsdevenv@main
if: matrix.os == 'windows-latest'
with:
host_arch: amd64
toolset_version: 14.37.32822
components: 'Microsoft.VisualStudio.Component.VC.14.37.17.7.x86.x64;Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM64'
arch: ${{ matrix.arch }}
- name: Workaround MSVC#10444970
if: ${{ matrix.arch == 'arm64' && matrix.os == 'windows-latest' }}
run: |
$clangTooling = "${{ github.workspace }}/SourceCache/llvm-project/clang/lib/Tooling/Inclusions/Stdlib/CMakeLists.txt"
Set-Content $clangTooling @"
$(Get-Content -Raw $clangTooling)
set_source_files_properties(StandardLibrary.cpp PROPERTIES
COMPILE_FLAGS "/Od /Gw /Oi /Oy /Gw /Ob2 /Ot /GF")
"@
$clangCodeGen = "${{ github.workspace }}/SourceCache/llvm-project/clang/lib/CodeGen/CMakeLists.txt"
Set-Content $clangCodeGen @"
$(Get-Content -Raw $clangCodeGen)
set_source_files_properties(CGBuiltin.cpp PROPERTIES
COMPILE_FLAGS "/Od /Gw /Oi /Oy /Gw /Ob2 /Ot /GF")
"@
- name: Configure LLVM
run: >-
cmake -GNinja ${{ matrix.cmake_system_name }} ${{ matrix.cmake_system_processor }} ${{ matrix.lldb_enable_libxml2 }}
-B ${{ github.workspace }}/BinaryCache/1
-C ${{ github.workspace }}/SourceCache/llvm-build/cmake/caches/LLVM.cmake
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_C_COMPILER=${{ matrix.c_compiler }}
-D CMAKE_C_COMPILER_LAUNCHER=sccache
-D CMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }}
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache
-D CMAKE_MT=mt
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/${{ env.LLVM_CONFIG }}
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm
-D CLANG_TABLEGEN=${{ github.workspace }}/BinaryCache/0/bin/clang-tblgen${{ matrix.executable_suffix }}
-D CLANG_TIDY_CONFUSABLE_CHARS_GEN=${{ github.workspace }}/BinaryCache/0/bin/clang-tidy-confusable-chars-gen${{ matrix.executable_suffix }}
-D LLDB_TABLEGEN=${{ github.workspace }}/BinaryCache/0/bin/lldb-tblgen${{ matrix.executable_suffix }}
-D LLVM_CONFIG_PATH=${{ github.workspace }}/BinaryCache/0/bin/llvm-config${{ matrix.executable_suffix }}
-D LLVM_NATIVE_TOOL_DIR=${{ github.workspace }}/BinaryCache/0/bin
-D LLVM_TABLEGEN=${{ github.workspace }}/BinaryCache/0/bin/llvm-tblgen${{ matrix.executable_suffix }}
-D LLVM_USE_HOST_TOOLS=NO
-D CLANG_VENDOR=hylo-lang.org
-D CLANG_VENDOR_UTI=org.hylo-lang.dt
-D PACKAGE_VENDOR=hylo-lang.org
-D LLVM_DEFAULT_TARGET_TRIPLE=${{ env.TARGET_TRIPLE }}
-D LLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}"
-D LLVM_PARALLEL_LINK_JOBS=2
-D LLVM_APPEND_VC_REV=NO
-D LLVM_VERSION_SUFFIX=""
-D LLDB_PYTHON_EXE_RELATIVE_PATH=python${{ matrix.executable_suffix }}
-D LLDB_PYTHON_EXT_SUFFIX=.pyd
-D LLDB_PYTHON_RELATIVE_PATH=lib/site-packages
-D Python3_EXECUTABLE=${{ steps.python.outputs.python-path }}
-D Python3_INCLUDE_DIR=${{ env.TARGET_PYTHON_LOCATION }}/include
-D Python3_LIBRARY=${{ env.TARGET_PYTHON_LOCATION }}/libs/python312${{ matrix.static_lib_suffix }}
-D Python3_ROOT_DIR=${{ env.pythonLocation }}
- name: Build LLVM
run: cmake --build ${{ github.workspace }}/BinaryCache/1
- name: Install LLVM
run: cmake --build ${{ github.workspace }}/BinaryCache/1 --target install
- name: Upload LLVM
uses: actions/upload-artifact@v4
with:
name: distribution-${{ matrix.arch }}
path: ${{ github.workspace }}/BuildRoot/
- name: Package LLVM
run: |
7z a -t7z ${{ env.LLVM_CONFIG }}.7z ${{ github.workspace }}\BuildRoot\${{ env.LLVM_CONFIG }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ env.LLVM_CONFIG }}.7z
# TODO(compnerd) this takes ~1h due to the size, see if we can compress first
- uses: actions/upload-artifact@v4
if: false # ${{ inputs.debug_info }}
with:
name: distribution-${{ matrix.arch }}-debug-info
path: |
${{ github.workspace }}/BinaryCache/1/**/*.pdb
- uses: microsoft/[email protected]
if: ${{ inputs.debug_info }}
with:
accountName: ${{ vars.SYMBOL_SERVER_ACCOUNT }}
personalAccessToken: ${{ secrets.SYMBOL_SERVER_PAT }}
symbolsFolder: ${{ github.workspace }}/BinaryCache/1