Skip to content

Commit 2177945

Browse files
authored
Add Windows ARM64 wheel build support with NEON optimization (#1959)
* enable woa build and add neon optimization * use appropriate python version for win-arm * fix clang-format * add WoA build & install doc
1 parent 5500cff commit 2177945

4 files changed

Lines changed: 342 additions & 23 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
arch: aarch64
3939
- os: windows-2025
4040
arch: x86_64
41+
- os: windows-11-arm
42+
arch: arm64
4143
- os: macos-15
4244
arch: arm64
4345
runs-on: ${{ matrix.os }}
@@ -46,6 +48,8 @@ jobs:
4648
- name: Setup MSVC
4749
if: startsWith(matrix.os, 'windows')
4850
uses: ilammy/msvc-dev-cmd@v1.13.0 # to use cl
51+
with:
52+
arch: ${{ matrix.arch == 'arm64' && 'arm64' || 'x64' }}
4953
- name: Build C++
5054
run: bash .github/scripts/build-cpu.sh
5155
env:
@@ -188,20 +192,27 @@ jobs:
188192
- build-xpu
189193
strategy:
190194
matrix:
191-
os: [ubuntu-22.04, ubuntu-22.04-arm, windows-2025, macos-15]
195+
os: [ubuntu-22.04, ubuntu-22.04-arm, windows-2025, windows-11-arm, macos-15]
192196
include:
193197
- os: ubuntu-22.04
194198
arch: x86_64
199+
python-version: "3.10"
195200
- os: ubuntu-22.04-arm
196201
arch: aarch64
202+
python-version: "3.10"
197203
- os: windows-2025
198204
arch: x86_64
205+
python-version: "3.10"
206+
- os: windows-11-arm
207+
arch: arm64
208+
# Python for Windows ARM64 is only available from 3.12+
209+
python-version: "3.12"
199210
- os: macos-15
200211
arch: arm64
212+
python-version: "3.10"
201213
# The specific Python version is irrelevant in this context as we are only packaging non-C extension
202214
# code. This ensures compatibility across Python versions, as compatibility is
203215
# dictated by the packaged code itself, not the Python version used for packaging.
204-
python-version: ["3.10"]
205216
runs-on: ${{ matrix.os }}
206217
steps:
207218
- uses: actions/checkout@v4
@@ -327,6 +338,8 @@ jobs:
327338
echo "### Linux (aarch64)" >> body.md
328339
elif [[ "$fname" == *"win_amd64"* ]]; then
329340
echo "### Windows (x86_64)" >> body.md
341+
elif [[ "$fname" == *"win_arm64"* ]]; then
342+
echo "### Windows (arm64)" >> body.md
330343
elif [[ "$fname" == *"macosx"* ]]; then
331344
echo "### macOS 14+ (arm64)" >> body.md
332345
else

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,13 @@ if(WIN32)
337337
endif()
338338

339339
if(MSVC)
340-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2 /fp:fast")
340+
# /arch:AVX2 is only valid for x86/x64 targets, not ARM64
341+
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _msvc_arch)
342+
if(_msvc_arch MATCHES "x86|x64|amd64")
343+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2 /fp:fast")
344+
else()
345+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
346+
endif()
341347
endif()
342348

343349
set_source_files_properties(${CPP_FILES} PROPERTIES LANGUAGE CXX)

0 commit comments

Comments
 (0)