-
Notifications
You must be signed in to change notification settings - Fork 7
245 lines (218 loc) · 9.32 KB
/
halide-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
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
name: halide prebuilt
on:
workflow_dispatch:
inputs:
llvm_run_id:
description: 'llvm workflow run id'
default: "latest"
required: true
jobs:
build:
name: halide [${{matrix.arch}}-${{matrix.os}}-${{matrix.version}}]
runs-on: ${{matrix.runner}}
strategy:
fail-fast: true
matrix:
arch: [ x86_64, aarch64 ]
os: [ windows, macos, ubuntu-20.04, ubuntu-22.04 ]
version: [ 16.0.0 ]
include:
- os: windows
runner: windows-2022
- os: macos
runner: macos-12
- os: ubuntu-20.04
runner: ubuntu-20.04
- os: ubuntu-22.04
runner: ubuntu-22.04
- arch: x86_64
os: windows
msvc_arch: amd64
- arch: aarch64
os: windows
msvc_arch: amd64_arm64
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Configure Windows runner
if: runner.os == 'Windows'
run: |
choco install ninja 7zip wget
Install-Module -Name VsDevShell -Force
- 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
- name: Install host clang+llvm
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$LlvmPlatform='${{matrix.os}}'
$LlvmArch='x86_64'
$LlvmVersion = if ('${{matrix.version}}' -eq "14.0.0") { "14.0.6" } else { "16.0.6" }
$LlvmName="clang+llvm-${LlvmVersion}-${LlvmArch}-${LlvmPlatform}"
$RunId = '${{ github.event.inputs.run_id }}'
if ($RunId -eq 'latest') {
$RunId = $(gh run list -w 'LLVM prebuilt' --json 'status,databaseId,conclusion') |
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
Select-Object -First 1 -ExpandProperty databaseId
}
& gh run download $RunId --repo $Env:GITHUB_REPOSITORY -n $LlvmName
if ($IsWindows) {
$TempDir = "C:/temp"
$LLVM_PREFIX = "C:/llvm"
cmd.exe /c "7z.exe x ${LlvmName}.tar.xz -so | 7z x -si -ttar -o`"C:/temp`""
mv "$TempDir/${LlvmName}" $LLVM_PREFIX
} else {
$TempDir = "/tmp"
$LLVM_PREFIX = "/opt/llvm"
tar -xvf "${LlvmName}.tar.xz" -C $TempDir
sudo mv "$TempDir/${LlvmName}" $LLVM_PREFIX
}
$LLVM_BIN_PATH="$LLVM_PREFIX/bin"
$LLVM_DIR="$LLVM_PREFIX/lib/cmake/llvm"
$CLANG_DIR="$LLVM_PREFIX/lib/cmake/clang"
echo "LLVM_X86_64_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV
echo "CLANG_X86_64_DIR=$CLANG_DIR" >> $Env:GITHUB_ENV
echo "LLVM_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV
echo "CLANG_DIR=$CLANG_DIR" >> $Env:GITHUB_ENV
echo "PATH=$LLVM_BIN_PATH$([IO.Path]::PathSeparator)$Env:PATH" >> $Env:GITHUB_ENV
- name: Install target clang+llvm
if: matrix.arch == 'aarch64'
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$LlvmPlatform='${{matrix.os}}'
$LlvmArch='${{matrix.arch}}'
$LlvmVersion = if ('${{matrix.version}}' -eq "14.0.0") { "14.0.6" } else { "16.0.6" }
$LlvmName="clang+llvm-${LlvmVersion}-${LlvmArch}-${LlvmPlatform}"
$RunId = '${{ github.event.inputs.run_id }}'
if ($RunId -eq 'latest') {
$RunId = $(gh run list -w 'LLVM prebuilt' --json 'status,databaseId,conclusion') |
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
Select-Object -First 1 -ExpandProperty databaseId
}
& gh run download $RunId --repo $Env:GITHUB_REPOSITORY -n $LlvmName
if ($IsWindows) {
$TempDir = "C:/temp"
$LLVM_PREFIX = "C:/llvm"
cmd.exe /c "7z.exe x ${LlvmName}.tar.xz -so | 7z x -si -ttar -o`"C:/temp`""
mv "$TempDir/${LlvmName}" $LLVM_PREFIX
} else {
$TempDir = "/tmp"
$LLVM_PREFIX = "/opt/llvm"
tar -xf "${LlvmName}.tar.xz" -C $TempDir
sudo mv "$TempDir/${LlvmName}" $LLVM_PREFIX
}
$LLVM_BIN_PATH="$LLVM_PREFIX/bin"
$LLVM_DIR="$LLVM_PREFIX/lib/cmake/llvm"
$CLANG_DIR="$LLVM_PREFIX/lib/cmake/clang"
echo "LLVM_AARCH64_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV
echo "CLANG_AARCH64_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV
echo "LLVM_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV
- name: Clone project
uses: actions/checkout@v3
with:
path: llvm-prebuilt
- name: Clone Halide ${{matrix.version}}
uses: actions/checkout@v3
with:
repository: halide/Halide
ref: v${{matrix.version}}
path: halide
- name: Patch Halide
shell: pwsh
run: |
if ('${{matrix.version}}' -eq '14.0.0') {
git -C halide apply ../llvm-prebuilt/patches/halide-14-add-halide-host-tools-dir-cmake-option.patch
git -C halide apply ../llvm-prebuilt/patches/halide-14-disable-autoschedulers.patch
git -C halide apply ../llvm-prebuilt/patches/halide-14-disable-imported-clang-llvm-executables.patch
git -C halide apply ../llvm-prebuilt/patches/halide-14-add-clang-no-unknown-warning-option.patch
} else {
git -C halide apply ../llvm-prebuilt/patches/halide-16-add-halide-host-tools-dir-cmake-option.patch
git -C halide apply ../llvm-prebuilt/patches/halide-16-disable-autoschedulers.patch
git -C halide apply ../llvm-prebuilt/patches/halide-16-disable-imported-clang-llvm-executables.patch
git -C halide apply ../llvm-prebuilt/patches/halide-16-add-clang-no-unknown-warning-option.patch
}
- name: Build Halide host tools
shell: pwsh
run: |
if ($IsWindows) {
Enter-VsDevShell x64
}
cmake -G Ninja -S halide -B halide-host `
-DCMAKE_BUILD_TYPE=Release `
-DLLVM_DIR="$Env:LLVM_DIR" `
-Wno-dev
cmake --build halide-host --target build_halide_h binary2cpp regexp_replace
$HALIDE_HOST_TOOLS_DIR = "$Env:GITHUB_WORKSPACE/halide-host/tools"
if ($IsWindows) {
$HALIDE_HOST_TOOLS_DIR = "$Env:GITHUB_WORKSPACE/halide-host/bin"
}
echo "HALIDE_HOST_TOOLS_DIR=$HALIDE_HOST_TOOLS_DIR" >> $Env:GITHUB_ENV
- name: Enable Windows target environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.msvc_arch}}
- name: Configure Halide
shell: pwsh
run: |
if ($IsWindows) {
$TargetArch = @{'x86_64'='x86_64';'aarch64'='arm64'}['${{matrix.arch}}']
$Env:CC="clang-cl --target=${TargetArch}-pc-windows-msvc"
$Env:CXX="clang-cl --target=${TargetArch}-pc-windows-msvc"
}
$TargetName = "${{matrix.arch}}-${{matrix.os}}"
$CMakeToolchainFile = "$Env:GITHUB_WORKSPACE/llvm-prebuilt/cmake/$TargetName.cmake"
$CMakeArgs = @("-DCMAKE_BUILD_TYPE=Release", "-DBUILD_SHARED_LIBS=ON")
$CMakeArgs += @("-DWITH_TESTS=OFF", "-DWITH_TUTORIALS=OFF")
$CMakeArgs += @("-DWITH_DOCS=OFF", "-DWITH_UTILS=OFF")
$CMakeArgs += @("-DWITH_PYTHON_BINDINGS=OFF")
$CMakeArgs += @("-DTARGET_WEBASSEMBLY=ON")
$CMakeArgs += @("-Wno-dev")
if ('${{matrix.os}}' -eq 'macos') {
$AppleArch = @{'x86_64'='x86_64';'aarch64'='arm64'}['${{matrix.arch}}']
$CMakeArgs += @("-DCMAKE_OSX_ARCHITECTURES=`"$AppleArch`"")
}
cmake -G Ninja -S halide -B halide-build $CMakeArgs `
-DLLVM_DIR="$Env:LLVM_DIR" `
-DClang_DIR="$Env:CLANG_DIR" `
-DHALIDE_HOST_TOOLS_DIR="$Env:HALIDE_HOST_TOOLS_DIR" `
-DCMAKE_INSTALL_PREFIX="halide-install" `
-DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile"
- name: Build Halide
run: cmake --build halide-build
- name: Install Halide
run: cmake --install halide-build
- name: Package Halide
if: runner.os != 'Windows'
run: |
PACKAGE_NAME="halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}"
mv halide-install ./${PACKAGE_NAME}
tar -cJf ${PACKAGE_NAME}.tar.xz ${PACKAGE_NAME}
- name: Package Halide
if: runner.os == 'Windows'
shell: pwsh
run: |
$PACKAGE_NAME="halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}"
mv halide-install $PACKAGE_NAME
cmd.exe /c "7z a -ttar -snl -so $PACKAGE_NAME.tar $PACKAGE_NAME | 7z a -si $PACKAGE_NAME.tar.xz"
- name: Upload Halide package
uses: actions/upload-artifact@v3
with:
name: halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}
path: halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar.xz