diff --git a/.github/workflows/llvmlite/bld_llvm_winarm64.bat b/.github/workflows/llvmlite/bld_llvm_winarm64.bat new file mode 100644 index 0000000..5bf5588 --- /dev/null +++ b/.github/workflows/llvmlite/bld_llvm_winarm64.bat @@ -0,0 +1,81 @@ +@echo off +setlocal enabledelayedexpansion + +set "LLVM_VERSION=20.1.8" +set "WORKSPACE=%CD%" +set "LLVM_SRC_DIR=%WORKSPACE%\llvm-project-%LLVM_VERSION%" +set "BUILD_DIR=%WORKSPACE%\build-arm64" +set "INSTALL_PREFIX=%WORKSPACE%\llvm-arm64-install" + +REM Use existing vcpkg from runner +if not defined VCPKG_INSTALLATION_ROOT set "VCPKG_INSTALLATION_ROOT=C:\vcpkg" +set "VCPKG_DIR=%VCPKG_INSTALLATION_ROOT%" + +REM Setup VS2022 ARM64 environment +call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" arm64 + +REM Install dependencies using vcpkg +"%VCPKG_DIR%\vcpkg.exe" install zlib:arm64-windows-static zstd:arm64-windows-static libxml2:arm64-windows-static + +REM Download and extract LLVM source +if not exist "%LLVM_SRC_DIR%\llvm" ( + if not exist "llvm-project-%LLVM_VERSION%.src.tar.xz" ( + curl -L -o "llvm-project-%LLVM_VERSION%.src.tar.xz" "https://github.com/llvm/llvm-project/releases/download/llvmorg-%LLVM_VERSION%/llvm-project-%LLVM_VERSION%.src.tar.xz" + ) + tar -xf "llvm-project-%LLVM_VERSION%.src.tar.xz" + if exist "llvm-project-%LLVM_VERSION%.src" move "llvm-project-%LLVM_VERSION%.src" "llvm-project-%LLVM_VERSION%" +) + +REM Configure +if exist "%BUILD_DIR%" rmdir /S /Q "%BUILD_DIR%" +mkdir "%BUILD_DIR%" +cd /d "%BUILD_DIR%" + +cmake -G "Ninja" ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DCMAKE_INSTALL_PREFIX=%INSTALL_PREFIX% ^ + -DCMAKE_TOOLCHAIN_FILE=%VCPKG_DIR%\scripts\buildsystems\vcpkg.cmake ^ + -DVCPKG_TARGET_TRIPLET=arm64-windows-static ^ + -DLLVM_USE_INTEL_JITEVENTS=OFF ^ + -DLLVM_ENABLE_LIBXML2=FORCE_ON ^ + -DLLVM_ENABLE_RTTI=OFF ^ + -DLLVM_ENABLE_ZLIB=FORCE_ON ^ + -DLLVM_ENABLE_ZSTD=FORCE_ON ^ + -DLLVM_INCLUDE_BENCHMARKS=OFF ^ + -DLLVM_INCLUDE_DOCS=OFF ^ + -DLLVM_INCLUDE_EXAMPLES=OFF ^ + -DLLVM_INCLUDE_TESTS=ON ^ + -DLLVM_INCLUDE_UTILS=ON ^ + -DLLVM_INSTALL_UTILS=ON ^ + -DLLVM_UTILS_INSTALL_DIR=libexec/llvm ^ + -DLLVM_BUILD_LLVM_C_DYLIB=no ^ + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly ^ + -DCMAKE_POLICY_DEFAULT_CMP0111=NEW ^ + -DLLVM_ENABLE_PROJECTS:STRING=lld;compiler-rt ^ + -DLLVM_ENABLE_ASSERTIONS=ON ^ + -DLLVM_ENABLE_DIA_SDK=OFF ^ + -DCOMPILER_RT_BUILD_BUILTINS=OFF ^ + -DCOMPILER_RT_BUILTINS_HIDE_SYMBOLS=OFF ^ + -DCOMPILER_RT_BUILD_LIBFUZZER=OFF ^ + -DCOMPILER_RT_BUILD_CRT=OFF ^ + -DCOMPILER_RT_BUILD_MEMPROF=OFF ^ + -DCOMPILER_RT_BUILD_PROFILE=OFF ^ + -DCOMPILER_RT_BUILD_SANITIZERS=OFF ^ + -DCOMPILER_RT_BUILD_XRAY=OFF ^ + -DCOMPILER_RT_BUILD_GWP_ASAN=OFF ^ + -DCOMPILER_RT_BUILD_ORC=OFF ^ + -DCOMPILER_RT_INCLUDE_TESTS=OFF ^ + "%LLVM_SRC_DIR%\llvm" + +if !ERRORLEVEL! neq 0 exit /B 1 + +REM Build +cmake --build . --config Release +if !ERRORLEVEL! neq 0 exit /B 1 + +REM Install +cmake --build . --target install --config Release +if !ERRORLEVEL! neq 0 exit /B 1 + +cd /d "%WORKSPACE%" +exit /B 0 diff --git a/.github/workflows/llvmlite/llvmdev_build.yml b/.github/workflows/llvmlite/llvmdev_build.yml new file mode 100644 index 0000000..bd81401 --- /dev/null +++ b/.github/workflows/llvmlite/llvmdev_build.yml @@ -0,0 +1,65 @@ +name: llvmdev + +on: + pull_request: + paths: + - .github/workflows/llvmlite/llvmdev_build.yml + label: + types: [created] + workflow_dispatch: + inputs: + platform: + description: LLVM DEV for Windows ARM64 + default: all + required: true + type: choice + options: + - win-arm64 + recipe: + description: Recipe to build + default: all + required: true + type: choice + options: + - llvmdev_for_wheel + +env: + ARTIFACT_RETENTION_DAYS: 30 + +jobs: + build: + name: llvmdev_for_wheel-win-arm64 + runs-on: windows-11-arm + defaults: + run: + shell: bash -el {0} + strategy: + fail-fast: false + + steps: + - name: Checkout main branch + uses: actions/checkout@v5 + + - name: Build LLVM package - Windows ARM64 platform + shell: cmd + env: + ARTIFACT_DIR: llvm_arm64_artifact + run: | + call "%GITHUB_WORKSPACE%\.github\workflows\llvmlite\bld_llvm_winarm64.bat" + if %ERRORLEVEL% neq 0 exit /B %ERRORLEVEL% + mkdir "%ARTIFACT_DIR%" + xcopy /E /I /Y llvm-arm64-install "%ARTIFACT_DIR%\llvm-arm64-install" + + - name: Upload Windows ARM64 LLVM artifacts + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: llvmdev_for_wheel-win-arm64 + path: llvm_arm64_artifact + compression-level: 0 + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} + if-no-files-found: error + + - name: Get Workflow Run ID + run: | + echo "Current workflow run ID: ${{ github.run_id }}" + echo "Use this ID when triggering llvmlite workflow" diff --git a/.github/workflows/llvmlite/patches/0001-Support-LLVMlite-on-Windows-ARM64.patch b/.github/workflows/llvmlite/patches/0001-Support-LLVMlite-on-Windows-ARM64.patch new file mode 100644 index 0000000..91d74a4 --- /dev/null +++ b/.github/workflows/llvmlite/patches/0001-Support-LLVMlite-on-Windows-ARM64.patch @@ -0,0 +1,72 @@ +From a1d77515c87e40ca9ec75ed52fcea0063211edb9 Mon Sep 17 00:00:00 2001 +From: MugundanMCW +Date: Wed, 28 Jan 2026 09:20:06 +0530 +Subject: [PATCH] Support LLVMlite on Windows ARM64 + +--- + ffi/build.py | 27 +++++++++++++++++++++------ + 1 file changed, 21 insertions(+), 6 deletions(-) + +diff --git a/ffi/build.py b/ffi/build.py +index ef0c2625..c03eda40 100755 +--- a/ffi/build.py ++++ b/ffi/build.py +@@ -12,15 +12,22 @@ import shutil + import sys + import tempfile + import warnings +- ++import platform + + here_dir = os.path.abspath(os.path.dirname(__file__)) + build_dir = os.path.join(here_dir, 'build') + target_dir = os.path.join(os.path.dirname(here_dir), 'llvmlite', 'binding') + +- +-is_64bit = sys.maxsize >= 2**32 +- ++is_windows = sys.platform == "win32" ++is_arm64 = False ++is_64bit = False ++if is_windows: ++ machine = platform.machine().lower() ++ if machine in ("arm64", "aarch64"): ++ is_arm64 = True ++ elif machine in ("amd64", "x86_64"): ++ is_64bit = True ++ + + def env_var_options_to_cmake_options(): + # This is not ideal, it exists to put env var options into CMake. Whilst it +@@ -146,15 +153,22 @@ def find_windows_generator(): + generators.append( + (env_generator, env_arch, env_toolkit) + ) ++ if is_arm64: ++ arch = "ARM64" ++ elif is_64bit: ++ arch = "x64" ++ else: ++ arch = "Win32" + + generators.extend([ + # use VS2022 first +- ('Visual Studio 17 2022', ('x64' if is_64bit else 'Win32'), 'v143'), ++ ('Visual Studio 17 2022', arch, 'v143'), + # try VS2019 next +- ('Visual Studio 16 2019', ('x64' if is_64bit else 'Win32'), 'v142'), ++ ('Visual Studio 16 2019', arch, 'v142'), + # # This is the generator configuration for VS2017 + # ('Visual Studio 15 2017' + (' Win64' if is_64bit else ''), None, None) + ]) ++ + for generator in generators: + build_dir = tempfile.mkdtemp() + print("Trying generator %r" % (generator,)) +@@ -207,3 +221,4 @@ def main(): + + if __name__ == "__main__": + main() ++ +-- +2.43.0 diff --git a/.github/workflows/llvmlite_win-arm64_wheel_builder.yml b/.github/workflows/llvmlite_win-arm64_wheel_builder.yml new file mode 100644 index 0000000..4e5fade --- /dev/null +++ b/.github/workflows/llvmlite_win-arm64_wheel_builder.yml @@ -0,0 +1,110 @@ +name: llvmlite_win-arm64_wheel_builder + +on: + pull_request: + paths: + - .github/workflows/llvmlite_win-arm64_wheel_builder.yml + workflow_dispatch: + inputs: + llvmdev_run_id: + description: 'llvmdev workflow run ID (optional)' + required: false + type: string + upload_wheel_to_anaconda: + description: 'Upload wheel to Anaconda Cloud - numba channel' + required: false + type: boolean + default: false + +env: + VALIDATION_PYTHON_VERSION: "3.12" + ARTIFACT_RETENTION_DAYS: 7 + +jobs: + win-arm64-build: + name: win-arm64-build + runs-on: windows-11-arm + defaults: + run: + shell: cmd + strategy: + matrix: + python-version: ["3.11", "3.12", "3.13", "3.14"] + fail-fast: false + + steps: + - name: Checkout PyEnv-WoA-State repository + uses: actions/checkout@v4 + + - name: Clone llvmlite repository + run: | + git clone https://github.com/numba/llvmlite.git llvmlite_src + cd llvmlite_src + git apply "%GITHUB_WORKSPACE%\.github\workflows\llvmlite\patches\0001-Support-LLVMlite-on-Windows-ARM64.patch" + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 + with: + python-version: ${{ matrix.python-version }} + allow-prereleases: true + + - name: Download llvmdev Artifact + if: ${{ inputs.llvmdev_run_id != '' }} + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 + with: + name: llvmdev_for_wheel-win-arm64 + path: llvm_install + run-id: ${{ inputs.llvmdev_run_id }} + repository: ${{ github.repository }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cache vcpkg installed packages + uses: actions/cache@v4 + with: + path: C:\vcpkg\installed + key: vcpkg-installed-windows-arm64-static-v1 + restore-keys: | + vcpkg-installed-windows-arm64-static + + - name: Install build dependencies + env: + VCPKG_DIR: C:\vcpkg + run: | + "%VCPKG_DIR%\vcpkg.exe" install zlib:arm64-windows-static zstd:arm64-windows-static libxml2:arm64-windows-static + python -m pip install build wheel setuptools delvewheel + + - name: Build wheel + working-directory: llvmlite_src + env: + CMAKE_ARGS: -DCMAKE_PREFIX_PATH=C:\vcpkg\installed\arm64-windows-static + LLVM_DIR: ${{ github.workspace }}\llvm_install\llvm-arm64-install\lib\cmake\llvm + LLVMLITE_PACKAGE_FORMAT: "wheel" + run: python -m build --wheel --no-isolation + + - name: Repair wheel with delvewheel + run: | + if not exist wheel_temp mkdir wheel_temp + move llvmlite_src\dist\*.whl wheel_temp\ + python -m delvewheel repair --analyze-existing -w dist wheel_temp\*.whl + dir dist + + - name: Upload llvmlite wheel + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f + with: + name: llvmlite-win-arm64-py${{ matrix.python-version }} + path: dist/*.whl + compression-level: 0 + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} + if-no-files-found: error + + - name: Create GitHub Release + if: github.event_name == 'workflow_dispatch' + uses: softprops/action-gh-release@v2 + with: + tag_name: llvmlite-win-arm64-${{ github.run_number }} + name: llvmlite Windows ARM64 Wheels - Build ${{ github.run_number }} + prerelease: true + files: dist/*.whl + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +