Skip to content

LLVM

LLVM #68

Workflow file for this run

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'
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/'}}"
- 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/"
- 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 && llvm-strip -s clang_root/bin/llvm-{strings,cvtres} || 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"
- name: Test
run: |
file mpv-winbuild-cmake/clang_root/bin/llvm
ldd mpv-winbuild-cmake/clang_root/bin/llvm
ls -alh mpv-winbuild-cmake/clang_root/bin/llvm
llvm-readobj --headers --notes mpv-winbuild-cmake/clang_root/bin/llvm
./mpv-winbuild-cmake/clang_root/bin/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/bin/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`
}
})