-
Notifications
You must be signed in to change notification settings - Fork 83
164 lines (153 loc) · 5.55 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
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: false
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: true
type: boolean
build_target:
description: "Toolchain build target"
required: false
default: "all-64bit"
type: choice
options:
- 32bit
- 64bit
- 64bit-v3
- aarch64
- all-64bit
- all
trigger_build:
description: "Trigger mpv build action after toolchain build"
required: false
default: true
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: archlinux/archlinux:base-devel
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 pacman -Syu --noconfirm
sudo pacman -S --noconfirm --needed git ninja cmake meson wget mimalloc go
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: shinchiro/mpv-winbuild-cmake
path: mpv-winbuild-cmake
fetch-depth: 0
- name: Build LLVM
uses: ./action/build_toolchain
with:
bit: "64-v3"
compiler: "clang"
command: "ninja -C $buildroot/build$bit llvm"
extra_option: "${{ inputs.pgo && '-DLLVM_ENABLE_PGO=GEN -DLLVM_PROFILE_DATA_DIR=$PWD/profiles/'}}"
- name: Training LLVM
uses: ./action/build_toolchain
if: ${{ inputs.pgo }}
with:
bit: "64-v3"
compiler: "clang"
command: "ninja -C $buildroot/build$bit rebuild_cache && cmake --build $buildroot/build$bit --target llvm-download && ninja -C $buildroot/build$bit llvm-clang"
extra_option: "-DLLVM_ENABLE_PGO=GEN -DLLVM_PROFILE_DATA_DIR=$buildroot/profiles/"
- 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-v3"
compiler: "clang"
command: "ninja -C $buildroot/build$bit llvm && rm -rf clang_root/llvm-thinlto || true"
extra_option: "-DLLVM_ENABLE_PGO=USE -DLLVM_ENABLE_LTO=Thin -DLLVM_PROFDATA_FILE=$buildroot/llvm.profdata"
- 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
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`
}
})