Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 31 additions & 54 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions:

jobs:
test-installer-scripts:
name: Test installer script for version ${{ matrix.version }} on ${{ matrix.os }}
name: Installer ${{ matrix.version }} (assertions=${{ matrix.assertions }}) on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -30,7 +30,18 @@ jobs:
windows-2025,
windows-11-arm,
]
version: ["21.1.8", "22.1.0", "f8cb798"]
version: ["23.1.2"]
assertions: ["ON", "OFF"]
include:
- os: ubuntu-26.04
version: "21.1.8"
assertions: "ON"
- os: windows-2025
version: "22.1.8"
assertions: "ON"
- os: macos-26
version: "f8cb798"
assertions: "ON"

steps:
- name: Checkout repository
Expand All @@ -42,71 +53,37 @@ jobs:
if: runner.os != 'Windows'
shell: bash
run: |
installation/setup-mlir.sh -v ${{ matrix.version }} -p /tmp/mlir-install

# Verify installation
if [ ! -d "/tmp/mlir-install/bin" ]; then
echo "Error: bin directory not found"
exit 1
fi

if [ ! -d "/tmp/mlir-install/lib/cmake/llvm" ]; then
echo "Error: LLVM cmake directory not found"
exit 1
fi

if [ ! -d "/tmp/mlir-install/lib/cmake/mlir" ]; then
echo "Error: MLIR cmake directory not found"
exit 1
fi

# Verify binaries exist
export PATH="/tmp/mlir-install/bin:$PATH"
if ! command -v mlir-opt &> /dev/null; then
echo "Error: mlir-opt not found in PATH"
exit 1
installer=installation/setup-mlir.sh
if [[ '${{ matrix.version }}' != 23.1.2 ]]; then
cp "$installer" /tmp/setup-mlir.sh
installer=/tmp/setup-mlir.sh
fi
bash "$installer" -v ${{ matrix.version }} -p /tmp/mlir-install -a ${{ matrix.assertions }}
grep -F "set(LLVM_ENABLE_ASSERTIONS ${{ matrix.assertions }})" /tmp/mlir-install/lib/cmake/llvm/LLVMConfig.cmake

# Test that mlir-opt runs
mlir-opt --version

echo "Installation test passed!"
test -f /tmp/mlir-install/lib/cmake/mlir/MLIRConfig.cmake
/tmp/mlir-install/bin/mlir-opt --version

- name: Test installer script (PowerShell)
if: runner.os == 'Windows'
shell: pwsh
run: |
$install_dir = Join-Path $env:TEMP "mlir-install"

& installation/setup-mlir.ps1 -llvm_version ${{ matrix.version }} -install_prefix $install_dir

# Verify installation
if (-not (Test-Path "$install_dir\bin")) {
Write-Error "bin directory not found"
exit 1
$installer = "installation/setup-mlir.ps1"
if ('${{ matrix.version }}' -ne '23.1.2') {
$installer = Join-Path $env:TEMP "setup-mlir.ps1"
Copy-Item installation/setup-mlir.ps1 $installer
}

if (-not (Test-Path "$install_dir\lib\cmake\llvm")) {
Write-Error "LLVM cmake directory not found"
exit 1
& $installer -llvm_version ${{ matrix.version }} -install_prefix $install_dir -no_assertions:('${{ matrix.assertions }}' -eq 'OFF')
if (-not (Select-String -Path "$install_dir/lib/cmake/llvm/LLVMConfig.cmake" -SimpleMatch "set(LLVM_ENABLE_ASSERTIONS ${{ matrix.assertions }})")) {
throw "Installed LLVM assertion mode does not match"
}

if (-not (Test-Path "$install_dir\lib\cmake\mlir")) {
Write-Error "MLIR cmake directory not found"
exit 1
if (-not (Test-Path "$install_dir/lib/cmake/mlir/MLIRConfig.cmake")) {
throw "MLIR CMake configuration not found"
}

# Verify binaries exist
$env:Path = "$install_dir\bin;$env:Path"
if (-not (Get-Command mlir-opt -ErrorAction SilentlyContinue)) {
Write-Error "mlir-opt not found in PATH"
exit 1
}

# Test that mlir-opt runs
mlir-opt --version

Write-Host "Installation test passed!"
& "$install_dir/bin/mlir-opt.exe" --version

integration-tests:
name: Integration tests with coverage on ${{ matrix.os }}
Expand Down
48 changes: 38 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ List of available LLVM versions:
- `22.1.8`
- `23.1.0`
- `23.1.1`
- `23.1.2`

List of available LLVM commit hashes:

Expand All @@ -51,7 +52,7 @@ For more information on the available LLVM versions and commit hashes, see
- name: Set up MLIR
uses: munich-quantum-software/setup-mlir@v1.4.2
with:
llvm-version: 22.1.8
llvm-version: 23.1.2
```

This extracts a pre-built MLIR installation, adds the binaries to `$PATH`, and
Expand All @@ -61,24 +62,51 @@ defines `$LLVM_DIR` and `$MLIR_DIR`.

If you want to use the pre-built MLIR installations locally, we also provide
installation scripts. The scripts require the LLVM version or commit hash (e.g.,
`22.1.0` or `f8cb798`) and the desired installation directory to be passed. The
`23.1.2` or `f8cb798`) and the desired installation directory to be passed. The
scripts automatically download and use a platform-specific `zstd` binary for
decompression, so only `tar` needs to be installed on the host system.

> [!NOTE]
>
> `tar` is included by default in Windows 10 and Windows 11. If you're using an
> older version, you can install it, for example, via
> [Chocolatey](https://chocolatey.org/): `choco install tar`.
When run from a repository checkout or source archive, the installers use its
`version-manifest.json`. Standalone or piped scripts read the manifest from
`main`. To pin both script and manifest, download the repository's source
archive at the desired commit and run its installer.

On Linux and macOS, use the following Bash command:

```bash
curl -LsSf https://github.com/munich-quantum-software/setup-mlir/releases/latest/download/setup-mlir.sh | bash -s -- -v 22.1.0 -p /path/to/installation
curl -LsSf https://github.com/munich-quantum-software/setup-mlir/releases/latest/download/setup-mlir.sh | bash -s -- -v 23.1.2 -p /path/to/installation
```

On Windows, use the following PowerShell command:
On Windows, use PowerShell 7.4 or newer, which supports the
[binary pipeline](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pipelines#piping-to-native-commands)
used for extraction. `tar` is included with Windows 10 and Windows 11.

```powershell
powershell -ExecutionPolicy ByPass -c "& ([scriptblock]::Create((irm https://github.com/munich-quantum-software/setup-mlir/releases/latest/download/setup-mlir.ps1))) -llvm_version 22.1.0 -install_prefix /path/to/installation"
pwsh -ExecutionPolicy ByPass -c "& ([scriptblock]::Create((irm https://github.com/munich-quantum-software/setup-mlir/releases/latest/download/setup-mlir.ps1))) -llvm_version 23.1.2 -install_prefix /path/to/installation"
```

## Assertion-free release SDKs

Set `assertions: false` to select the native assertion-free SDK:

```yaml
- uses: munich-quantum-software/setup-mlir@v1
with:
llvm-version: 23.1.2
assertions: false
```

The installers accept `-a OFF` in Bash and `-no_assertions` in PowerShell.
Assertions are enabled by default. Tool-cache directories separate the two
variants. Use headers and libraries from the same variant because LLVM's
assertion mode affects its ABI checks.

Each manifest entry describes one version, platform, and architecture.
`asset_name` and `download_url` identify the SDK with assertions;
`noassert_asset_name` and `noassert_download_url` identify the assertion-free
SDK when available. Installers select the requested URL directly and report an
unavailable variant before downloading assets. The optional fields are ignored
by older actions.

The action uses its bundled manifest and checks `main` for versions absent from
that manifest.
Loading
Loading