Skip to content

[OrcJIT] Add LLVM ORC JIT v2 dynamic object loader addon #34

[OrcJIT] Add LLVM ORC JIT v2 dynamic object loader addon

[OrcJIT] Add LLVM ORC JIT v2 dynamic object loader addon #34

Workflow file for this run

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: OrcJIT Build
on:
push:
paths:
- "addons/tvm-ffi-orcjit/**"
- ".github/workflows/tvm-ffi-orcjit.yml"
pull_request:
paths:
- "addons/tvm-ffi-orcjit/**"
- ".github/workflows/tvm-ffi-orcjit.yml"
workflow_dispatch:
jobs:
build_wheels:
name: ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-latest, arch: x86_64, build: "cp312-manylinux_x86_64"}
- {os: ubuntu-24.04-arm, arch: aarch64, build: "cp312-manylinux_aarch64"}
- {os: macos-14, arch: arm64, build: "cp312-macosx_arm64"}
- {os: windows-latest, arch: AMD64, build: "cp312-win_amd64"}
steps:
- uses: actions/checkout@v5
with:
submodules: recursive
- uses: ./.github/actions/detect-env-vars
id: env_vars
# ---- Cache LLVM prefix ----
- name: Cache LLVM
uses: actions/cache@v4
id: llvm-cache
with:
path: ${{ runner.os == 'Windows' && 'C:/opt/llvm' || '/opt/llvm' }}
key: llvm-22.1.0-${{ runner.os }}-${{ matrix.arch }}-v2
# ---- Install LLVM via conda (cache miss only) ----
- name: Setup conda
if: steps.llvm-cache.outputs.cache-hit != 'true'
uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
continue-on-error: true
id: conda1
with:
miniforge-version: latest
- name: Setup conda (retry with tar.bz2)
if: steps.llvm-cache.outputs.cache-hit != 'true' && steps.conda1.outcome == 'failure'
uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
with:
miniforge-version: latest
use-only-tar-bz2: true
- name: Create /opt/llvm (macOS)
if: steps.llvm-cache.outputs.cache-hit != 'true' && runner.os == 'macOS'
run: sudo mkdir -p /opt/llvm && sudo chown -R $(whoami) /opt/llvm
- name: Install LLVM (Unix)
if: steps.llvm-cache.outputs.cache-hit != 'true' && runner.os != 'Windows'
shell: bash -l {0}
run: |
conda create -q -p /opt/llvm -c conda-forge \
llvmdev=22.1.0 clangdev=22.1.0 compiler-rt=22.1.0 zlib \
-y
- name: Build static zstd (Unix)
if: steps.llvm-cache.outputs.cache-hit != 'true' && runner.os != 'Windows'
shell: bash -l {0}
run: |
ZSTD_VERSION="1.5.7"
curl -sL "https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/zstd-${ZSTD_VERSION}.tar.gz" \
| tar -xz -C /tmp
cmake -S "/tmp/zstd-${ZSTD_VERSION}/build/cmake" -B /tmp/_zstd_build \
-DCMAKE_INSTALL_PREFIX=/opt/llvm \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DZSTD_BUILD_SHARED=OFF -DZSTD_BUILD_STATIC=ON \
-DZSTD_BUILD_PROGRAMS=OFF
cmake --build /tmp/_zstd_build --target install -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)
- name: Install LLVM (Windows)
if: steps.llvm-cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
shell: cmd /C call {0}
run: |
conda create -q -p C:\opt\llvm -c conda-forge llvmdev=22.1.0 zlib -y
- name: Build static zstd (Windows)
if: steps.llvm-cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
shell: pwsh
run: |
$ZstdVersion = "1.5.7"
$ZstdTarball = "$env:TEMP\zstd-$ZstdVersion.tar.gz"
$ZstdSrc = "$env:TEMP\zstd-$ZstdVersion"
$Prefix = "C:\opt\llvm"
& curl.exe -sSL -o $ZstdTarball "https://github.com/facebook/zstd/releases/download/v$ZstdVersion/zstd-$ZstdVersion.tar.gz"
& "$env:SystemRoot\System32\tar.exe" -xzf $ZstdTarball -C $env:TEMP
cmake -S "$ZstdSrc\build\cmake" -B "$env:TEMP\_zstd_build" `
-DCMAKE_INSTALL_PREFIX="$Prefix\Library" `
-DZSTD_BUILD_SHARED=OFF -DZSTD_BUILD_STATIC=ON `
-DZSTD_BUILD_PROGRAMS=OFF
cmake --build "$env:TEMP\_zstd_build" --config Release --target install -j $env:NUMBER_OF_PROCESSORS
# ---- Build and test wheels ----
- name: Build and test wheels
uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1
with:
package-dir: addons/tvm-ffi-orcjit
output-dir: wheelhouse
env:
CIBW_BUILD: ${{ matrix.build }}
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
CIBW_ARCHS_WINDOWS: ${{ matrix.arch }}
CIBW_BUILD_VERBOSITY: 1
CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
CIBW_ENVIRONMENT: LLVM_PREFIX=/opt/llvm
CIBW_ENVIRONMENT_WINDOWS: LLVM_PREFIX="C:/opt/llvm"
CIBW_CONTAINER_ENGINE: "docker; create_args: --volume /opt/llvm:/opt/llvm"
CIBW_TEST_REQUIRES: pytest ninja
CIBW_TEST_COMMAND: >-
pip install --force-reinstall {project} &&
python {project}/addons/tvm-ffi-orcjit/tests/run_all_tests.py
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ strategy.job-index }}
path: wheelhouse/*.whl