LLVM prebuilt #100
Workflow file for this run
This file contains 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 prebuilt | |
on: workflow_dispatch | |
jobs: | |
build: | |
name: LLVM ${{matrix.version}} [${{matrix.arch}}-${{matrix.os}}] ${{matrix.distro}} | |
runs-on: ${{matrix.runner}} | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [ x86_64, aarch64 ] | |
os: [ windows, macos, ubuntu-20.04, ubuntu-22.04 ] | |
version: [ 14.0.6, 16.0.6 ] | |
include: | |
- version: 14.0.6 | |
branch: release/14.x | |
- version: 16.0.6 | |
branch: release/16.x | |
- os: windows | |
runner: windows-2022 | |
- os: macos | |
runner: macos-latest | |
- os: ubuntu-20.04 | |
runner: ubuntu-20.04 | |
- os: ubuntu-22.04 | |
runner: ubuntu-22.04 | |
- arch: x86_64 | |
os: windows | |
msvc: amd64 | |
- arch: aarch64 | |
os: windows | |
msvc: amd64_arm64 | |
- arch: x86_64 | |
os: macos | |
osx_arch: x86_64 | |
- arch: aarch64 | |
os: macos | |
osx_arch: arm64 | |
steps: | |
- name: Configure Windows runner | |
if: runner.os == 'Windows' | |
run: | | |
choco install ninja 7zip | |
- name: Configure macOS runner | |
if: runner.os == 'macOS' | |
run: | | |
brew install ninja | |
echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> $GITHUB_ENV | |
- name: Configure Linux runner | |
if: runner.os == 'Linux' | |
shell: pwsh | |
run: | | |
sudo apt update | |
sudo apt install zstd xz-utils | |
sudo apt install ninja-build | |
sudo apt install g++-aarch64-linux-gnu | |
sudo apt install libxml2-dev | |
mkdir libxml2-dev-arm64 && cd libxml2-dev-arm64 | |
$LibXmlDebFile = if ($(lsb_release -rs) -eq '20.04') { | |
"libxml2-dev_2.9.10+dfsg-5ubuntu0.20.04.7_arm64.deb" | |
} else { | |
"libxml2-dev_2.9.13+dfsg-1build1_arm64.deb" | |
} | |
wget -q "http://ports.ubuntu.com/pool/main/libx/libxml2/$LibXmlDebFile" | |
ar -x "$LibXmlDebFile" | |
if (Test-Path 'data.tar.zst') { | |
tar --use-compress-program=unzstd -xf data.tar.zst | |
} else { | |
tar -xf data.tar.xz | |
} | |
sudo cp -R ./usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu | |
cd .. | |
sudo apt install zlib1g-dev | |
mkdir zlib1g-dev-arm64 && cd zlib1g-dev-arm64 | |
$ZlibDebFile = if ($(lsb_release -rs) -eq '20.04') { | |
"zlib1g-dev_1.2.11.dfsg-2ubuntu1_arm64.deb" | |
} else { | |
"zlib1g-dev_1.2.11.dfsg-2ubuntu9_arm64.deb" | |
} | |
wget -q "http://ports.ubuntu.com/pool/main/z/zlib/$ZlibDebFile" | |
ar -x "$ZlibDebFile" | |
if (Test-Path 'data.tar.zst') { | |
tar --use-compress-program=unzstd -xf data.tar.zst | |
} else { | |
tar -xf data.tar.xz | |
} | |
sudo cp -R ./usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu | |
cd .. | |
- name: Clone project | |
uses: actions/checkout@v4 | |
with: | |
path: llvm-prebuilt | |
- name: Clone LLVM ${{matrix.version}} | |
uses: actions/checkout@v4 | |
with: | |
repository: llvm/llvm-project | |
ref: ${{matrix.branch}} | |
path: llvm-project | |
- name: Patch LLVM | |
shell: pwsh | |
run: | | |
if ('${{matrix.version}}' -eq '14.0.6') { | |
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-14-add-lld-install-targets.patch | |
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-14-add-llvm-name-prefix-to-llc-lli-opt-tools.patch | |
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-14-force-disable-clang-ast-introspection.patch | |
} else { | |
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-16-add-lld-install-targets.patch | |
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-16-add-llvm-name-prefix-to-llc-lli-opt-tools.patch | |
git -C llvm-project apply ../llvm-prebuilt/patches/llvm-16-force-disable-clang-ast-introspection.patch | |
} | |
- name: Enable Windows host environment | |
if: runner.os == 'Windows' | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: amd64 | |
- name: Configure LLVM host tools | |
shell: pwsh | |
run: | | |
cmake -G Ninja -S llvm-project/llvm -B llvm-host ` | |
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" ` | |
-DCMAKE_BUILD_TYPE=Release -Wno-dev | |
- name: Build LLVM host tools | |
shell: pwsh | |
run: | | |
cmake --build llvm-host --target llvm-tblgen clang-tblgen llvm-config | |
if ('${{matrix.version}}' -eq '16.0.6') { | |
cmake --build llvm-host --target clang-tidy-confusable-chars-gen clang-pseudo-gen | |
} | |
$HostBinPath = "$Env:GITHUB_WORKSPACE/llvm-host/bin" | |
$ExeExt = if ($IsWindows) { ".exe" } else { "" } | |
echo "LLVM_NATIVE_TOOL_DIR=$HostBinPath" >> $Env:GITHUB_ENV | |
echo "LLVM_TABLEGEN=$HostBinPath/llvm-tblgen$ExeExt" >> $Env:GITHUB_ENV | |
echo "CLANG_TABLEGEN=$HostBinPath/clang-tblgen$ExeExt" >> $Env:GITHUB_ENV | |
echo "LLVM_CONFIG_PATH=$HostBinPath/llvm-config$ExeExt" >> $Env:GITHUB_ENV | |
echo "LLVM_VERSION=${{matrix.version}}" >> $Env:GITHUB_ENV | |
- name: Enable Windows target environment | |
if: runner.os == 'Windows' | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: ${{matrix.msvc}} | |
- name: Configure LLVM | |
shell: pwsh | |
run: | | |
$TargetName = "${{matrix.arch}}-${{matrix.os}}" | |
$CMakeToolchainFile = "$Env:GITHUB_WORKSPACE/llvm-prebuilt/cmake/$TargetName.cmake" | |
$CMakeInitialCache = "$Env:GITHUB_WORKSPACE/llvm-prebuilt/cmake/llvm-distribution.cmake" | |
$CMakeArgs = @() | |
if ('${{matrix.os}}' -eq 'macos') { | |
$AppleArch = @{'x86_64'='x86_64';'aarch64'='arm64'}['${{matrix.arch}}'] | |
$CMakeArgs += @("-DCMAKE_OSX_ARCHITECTURES=$AppleArch") | |
} | |
cmake -G Ninja -S llvm-project/llvm -B llvm-build $CMakeArgs ` | |
-DCMAKE_INSTALL_PREFIX=llvm-install ` | |
-DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile" ` | |
-C $CMakeInitialCache -Wno-dev | |
- name: Build LLVM | |
run: cmake --build llvm-build | |
- name: Install LLVM | |
run: cmake --build llvm-build --target install-distribution | |
- name: Package LLVM | |
if: runner.os != 'Windows' | |
run: | | |
mv llvm-install clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}} | |
tar -cJf clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar.xz clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}} | |
- name: Package LLVM | |
if: runner.os == 'Windows' | |
run: | | |
ren llvm-install clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}} | |
cmd.exe /c "7z a -ttar -snl -so clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}} | 7z a -si clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar.xz" | |
- name: Upload LLVM package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}} | |
path: clang+llvm-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar.xz |