👷 add windows CI for MLIR #233
Workflow file for this run
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: MLIR CI | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "mlir/**" | |
pull_request: | |
paths: | |
- "mlir/**" | |
- ".github/workflows/ci_mlir.yml" | |
merge_group: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
cpp-test-mlir: | |
name: 🐧 Test MLIR with LLVM@${{ matrix.llvm-version }} | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
llvm-version: [19, 20] | |
env: | |
CMAKE_BUILD_PARALLEL_LEVEL: 4 | |
CTEST_PARALLEL_LEVEL: 4 | |
FORCE_COLOR: 3 | |
steps: | |
# check out the repository | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# install a specific version of the LLVM toolchain | |
- name: Install llvm and mlir | |
run: | | |
sudo apt-get update | |
wget https://apt.llvm.org/llvm.sh -O ${{ runner.temp }}/llvm_install.sh | |
chmod +x ${{ runner.temp }}/llvm_install.sh | |
if sudo ${{ runner.temp }}/llvm_install.sh ${{ matrix.llvm-version }}; then | |
sudo apt-get install -y libmlir-${{ matrix.llvm-version }}-dev \ | |
mlir-${{ matrix.llvm-version }}-tools \ | |
clang-${{ matrix.llvm-version}} \ | |
|| exit 1 | |
else | |
echo "Installation from script failed." | |
exit 1 | |
fi | |
echo "CC=clang-${{ matrix.llvm-version }}" >> $GITHUB_ENV | |
echo "CXX=clang++-${{ matrix.llvm-version }}" >> $GITHUB_ENV | |
echo "MLIR_DIR=/usr/lib/llvm-${{ matrix.llvm-version }}/lib/cmake/mlir" >> $GITHUB_ENV | |
echo "LLVM_DIR=/usr/lib/llvm-${{ matrix.llvm-version }}/lib/cmake/llvm" >> $GITHUB_ENV | |
# set up ccache for faster C++ builds | |
- name: Setup ccache | |
uses: Chocobo1/setup-ccache-action@v1 | |
with: | |
prepend_symlinks_to_path: false | |
override_cache_key: c++-tests-mlir | |
# set up mold as linker for faster C++ builds | |
- name: Set up mold as linker | |
uses: rui314/setup-mold@v1 | |
# set up uv for faster Python package management | |
- name: Install the latest version of uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: 3.13 | |
activate-environment: true | |
# make sure ninja is installed | |
- name: Install Ninja | |
run: uv tool install ninja | |
# make sure the lit test runner is installed | |
- name: Install lit | |
run: uv pip install lit | |
# configure the project with CMake | |
- name: Configure CMake for MLIR | |
run: | | |
cmake -G Ninja -S . -B build \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DBUILD_MQT_CORE_MLIR=ON \ | |
-DLLVM_EXTERNAL_LIT=$(which lit) | |
# build the project and run the tests | |
- name: Build MLIR components and directly run lit tests | |
run: cmake --build build --config Release --target check-quantum-opt | |
cpp-test-mlir-windows: | |
name: 🏁 Test MLIR with LLVM@${{ matrix.llvm-version }} | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
llvm-version: [19, 20] | |
env: | |
CMAKE_BUILD_PARALLEL_LEVEL: 4 | |
CTEST_PARALLEL_LEVEL: 4 | |
FORCE_COLOR: 3 | |
outputs: | |
llvm-latest-tag: ${{ steps.get-latest.outputs.latest }} | |
steps: | |
# check out the repository | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Find latest release of llvm-project | |
id: get-latest | |
run: | | |
$tag = git ls-remote --tags https://github.com/llvm/llvm-project.git "llvmorg-${{ matrix.llvm-version }}.*" | | |
Where-Object { $_ -match "llvmorg-\d+\.\d+\.\d+" } | | |
Sort-Object -Property { | |
if ($_ -match "llvmorg-(\d+)\.(\d+)\.(\d+)") { | |
[int]$Matches[1]*10000 + [int]$Matches[2]*100 + [int]$Matches[3] | |
} | |
} | | |
Select-Object -Last 1 | |
$latest = $tag | ForEach-Object { | |
if ($_ -match "refs/tags/llvmorg-(\d+\.\d+\.\d+)") { | |
$Matches[1] # Extract just the version number (e.g., "20.1.0") | |
} | |
} | | |
Where-Object { $_ -ne $null } | |
echo "Latest tag: $tag" | |
echo "latest=$latest" >> $env:GITHUB_OUTPUT | |
- name: Try to get MLIR from cache | |
uses: actions/cache@v4 | |
id: mlir-cache | |
with: | |
path: ${{ github.workspace }}/llvm-install | |
key: ${{ runner.os }}-llvm-${{ steps.get-latest.outputs.latest }} | |
restore-keys: | | |
${{ runner.os }}-llvm-${{ steps.get-latest.outputs.latest }} | |
# build the llvm-project from source | |
- name: Install llvm and mlir | |
if: steps.mlir-cache.outputs.cache-hit != 'true' | |
run: | | |
git clone --depth 1 https://github.com/llvm/llvm-project.git --branch llvmorg-${{ steps.get-latest.outputs.latest }} | |
cd llvm-project | |
cmake -S llvm -B build_llvm ` | |
-DLLVM_ENABLE_PROJECTS=mlir ` | |
-DLLVM_BUILD_EXAMPLES=OFF ` | |
-DLLVM_TARGETS_TO_BUILD="X86" ` | |
-DCMAKE_BUILD_TYPE=Release ` | |
-DLLVM_BUILD_TESTS=OFF ` | |
-DLLVM_INCLUDE_TESTS=OFF ` | |
-DLLVM_INCLUDE_EXAMPLES=OFF ` | |
-DLLVM_ENABLE_ASSERTIONS=ON ` | |
-DLLVM_ENABLE_UTILS=ON ` | |
-DLLVM_INSTALL_UTILS=ON ` | |
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}\llvm-install | |
cmake --build build_llvm --target install --config Release | |
# set up uv for faster Python package management | |
- name: Install the latest version of uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: 3.13 | |
activate-environment: true | |
# make sure the lit test runner is installed | |
- name: Install lit | |
run: | | |
uv pip install lit | |
# configure the project with CMake | |
- name: Configure CMake for MLIR | |
run: | | |
cmake -S . -B build ` | |
-DCMAKE_BUILD_TYPE=Release ` | |
-DBUILD_MQT_CORE_MLIR=ON ` | |
-DCMAKE_PREFIX_PATH=${{ github.workspace }}\llvm-install ` | |
-DLLVM_EXTERNAL_LIT=${{ github.workspace }}\.venv\Scripts\lit.exe | |
# build the project and run the tests | |
- name: Build MLIR components and directly run lit tests | |
run: | | |
cmake --build build --config Release --target quantum-opt | |
$targetPath = "${{ github.workspace }}\\build\\mlir\\tools\\quantum-opt\\Release\\quantum-opt.exe" | |
$batchContent = '@echo off | |
"{0}" %*' -f $targetPath | |
# Write to a directory that's definitely in PATH | |
$batchContent | Out-File -FilePath "C:\Windows\quantum-opt" -Encoding ascii | |
# Verify the batch file | |
Get-Content "C:\Windows\quantum-opt" | |
Write-Output "Batch file created at C:\Windows\quantum-opt pointing to $targetPath" | |
cmake --build build --config Release --target check-quantum-opt |