LLVM #62
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| type: choice | |
| options: | |
| - 64bit-v4 | |
| - 64bit-nvl | |
| - aarch64-armv9.2-a | |
| - 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: ghcr.io/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: | | |
| lscpu | |
| sudo pacman-key --init | |
| sudo pacman-key --populate archlinux | |
| sudo pacman -Syu --noconfirm || true | |
| sudo pacman -Syu --noconfirm || true | |
| sudo pacman -Syu --noconfirm || true | |
| sudo pacman -S --noconfirm --needed git ninja cmake meson wget mimalloc go 7zip ccache || true | |
| sudo pacman -S --noconfirm --needed git ninja cmake meson wget mimalloc go 7zip ccache || true | |
| sudo pacman -S --noconfirm --needed git ninja cmake meson wget mimalloc go 7zip ccache || true | |
| 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@v6 | |
| - name: Checkout toolchain | |
| uses: actions/checkout@v6 | |
| 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 toolchains-download || true ; ninja -C $buildroot/build$bit toolchains-download && ninja -C $buildroot/build$bit llvm-host-libcxx && ninja -C $buildroot/build$bit llvm && ninja -C $buildroot/build$bit toolchains-fullclean" | |
| extra_option: "${{ inputs.pgo && '-DLLVM_ENABLE_UNSAFE_X86_AVX512_VFABI=ON -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 toolchains-download && ninja -C $buildroot/build$bit llvm-clang && ninja -C $buildroot/build$bit mujs sqlite harfbuzz mimalloc vulkan" | |
| extra_option: "-DLLVM_ENABLE_UNSAFE_X86_AVX512_VFABI=ON -DCUSTOM_LIBCXX=ON -DCUSTOM_COMPILER_RT=OFF -DLLVM_ENABLE_PGO=GEN -DLLVM_ENABLE_LTO=Thin -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 toolchains-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 && ninja -C $buildroot/build$bit glslc-host" | |
| extra_option: "-DLLVM_ENABLE_UNSAFE_X86_AVX512_VFABI=ON -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 | |
| 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/save@v5.0.5 | |
| 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@v7 | |
| 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@v9 | |
| 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` | |
| } | |
| }) |