halide prebuilt #87
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: halide prebuilt | |
on: | |
workflow_dispatch: | |
inputs: | |
llvm_run_id: | |
description: 'llvm workflow run id' | |
default: "latest" | |
required: true | |
jobs: | |
build: | |
name: halide [${{matrix.arch}}-${{matrix.os}}-${{matrix.version}}] | |
runs-on: ${{matrix.runner}} | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [ x86_64, aarch64 ] | |
os: [ windows, macos, ubuntu-20.04, ubuntu-22.04 ] | |
version: [ 16.0.0 ] | |
include: | |
- os: windows | |
runner: windows-2022 | |
- os: macos | |
runner: macos-12 | |
- os: ubuntu-20.04 | |
runner: ubuntu-20.04 | |
- os: ubuntu-22.04 | |
runner: ubuntu-22.04 | |
- arch: x86_64 | |
os: windows | |
msvc_arch: amd64 | |
- arch: aarch64 | |
os: windows | |
msvc_arch: amd64_arm64 | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Configure Windows runner | |
if: runner.os == 'Windows' | |
run: | | |
choco install ninja 7zip wget | |
Install-Module -Name VsDevShell -Force | |
- 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 | |
- name: Install host clang+llvm | |
shell: pwsh | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
$LlvmPlatform='${{matrix.os}}' | |
$LlvmArch='x86_64' | |
$LlvmVersion = if ('${{matrix.version}}' -eq "14.0.0") { "14.0.6" } else { "16.0.6" } | |
$LlvmName="clang+llvm-${LlvmVersion}-${LlvmArch}-${LlvmPlatform}" | |
$RunId = '${{ github.event.inputs.run_id }}' | |
if ($RunId -eq 'latest') { | |
$RunId = $(gh run list -w 'LLVM prebuilt' --json 'status,databaseId,conclusion') | | |
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } | | |
Select-Object -First 1 -ExpandProperty databaseId | |
} | |
& gh run download $RunId --repo $Env:GITHUB_REPOSITORY -n $LlvmName | |
if ($IsWindows) { | |
$TempDir = "C:/temp" | |
$LLVM_PREFIX = "C:/llvm" | |
cmd.exe /c "7z.exe x ${LlvmName}.tar.xz -so | 7z x -si -ttar -o`"C:/temp`"" | |
mv "$TempDir/${LlvmName}" $LLVM_PREFIX | |
} else { | |
$TempDir = "/tmp" | |
$LLVM_PREFIX = "/opt/llvm" | |
tar -xvf "${LlvmName}.tar.xz" -C $TempDir | |
sudo mv "$TempDir/${LlvmName}" $LLVM_PREFIX | |
} | |
$LLVM_BIN_DIR="$LLVM_PREFIX/bin" | |
$LLVM_DIR="$LLVM_PREFIX/lib/cmake/llvm" | |
$CLANG_DIR="$LLVM_PREFIX/lib/cmake/clang" | |
echo "LLVM_HOST_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV | |
echo "CLANG_HOST_DIR=$CLANG_DIR" >> $Env:GITHUB_ENV | |
if ('${{matrix.arch}}' -eq 'x86_64') { | |
echo "LLVM_TARGET_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV | |
echo "CLANG_TARGET_DIR=$CLANG_DIR" >> $Env:GITHUB_ENV | |
} | |
echo "LLVM_HOST_BIN_DIR=$LLVM_BIN_DIR" >> $Env:GITHUB_ENV | |
echo "PATH=$LLVM_BIN_DIR$([IO.Path]::PathSeparator)$Env:PATH" >> $Env:GITHUB_ENV | |
- name: Install target clang+llvm | |
if: matrix.arch == 'aarch64' | |
shell: pwsh | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
$LlvmPlatform='${{matrix.os}}' | |
$LlvmArch='${{matrix.arch}}' | |
$LlvmVersion = if ('${{matrix.version}}' -eq "14.0.0") { "14.0.6" } else { "16.0.6" } | |
$LlvmName="clang+llvm-${LlvmVersion}-${LlvmArch}-${LlvmPlatform}" | |
$RunId = '${{ github.event.inputs.run_id }}' | |
if ($RunId -eq 'latest') { | |
$RunId = $(gh run list -w 'LLVM prebuilt' --json 'status,databaseId,conclusion') | | |
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } | | |
Select-Object -First 1 -ExpandProperty databaseId | |
} | |
& gh run download $RunId --repo $Env:GITHUB_REPOSITORY -n $LlvmName | |
if ($IsWindows) { | |
$TempDir = "C:/temp" | |
$LLVM_PREFIX = "C:/llvm-$LlvmArch" | |
cmd.exe /c "7z.exe x ${LlvmName}.tar.xz -so | 7z x -si -ttar -o`"C:/temp`"" | |
mv "$TempDir/${LlvmName}" $LLVM_PREFIX | |
} else { | |
$TempDir = "/tmp" | |
$LLVM_PREFIX = "/opt/llvm-$LlvmArch" | |
tar -xf "${LlvmName}.tar.xz" -C $TempDir | |
sudo mv "$TempDir/${LlvmName}" $LLVM_PREFIX | |
} | |
$LLVM_BIN_DIR="$LLVM_PREFIX/bin" | |
$LLVM_DIR="$LLVM_PREFIX/lib/cmake/llvm" | |
$CLANG_DIR="$LLVM_PREFIX/lib/cmake/clang" | |
echo "LLVM_TARGET_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV | |
echo "CLANG_TARGET_DIR=$CLANG_DIR" >> $Env:GITHUB_ENV | |
$LLVM_HOST_BIN_DIR=$Env:LLVM_HOST_BIN_DIR | |
$LLVM_TARGET_BIN_DIR=$LLVM_BIN_DIR | |
$ExeSuffix = if ($IsWindows) { ".exe" } else { "" } | |
@('llvm-as', 'clang', 'clang-format') | ForEach-Object { | |
$ExeFileName = "$_.${ExeSuffix}" | |
Copy-Item -Path "${LLVM_HOST_BIN_DIR}/$ExeFileName" -Destination "${LLVM_TARGET_BIN_DIR}/$ExeFileName" -Force | |
} | |
- name: Clone project | |
uses: actions/checkout@v3 | |
with: | |
path: llvm-prebuilt | |
- name: Clone Halide ${{matrix.version}} | |
uses: actions/checkout@v3 | |
with: | |
repository: halide/Halide | |
ref: v${{matrix.version}} | |
path: halide | |
- name: Patch Halide | |
shell: pwsh | |
run: | | |
if ('${{matrix.version}}' -eq '14.0.0') { | |
git -C halide apply ../llvm-prebuilt/patches/halide-14-add-halide-host-tools-dir-cmake-option.patch | |
git -C halide apply ../llvm-prebuilt/patches/halide-14-disable-autoschedulers.patch | |
git -C halide apply ../llvm-prebuilt/patches/halide-14-disable-imported-clang-llvm-executables.patch | |
git -C halide apply ../llvm-prebuilt/patches/halide-14-add-clang-no-unknown-warning-option.patch | |
} else { | |
git -C halide apply ../llvm-prebuilt/patches/halide-16-add-halide-host-tools-dir-cmake-option.patch | |
git -C halide apply ../llvm-prebuilt/patches/halide-16-disable-autoschedulers.patch | |
git -C halide apply ../llvm-prebuilt/patches/halide-16-disable-clang-verbose-build-warnings.patch | |
} | |
- name: Build Halide host tools | |
shell: pwsh | |
run: | | |
if ($IsWindows) { | |
Enter-VsDevShell x64 | |
} | |
cmake -G Ninja -S halide -B halide-host ` | |
-DCMAKE_BUILD_TYPE=Release ` | |
-DLLVM_DIR="$Env:LLVM_HOST_DIR" ` | |
-DClang_DIR="$Env:CLANG_HOST_DIR" ` | |
-DWITH_TESTS=OFF -DWITH_UTILS=OFF ` | |
-DWITH_PYTHON_BINDINGS=OFF ` | |
-Wno-dev | |
cmake --build halide-host --target build_halide_h binary2cpp regexp_replace | |
$HALIDE_HOST_TOOLS_DIR = "$Env:GITHUB_WORKSPACE/halide-host/tools" | |
if ($IsWindows) { | |
$HALIDE_HOST_TOOLS_DIR = "$Env:GITHUB_WORKSPACE/halide-host/bin" | |
} | |
echo "HALIDE_HOST_TOOLS_DIR=$HALIDE_HOST_TOOLS_DIR" >> $Env:GITHUB_ENV | |
- name: Enable Windows target environment | |
if: runner.os == 'Windows' | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: ${{matrix.msvc_arch}} | |
- name: Configure Halide | |
shell: pwsh | |
run: | | |
if ($IsWindows) { | |
$TargetArch = @{'x86_64'='x86_64';'aarch64'='arm64'}['${{matrix.arch}}'] | |
$Env:CC="clang-cl --target=${TargetArch}-pc-windows-msvc" | |
$Env:CXX="clang-cl --target=${TargetArch}-pc-windows-msvc" | |
} | |
$TargetName = "${{matrix.arch}}-${{matrix.os}}" | |
$CMakeToolchainFile = "$Env:GITHUB_WORKSPACE/llvm-prebuilt/cmake/$TargetName.cmake" | |
$CMakeArgs = @("-DCMAKE_BUILD_TYPE=Release", "-DBUILD_SHARED_LIBS=ON") | |
$CMakeArgs += @("-DWITH_TESTS=OFF", "-DWITH_TUTORIALS=OFF") | |
$CMakeArgs += @("-DWITH_DOCS=OFF", "-DWITH_UTILS=OFF") | |
$CMakeArgs += @("-DWITH_PYTHON_BINDINGS=OFF") | |
$CMakeArgs += @("-DTARGET_WEBASSEMBLY=ON") | |
$CMakeArgs += @("-Wno-dev") | |
if ('${{matrix.os}}' -eq 'macos') { | |
$AppleArch = @{'x86_64'='x86_64';'aarch64'='arm64'}['${{matrix.arch}}'] | |
$CMakeArgs += @("-DCMAKE_OSX_ARCHITECTURES=`"$AppleArch`"") | |
} | |
cmake -G Ninja -S halide -B halide-build $CMakeArgs ` | |
-DLLVM_DIR="$Env:LLVM_TARGET_DIR" ` | |
-DClang_DIR="$Env:CLANG_HOST_DIR" ` | |
-DHALIDE_HOST_TOOLS_DIR="$Env:HALIDE_HOST_TOOLS_DIR" ` | |
-DLLVM_HOST_BIN_DIR="$Env:LLVM_HOST_BIN_DIR" ` | |
-DCMAKE_INSTALL_PREFIX="halide-install" ` | |
-DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile" | |
- name: Build Halide | |
run: cmake --build halide-build | |
- name: Install Halide | |
run: cmake --install halide-build | |
- name: Package Halide | |
shell: pwsh | |
run: | | |
$PACKAGE_NAME="halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}" | |
Move-Item halide-install $PACKAGE_NAME | |
if ($IsWindows) { | |
cmd.exe /c "7z a -ttar -snl -so $PACKAGE_NAME.tar $PACKAGE_NAME | 7z a -si $PACKAGE_NAME.tar.xz" | |
} else { | |
tar -cJf ${PACKAGE_NAME}.tar.xz ${PACKAGE_NAME} | |
} | |
- name: Upload Halide package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}} | |
path: halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}.tar.xz |