forked from zhongfly/mpv-winbuild
-
Notifications
You must be signed in to change notification settings - Fork 1
182 lines (170 loc) · 7.09 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
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
name: LLVM
run-name: "${{ inputs.run_name != '' && inputs.run_name || github.workflow }}"
on:
workflow_dispatch:
inputs:
pgo:
description: "Build llvm with PGO"
required: false
default: true
type: boolean
no_save_cache:
description: "Don't save caches after success build"
required: false
default: false
type: boolean
trigger_toolchain:
description: "Trigger toolchain build action after success build"
required: false
default: false
type: boolean
build_target:
description: "Toolchain build target"
required: false
default: "all-64bit"
type: choice
options:
- 64bit-v3
- 64bit-v4
- aarch64
- all-64bit
- all
trigger_build:
description: "Trigger mpv build action after toolchain build"
required: false
default: false
type: boolean
release:
description: "Publish a release after mpv build"
required: false
default: false
type: boolean
run_name:
description: 'The name displayed in the list of workflow runs'
required: false
jobs:
build_llvm:
name: Build LLVM
runs-on: ubuntu-latest
container:
image: cachyos/cachyos-v3:latest
steps:
- name: suffix
id: suffix
run: |
cache_suffix="$(date "+%Y-%m-%d")-${{ github.run_id }}-${{ github.run_attempt }}"
echo "cache_suffix=$cache_suffix" >> "$GITHUB_OUTPUT"
- name: Install Dependencies
run: |
sudo bash -c 'yes y|pacman -Syu'
sudo bash -c 'yes y|pacman -Sy --needed base-devel dash zlib-ng-compat git ninja cmake meson wget mimalloc go ccache bin-cpuflags-x86'
mkdir -p /home/opt/7zip
wget -qO - https://www.7-zip.org/a/7z2301-linux-x64.tar.xz | tar -xJf - -C /home/opt/7zip 7zzs
sudo ln -s /home/opt/7zip/7zzs /usr/bin/7z
git config --global user.name "github-actions[bot]"
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
sudo GOBIN=/usr/bin go install go.chromium.org/luci/cipd/client/cmd/...@latest
sudo cipd install fuchsia/third_party/clang/linux-amd64 latest -root /usr/local/fuchsia-clang
echo "PATH=/usr/local/fuchsia-clang/bin:$PATH" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Checkout toolchain
uses: actions/checkout@v4
with:
repository: Andarwinux/mpv-winbuild-cmake
path: mpv-winbuild-cmake
fetch-depth: 0
- name: Build LLVM
uses: ./action/build_toolchain
with:
bit: "64-v4"
compiler: "clang"
command: "ninja -C $buildroot/build$bit toolchain-download || true ; ninja -C $buildroot/build$bit toolchain-download && ninja -C $buildroot/build$bit llvm-host-libcxx && ninja -C $buildroot/build$bit llvm && ninja -C $buildroot/build$bit toolchain-fullclean"
extra_option: "${{ inputs.pgo && '-DCREL_AVAILABLE=OFF -DCUSTOM_LIBCXX=ON -DCUSTOM_COMPILER_RT=OFF -DLLVM_ENABLE_PGO=GEN -DLLVM_ENABLE_LTO=Thin -DLLVM_PROFILE_DATA_DIR=$PWD/profiles/ -DTOOLCHAIN_FLAGS=-mno-sse4a'}}"
- name: Training LLVM
uses: ./action/build_toolchain
if: ${{ inputs.pgo }}
with:
bit: "64-v4"
compiler: "clang"
command: "ninja -C $buildroot/build$bit rebuild_cache && ninja -C $buildroot/build$bit toolchain-download && ninja -C $buildroot/build$bit llvm-clang && ninja -C $buildroot/build$bit aria2"
extra_option: "-DCREL_AVAILABLE=OFF -DCUSTOM_LIBCXX=ON -DCUSTOM_COMPILER_RT=OFF -DLLVM_ENABLE_PGO=GEN -DLLVM_ENABLE_LTO=Thin -DCLANG_PACKAGES_LTO=ON -DENABLE_CCACHE=ON -DLLVM_PROFILE_DATA_DIR=$buildroot/profiles/ -DTOOLCHAIN_FLAGS=-mno-sse4a"
- name: Merging profdata
if: ${{ inputs.pgo }}
run: |
shopt -s globstar
cd mpv-winbuild-cmake/profiles/
ls -R
llvm-profdata merge *.profraw -o ../llvm.profdata
rm -rf ./{*,.*} || true
- name: Build LLVM with PGO
uses: ./action/build_toolchain
if: ${{ inputs.pgo }}
with:
bit: "64-v4"
compiler: "clang"
command: "ninja -C $buildroot/build$bit toolchain-fullclean && ninja -C $buildroot/build$bit llvm-host-compiler-rt-builtin && ninja -C $buildroot/build$bit llvm-host-libcxx && ninja -C $buildroot/build$bit llvm && rm -rf clang_root/llvm-thinlto || true"
extra_option: "-DCREL_AVAILABLE=OFF -DCUSTOM_LIBCXX=ON -DCUSTOM_COMPILER_RT=ON -DLLVM_ENABLE_PGO=USE -DLLVM_ENABLE_LTO=Thin -DLLVM_PROFDATA_FILE=$buildroot/llvm.profdata -DTOOLCHAIN_FLAGS=-mno-sse4a"
- name: Test
run: |
file mpv-winbuild-cmake/clang_root/llvmbin/llvm
ldd mpv-winbuild-cmake/clang_root/llvmbin/llvm
ls -alh mpv-winbuild-cmake/clang_root/llvmbin/llvm
bin-cpuflags-x86 -d mpv-winbuild-cmake/clang_root/llvmbin/llvm
llvm-readobj --headers --notes mpv-winbuild-cmake/clang_root/llvmbin/llvm
./mpv-winbuild-cmake/clang_root/llvmbin/llvm clang -v
- name: Save llvm cache
uses: actions/cache/[email protected]
if: ${{ !inputs.no_save_cache }}
with:
path: |
mpv-winbuild-cmake/clang_root
key: llvm-${{ steps.suffix.outputs.cache_suffix }}
- name: Collect logs
if: ${{ always() }}
run: |
sudo 7z a logs.7z $(find mpv-winbuild-cmake -type f -iname "*-*.log")
- name: upload logs
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: llvm_logs
path: logs.7z
- name: "release llvm"
uses: ncipollo/release-action@v1
with:
prerelease: false
artifacts: mpv-winbuild-cmake/clang_root/llvmbin/llvm
replacesArtifacts: true
tag: llvm
name: llvm
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
trigger:
needs: [build_llvm]
if: ${{ always() && inputs.trigger_toolchain && !inputs.no_save_cache && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Trigger Toolchain build workflow
uses: actions/github-script@v7
with:
retries: 3
script: |
const repo="${{github.repository}}".split('/')[1];
await github.rest.actions.createWorkflowDispatch({
owner: '${{github.repository_owner}}',
repo,
ref: '${{github.ref}}',
workflow_id: 'toolchain.yml',
inputs: {
build_target: "${{ inputs.build_target }}",
compiler: "clang",
trigger_build: ${{ inputs.trigger_build }},
release: ${{ inputs.release }},
run_name: `CI Build: llvm update`
}
})