forked from media-kit/libmpv-win32-video-cmake
-
Notifications
You must be signed in to change notification settings - Fork 0
223 lines (194 loc) · 9.4 KB
/
llvm_clang.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
name: llvm toolchain
defaults:
run:
shell: bash
on:
workflow_dispatch:
inputs:
command:
description: 'Run custom command before building'
required: false
type: string
jobs:
build_llvm:
name: Building LLVM and Clang
runs-on: ubuntu-latest
strategy:
fail-fast: false
container:
image: docker://ghcr.io/shinchiro/archlinux:latest
steps:
- name: Setup git config
run: |
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global pull.rebase true
git config --global rebase.autoStash true
git config --global fetch.prune true
git config --global --add safe.directory $PWD
- uses: actions/checkout@main
with:
ref: master
- name: Loading clang root
id: clang_root_cache
uses: actions/cache/restore@main
with:
path: clang_root
key: ${{ secrets.CACHE_VERSION }}-clang_root-${{ github.run_id }}
restore-keys: ${{ secrets.CACHE_VERSION }}-clang_root
- name: Loading x86_64 toolchain
id: x86_64_cache
uses: actions/cache/restore@main
with:
path: build_x86_64
key: ${{ secrets.CACHE_VERSION }}-clang-x86_64_toolchain-${{ github.run_id }}
restore-keys: ${{ secrets.CACHE_VERSION }}-clang-x86_64_toolchain
- name: Loading x86_64_v3 toolchain
id: x86_64_v3_cache
uses: actions/cache/restore@main
with:
path: build_x86_64_v3
key: ${{ secrets.CACHE_VERSION }}-clang-x86_64_v3_toolchain-${{ github.run_id }}
restore-keys: ${{ secrets.CACHE_VERSION }}-clang-x86_64_v3_toolchain
- name: Loading i686 toolchain
id: i686_cache
uses: actions/cache/restore@main
with:
path: build_i686
key: ${{ secrets.CACHE_VERSION }}-clang-i686_toolchain-${{ github.run_id }}
restore-keys: ${{ secrets.CACHE_VERSION }}-clang-i686_toolchain
- name: Loading aarch64 toolchain
id: aarch64_cache
uses: actions/cache/restore@main
with:
path: build_aarch64
key: ${{ secrets.CACHE_VERSION }}-clang-aarch64_toolchain-${{ github.run_id }}
restore-keys: ${{ secrets.CACHE_VERSION }}-clang-aarch64_toolchain
- name: Loading repository cache
id: repository_cache
if: false
uses: actions/cache/restore@main
with:
path: src_packages
key: ${{ secrets.CACHE_VERSION }}-repository-${{ github.run_id }}
restore-keys: ${{ secrets.CACHE_VERSION }}-repository
- name: Running custom command
if: ${{ github.event.inputs.command != '' }}
continue-on-error: true
run: ${{ github.event.inputs.command }}
- name: Building LLVM with IR Profile Instrumentation
if: ${{ steps.clang_root_cache.outputs.cache-matched-key == '' }}
run: |
cmake -DTARGET_ARCH=x86_64-w64-mingw32 -DLLVM_ENABLE_PGO=GEN -DCOMPILER_TOOLCHAIN=clang -DCMAKE_INSTALL_PREFIX=$PWD/clang_root -DMINGW_INSTALL_PREFIX=$PWD/build_x86_64/x86_64-w64-mingw32 -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/clang_root/install_rustup -G Ninja -B build_x86_64 -S $PWD
ninja -C build_x86_64 llvm
ninja -C build_x86_64 rustup
ninja -C build_x86_64 cargo-clean
- name: Building x86_64 toolchain
if: ${{ steps.x86_64_cache.outputs.cache-matched-key == '' }}
run: |
cmake -DTARGET_ARCH=x86_64-w64-mingw32 -DLLVM_ENABLE_PGO=GEN -DCOMPILER_TOOLCHAIN=clang -DCMAKE_INSTALL_PREFIX=$PWD/clang_root -DMINGW_INSTALL_PREFIX=$PWD/build_x86_64/x86_64-w64-mingw32 -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/clang_root/install_rustup -G Ninja -B build_x86_64 -S $PWD
ninja -C build_x86_64 llvm-clang
- name: Building x86_64-v3 toolchain
if: ${{ steps.x86_64_v3_cache.outputs.cache-matched-key == '' }}
run: |
cmake -DTARGET_ARCH=x86_64-w64-mingw32 -DLLVM_ENABLE_PGO=GEN -DCOMPILER_TOOLCHAIN=clang -DGCC_ARCH=x86-64-v3 -DCMAKE_INSTALL_PREFIX=$PWD/clang_root -DMINGW_INSTALL_PREFIX=$PWD/build_x86_64_v3/x86_64_v3-w64-mingw32 -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/clang_root/install_rustup -G Ninja -B build_x86_64_v3 -S $PWD
ninja -C build_x86_64_v3 llvm-clang
- name: Building i686 toolchain
if: ${{ steps.i686_cache.outputs.cache-matched-key == '' }}
run: |
cmake -DTARGET_ARCH=i686-w64-mingw32 -DLLVM_ENABLE_PGO=GEN -DCOMPILER_TOOLCHAIN=clang -DCMAKE_INSTALL_PREFIX=$PWD/clang_root -DMINGW_INSTALL_PREFIX=$PWD/build_i686/i686-w64-mingw32 -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/clang_root/install_rustup -G Ninja -B build_i686 -S $PWD
ninja -C build_i686 llvm-clang
- name: Building aarch64 toolchain
if: ${{ steps.aarch64_cache.outputs.cache-matched-key == '' }}
run: |
cmake -DTARGET_ARCH=aarch64-w64-mingw32 -DLLVM_ENABLE_PGO=GEN -DCOMPILER_TOOLCHAIN=clang -DCMAKE_INSTALL_PREFIX=$PWD/clang_root -DMINGW_INSTALL_PREFIX=$PWD/build_aarch64/aarch64-w64-mingw32 -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/clang_root/install_rustup -G Ninja -B build_aarch64 -S $PWD
ninja -C build_aarch64 llvm-clang
- name: PGO training with shaderc
if: ${{ steps.clang_root_cache.outputs.cache-matched-key == '' }}
run: |
cmake -DTARGET_ARCH=x86_64-w64-mingw32 -DLLVM_ENABLE_PGO=GEN -DCLANG_PACKAGES_LTO=ON -DCOMPILER_TOOLCHAIN=clang -DCMAKE_INSTALL_PREFIX=$PWD/clang_root -DMINGW_INSTALL_PREFIX=$PWD/build_x86_64/x86_64-w64-mingw32 -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/clang_root/install_rustup -G Ninja -B build_x86_64 -S $PWD
ninja -C build_x86_64 shaderc
- name: Merging profraw to profdata
if: ${{ steps.clang_root_cache.outputs.cache-matched-key == '' }}
run: |
llvm-profdata merge $PWD/clang_root/profiles/*.profraw -o llvm.profdata
rm -rf $PWD/clang_root/profiles/* || true
- name: Building LLVM with PGO
if: ${{ steps.clang_root_cache.outputs.cache-matched-key == '' }}
run: |
cmake -DTARGET_ARCH=x86_64-w64-mingw32 -DLLVM_ENABLE_PGO=USE -DLLVM_PROFDATA_FILE="llvm.profdata" -DCOMPILER_TOOLCHAIN=clang -DCMAKE_INSTALL_PREFIX=$PWD/clang_root -DMINGW_INSTALL_PREFIX=$PWD/build_x86_64/x86_64-w64-mingw32 -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/clang_root/install_rustup -G Ninja -B build_x86_64 -S $PWD
ninja -C build_x86_64 llvm
- name: Cleanup
run: |
rm -rf {build_i686,build_x86_64,build_x86_64_v3,build_aarch64}/{toolchain,packages} || true
- name: Collecting logs
if: always()
run: |
mkdir -p build_x86_64_logs build_i686_logs build_aarch64_logs
cp -fr $(find build_x86_64 -type f -iname "*-*.log") build_x86_64_logs || true
cp -fr $(find build_i686 -type f -iname "*-*.log") build_i686_logs || true
cp -fr $(find build_aarch64 -type f -iname "*-*.log") build_aarch64_logs || true
7z a -m0=lzma2 -mx=9 -ms=on logs.7z build*logs
- name: Uploading logs
uses: actions/upload-artifact@master
if: always()
with:
name: logs
path: logs.7z
retention-days: 1
- name: Uploading toolchain
uses: actions/upload-artifact@master
if: always()
with:
name: toolchain
path: clang_root
- name: Saving clang root
uses: actions/cache/save@main
with:
path: clang_root
key: ${{ secrets.CACHE_VERSION }}-clang_root-${{ github.run_id }}
- name: Saving x86_64 toolchain
uses: actions/cache/save@main
with:
path: build_x86_64
key: ${{ secrets.CACHE_VERSION }}-clang-x86_64_toolchain-${{ github.run_id }}
- name: Saving x86_64_v3 toolchain
uses: actions/cache/save@main
with:
path: build_x86_64_v3
key: ${{ secrets.CACHE_VERSION }}-clang-x86_64_v3_toolchain-${{ github.run_id }}
- name: Saving i686 toolchain
uses: actions/cache/save@main
with:
path: build_i686
key: ${{ secrets.CACHE_VERSION }}-clang-i686_toolchain-${{ github.run_id }}
- name: Saving aarch64 toolchain
uses: actions/cache/save@main
with:
path: build_aarch64
key: ${{ secrets.CACHE_VERSION }}-clang-aarch64_toolchain-${{ github.run_id }}
- name: Saving repository cache
if: false
uses: actions/cache/save@main
with:
path: src_packages
key: ${{ secrets.CACHE_VERSION }}-repository-${{ github.run_id }}
call_workflow:
name: Run mpv_clang
runs-on: ubuntu-latest
needs: build_llvm
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Run mpv_clang.yml
run: |
curl -u shinchiro:$GH_TOKEN -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/actions/workflows/mpv_clang.yml/dispatches -d @- <<EOF
{
"ref": "master",
"inputs": {
"sourceforge": "false",
"github_release": "false",
"mpv_tarball": "false"
}
}
EOF