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
3 changes: 2 additions & 1 deletion .github/workflows/debian-portable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Upgrade Rust toolchain
run: |
apt-get update
apt-get install -y uuid-dev nasm
apt-get install -y uuid-dev nasm patchelf
apt-get install -y --no-install-recommends curl ca-certificates
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile minimal --default-toolchain stable
Expand Down Expand Up @@ -86,6 +86,7 @@ jobs:
model_list.json \
model_info.json
echo "Created tarball with symlinks preserved"
# The default backend is XRT, so confirm libxrt is bundled.
tar tzf $GITHUB_WORKSPACE/fastflowlm_${VERSION}_linux.tar.gz | grep libxrt

- name: Upload portable build artifact
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build
build_*/
.vscode
__pycache__
_site
Expand Down
2 changes: 2 additions & 0 deletions hrx-integration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Fetched HRX release artifact (populated by fetch-hrx-release.sh).
.hrx-release/
157 changes: 157 additions & 0 deletions hrx-integration/fetch-hrx-release.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<#
.SYNOPSIS
Fetch and verify the pinned HRX amdxdna *Windows public package* release.

.DESCRIPTION
Windows counterpart of fetch-hrx-release.sh. Downloads the Windows .zip pinned
in hrx-release.env (HRX_RELEASE_ASSET_WINDOWS / HRX_RELEASE_SHA256_WINDOWS),
verifies its checksum, extracts it, locates the HRX CMake package config, and
prints the package prefix to feed find_package(hrx) via CMAKE_PREFIX_PATH.

After XADX removal, FLM consumes HRX through find_package(hrx CONFIG REQUIRED)
from the public package (CMake package config + hrx.dll/import lib + public
headers), not the former HRX_DIR/HRX_BUILD source+build tree. So configure the
FLM build with:

-DCMAKE_PREFIX_PATH=<the HRX_CMAKE_PREFIX printed below>

The archive is extracted into <script-dir>\.hrx-release\<artifact-root>.

When running in GitHub Actions, also writes `prefix=<package-prefix>` to
$env:GITHUB_OUTPUT.

.PARAMETER OutDir
Optional output directory (defaults to <script-dir>\.hrx-release).
#>
[CmdletBinding()]
param(
[string]$OutDir
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest

$here = $PSScriptRoot
$releaseEnv = Join-Path $here 'hrx-release.env'
if (-not (Test-Path -LiteralPath $releaseEnv)) {
throw "missing $releaseEnv"
}

# Parse the shell-style .env (KEY=VALUE or KEY="VALUE"; ignore comments/blanks).
$env_vars = @{}
foreach ($line in Get-Content -LiteralPath $releaseEnv) {
$trimmed = $line.Trim()
if ($trimmed -eq '' -or $trimmed.StartsWith('#')) { continue }
if ($trimmed -match '^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$') {
$key = $Matches[1]
$val = $Matches[2].Trim().Trim('"').Trim("'")
$env_vars[$key] = $val
}
}

function Require-Var([string]$name) {
if (-not $env_vars.ContainsKey($name) -or [string]::IsNullOrWhiteSpace($env_vars[$name])) {
throw "missing $name in $releaseEnv"
}
return $env_vars[$name]
}

$repo = Require-Var 'HRX_RELEASE_REPO'
$tag = Require-Var 'HRX_RELEASE_TAG'
$asset = Require-Var 'HRX_RELEASE_ASSET_WINDOWS'
$sha256 = (Require-Var 'HRX_RELEASE_SHA256_WINDOWS').ToLower()

if ($tag -like 'TODO*' -or $asset -like '*TODO*' -or $sha256 -like 'todo*') {
throw "hrx-release.env still has TODO placeholders. The Linux agent must " +
"publish the HRX public package and fill in REPO/TAG/ASSET/SHA256 first."
}

if (-not $OutDir) { $OutDir = Join-Path $here '.hrx-release' }
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null

$baseUrl = "https://github.com/$repo/releases/download/$tag"
$zip = Join-Path $OutDir $asset
$shaFile = "$zip.sha256"

function Download-File([string]$url, [string]$path) {
Write-Host "download: $url"
for ($attempt = 1; $attempt -le 3; $attempt++) {
try {
Invoke-WebRequest -Uri $url -OutFile $path -UseBasicParsing
return
} catch {
if ($attempt -eq 3) { throw }
Start-Sleep -Seconds 2
}
}
}

Download-File "$baseUrl/$asset" $zip
Download-File "$baseUrl/$asset.sha256" $shaFile

$remoteSha = ((Get-Content -LiteralPath $shaFile | Select-Object -First 1) -split '\s+')[0].ToLower()
if ([string]::IsNullOrWhiteSpace($remoteSha)) { throw "empty remote sha256 file: $shaFile" }
if ($remoteSha -ne $sha256) {
throw "remote sha256 mismatch: expected $sha256, got $remoteSha"
}

$actualSha = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash.ToLower()
if ($actualSha -ne $sha256) {
throw "zip sha256 mismatch: expected $sha256, got $actualSha"
}

# The archive root directory mirrors the asset name without the .zip suffix.
$artifactRootName = [System.IO.Path]::GetFileNameWithoutExtension($asset)
if ([string]::IsNullOrWhiteSpace($artifactRootName)) { throw "could not determine zip root" }

$artifactRoot = Join-Path $OutDir $artifactRootName
if (Test-Path -LiteralPath $artifactRoot) {
Remove-Item -LiteralPath $artifactRoot -Recurse -Force
}

Expand-Archive -LiteralPath $zip -DestinationPath $OutDir -Force

# Some archives contain the package files at the top level rather than under a
# directory named after the asset; fall back to the extraction dir in that case.
if (-not (Test-Path -LiteralPath $artifactRoot)) {
$artifactRoot = $OutDir
}

# Locate the HRX CMake package config (hrx-config.cmake / hrxConfig.cmake). Its
# containing dir is what find_package(hrx CONFIG) needs on CMAKE_PREFIX_PATH; we
# report the package prefix (two levels up from lib/cmake/hrx when present).
$configFile = Get-ChildItem -LiteralPath $artifactRoot -Recurse -File `
-Include 'hrx-config.cmake', 'hrxConfig.cmake' -ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $configFile) {
throw "no HRX CMake package config (hrx-config.cmake/hrxConfig.cmake) found " +
"under $artifactRoot -- is this a public HRX package built with the " +
"CMake packaging flow and IREE_HAL_DRIVER_AMDXDNA=ON?"
}

$configDir = Split-Path -Parent $configFile.FullName
# Prefer the install prefix (…/<prefix>/lib/cmake/hrx -> <prefix>); else use the
# config dir directly. Both are valid on CMAKE_PREFIX_PATH.
$prefix = $configDir
if ((Split-Path -Leaf $configDir) -ieq 'hrx') {
$cmakeDir = Split-Path -Parent $configDir
if ((Split-Path -Leaf $cmakeDir) -ieq 'cmake') {
$libDir = Split-Path -Parent $cmakeDir
$prefix = Split-Path -Parent $libDir
}
}

Write-Host "HRX_ARTIFACT_ROOT=$artifactRoot"
Write-Host "HRX_CMAKE_CONFIG=$($configFile.FullName)"
Write-Host "HRX_CMAKE_PREFIX=$prefix"
Write-Host ""
Write-Host "Configure FLM with: -DCMAKE_PREFIX_PATH=`"$prefix`""
if ($env:GITHUB_OUTPUT) {
# Append without a BOM: Windows PowerShell 5.1's `Out-File -Encoding utf8`
# emits a UTF-8 BOM, which would corrupt the output key name and make
# steps.<id>.outputs.prefix resolve to empty.
[System.IO.File]::AppendAllText(
$env:GITHUB_OUTPUT,
"prefix=$prefix`n",
(New-Object System.Text.UTF8Encoding($false)))
}
115 changes: 115 additions & 0 deletions hrx-integration/fetch-hrx-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/usr/bin/env bash
# Fetch and verify the pinned HRX amdxdna *public package* release artifact.
#
# After XADX removal, FLM consumes HRX via find_package(hrx CONFIG REQUIRED) from
# the public package (CMake package config + libhrx.so + public headers), not the
# former HRX_DIR/HRX_BUILD source+build tree. This script downloads + verifies +
# extracts the package and prints its CMake package prefix (feed it to the FLM
# build via -DCMAKE_PREFIX_PATH). The Linux agent owns finalizing this path.
set -euo pipefail

usage() {
cat <<'USAGE'
usage: fetch-hrx-release.sh [out-dir]

Downloads the HRX public package pinned in ./hrx-release.env, verifies its
checksum, extracts it, locates the HRX CMake package config, and prints the
package prefix for find_package(hrx).

When running in GitHub Actions, the script also writes:
prefix=<package-prefix>
to $GITHUB_OUTPUT.
USAGE
}

die() {
echo "ERROR: $*" >&2
exit 1
}

if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage
exit 0
fi

here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root="$here"
release_env="$here/hrx-release.env"
[[ -f "$release_env" ]] || die "missing $release_env"

# shellcheck disable=SC1090
source "$release_env"

: "${HRX_RELEASE_REPO:?missing HRX_RELEASE_REPO in $release_env}"
: "${HRX_RELEASE_TAG:?missing HRX_RELEASE_TAG in $release_env}"
: "${HRX_RELEASE_ASSET:?missing HRX_RELEASE_ASSET in $release_env}"
: "${HRX_RELEASE_SHA256:?missing HRX_RELEASE_SHA256 in $release_env}"

case "$HRX_RELEASE_TAG$HRX_RELEASE_ASSET$HRX_RELEASE_SHA256" in
*TODO*)
die "hrx-release.env still has TODO placeholders. The Linux agent must publish the HRX public package and fill in REPO/TAG/ASSET/SHA256 first."
;;
esac

out_dir="${1:-$root/.hrx-release}"
mkdir -p "$out_dir"

base_url="https://github.com/${HRX_RELEASE_REPO}/releases/download/${HRX_RELEASE_TAG}"
tarball="$out_dir/$HRX_RELEASE_ASSET"
sha_file="$tarball.sha256"

download() {
local url="$1"
local path="$2"
echo "download: $url"
curl -fsSL --retry 3 --retry-delay 2 -o "$path" "$url"
}

download "$base_url/$HRX_RELEASE_ASSET" "$tarball"
download "$base_url/$HRX_RELEASE_ASSET.sha256" "$sha_file"

remote_sha="$(awk '{print $1; exit}' "$sha_file")"
[[ -n "$remote_sha" ]] || die "empty remote sha256 file: $sha_file"
[[ "$remote_sha" == "$HRX_RELEASE_SHA256" ]] ||
die "remote sha256 mismatch: expected $HRX_RELEASE_SHA256, got $remote_sha"

actual_sha="$(sha256sum "$tarball" | awk '{print $1}')"
[[ "$actual_sha" == "$HRX_RELEASE_SHA256" ]] ||
die "tarball sha256 mismatch: expected $HRX_RELEASE_SHA256, got $actual_sha"

# Public package ships as .tar.zst (fall back to gzip for legacy assets).
# Decompress zstd via the standalone binary piped into tar, so extraction does
# not depend on tar being built with its zstd plugin, and fail with a clear
# message when the zstd package is not installed.
case "$HRX_RELEASE_ASSET" in
*.tar.zst)
command -v zstd >/dev/null 2>&1 ||
die "zstd is required to extract $HRX_RELEASE_ASSET but was not found on PATH (install the 'zstd' package)"
zstd -dc "$tarball" | tar -C "$out_dir" -xf -
;;
*.tar.gz|*.tgz) tar -C "$out_dir" -xzf "$tarball" ;;
*) tar -C "$out_dir" -xf "$tarball" ;;
esac

# Locate the HRX CMake package config; its dir feeds find_package(hrx CONFIG).
config_file="$(find "$out_dir" -type f \( -name 'hrx-config.cmake' -o -name 'hrxConfig.cmake' \) 2>/dev/null | head -n1)"
[[ -n "$config_file" ]] ||
die "no HRX CMake package config found under $out_dir -- is this a public HRX package built with the CMake packaging flow and IREE_HAL_DRIVER_AMDXDNA=ON?"

config_dir="$(dirname "$config_file")"
# Prefer the install prefix (.../<prefix>/lib/cmake/hrx -> <prefix>); else the config dir.
prefix="$config_dir"
if [[ "$(basename "$config_dir")" == "hrx" ]]; then
cmake_dir="$(dirname "$config_dir")"
if [[ "$(basename "$cmake_dir")" == "cmake" ]]; then
prefix="$(dirname "$(dirname "$cmake_dir")")"
fi
fi

echo "HRX_CMAKE_CONFIG=$config_file"
echo "HRX_CMAKE_PREFIX=$prefix"
echo ""
echo "Configure FLM with: -DCMAKE_PREFIX_PATH=\"$prefix\""
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
echo "prefix=$prefix" >> "$GITHUB_OUTPUT"
fi
12 changes: 12 additions & 0 deletions hrx-integration/hrx-release.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (C) 2026 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Pinned HRX (amdxdna) release consumed by the HRX runtime path.
HRX_RELEASE_REPO="jtuyls/hrx"
HRX_RELEASE_TAG="flm-hrx-amdxdna-v2026.07.30"
# For Linux.
HRX_RELEASE_ASSET="hrx-amdxdna-2026.07.30-amdxdna-hal-native-rel-eb0b39f-linux-x86_64.tar.zst"
HRX_RELEASE_SHA256="661ed94051cc6ad04f53739b2df7a791aecb658bc435bd5a6ff3c46716696345"
# For Windows.
HRX_RELEASE_ASSET_WINDOWS="hrx-amdxdna-2026.07.30-amdxdna-hal-native-rel-eb0b39f-windows-x86_64.zip"
HRX_RELEASE_SHA256_WINDOWS="b3af74c9b393ce49ef71a3cbec2cbe92be6d40601858b41009d2bda57eadeb43"
Loading
Loading