From 33510a52e4cb2648366c5113559c1d6967d0204c Mon Sep 17 00:00:00 2001 From: Harish RS Date: Fri, 20 Feb 2026 22:34:00 +0530 Subject: [PATCH] Enable Windows ARM64 CTest CI for release binaries (#6177) * ci: add Windows ARM64 MSVC CTest job * ci: add MSYS2 clangarm64 build on Windows ARM64 * cmake: add MSVC ARM64 presets for Windows * zlib: fix MSVC static library flags for ARM64 builds --- .github/workflows/arm-main.yml | 2 +- .github/workflows/ctest.yml | 174 ++++++++++++++++++++++- .github/workflows/msys2.yml | 3 +- CMakeInstallation.cmake | 3 + CMakePresets.json | 51 +++++++ config/cmake-presets/hidden-presets.json | 65 +++++++++ config/cmake/ZLIB/CMakeLists.txt | 10 +- config/cmake/ZLIB/devCMakeLists.txt | 10 +- 8 files changed, 309 insertions(+), 9 deletions(-) diff --git a/.github/workflows/arm-main.yml b/.github/workflows/arm-main.yml index 625b1df1022..21d601efb4c 100644 --- a/.github/workflows/arm-main.yml +++ b/.github/workflows/arm-main.yml @@ -161,7 +161,7 @@ jobs: uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v5 with: name: zip-vs2022_cl-${{ inputs.build_mode }}-${{ inputs.save_binary }}-binary - path: ${{ runner.workspace }}/build/HDF5-*-win64.zip + path: ${{ runner.workspace }}/build/HDF5-*-winarm64.zip if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` if: ${{ (inputs.thread_safety != 'TS') && (inputs.concurrent != 'CC') && ( inputs.save_binary != 'skip') }} diff --git a/.github/workflows/ctest.yml b/.github/workflows/ctest.yml index 03960f6c78f..2245b5753bb 100644 --- a/.github/workflows/ctest.yml +++ b/.github/workflows/ctest.yml @@ -229,6 +229,178 @@ jobs: path: ${{ runner.workspace }}/buildmsi/${{ steps.set-file-base.outputs.FILE_BASE }}-win-vs2022_cl.msi if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + build_and_test_win_arm64: + # Windows ARM64 w/ MSVC (Native) + # + name: "Windows MSVC ARM64 CTest" + runs-on: windows-11-arm + needs: [check-secret] + steps: + - name: Install Dependencies (Windows ARM64) + run: choco install ninja + + - name: Get Sources + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + + - name: Setup Doxygen + uses: ./.github/actions/setup-doxygen + + - name: Enable Developer Command Prompt + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + with: + arch: arm64 + + - name: Install CMake + uses: lukka/get-cmake@9e07ecdcee1b12e5037e42f410b67f03e2f626e1 # latest + with: + cmakeVersion: ${{ inputs.cmake_version }} + ninjaVersion: latest + + - name: Check CMake Version + shell: bash + run: | + which cmake + cmake --version + + - name: Set up JDK 21 + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 + with: + java-version: '21' + distribution: 'temurin' + architecture: 'aarch64' + + - name: Set environment for MSVC ARM64 (Windows) + run: | + echo "CXX=cl.exe" >> $GITHUB_ENV + echo "CC=cl.exe" >> $GITHUB_ENV + shell: bash + + - name: Set file base name (Windows ARM64) + id: set-file-base + run: | + FILE_NAME_BASE=$(echo "${{ inputs.file_base }}") + echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT + if [[ '${{ inputs.use_environ }}' == 'release' ]] + then + SOURCE_NAME_BASE=$(echo "${{ inputs.snap_name }}") + else + SOURCE_NAME_BASE=$(echo "hdfsrc") + fi + echo "SOURCE_BASE=$SOURCE_NAME_BASE" >> $GITHUB_OUTPUT + shell: bash + + # Get files created by release script + - name: Get zip-tarball (Windows ARM64) + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v6 + with: + name: zip-tarball + path: ${{ github.workspace }} + + - name: using powershell + shell: pwsh + run: Get-Location + + - name: List files for the space (Windows ARM64) + run: | + Get-ChildItem -Path ${{ github.workspace }} + Get-ChildItem -Path ${{ runner.workspace }} + shell: pwsh + + - name: Uncompress source (Windows ARM64) + working-directory: ${{ github.workspace }} + run: 7z x ${{ steps.set-file-base.outputs.FILE_BASE }}.zip + shell: bash + + - name: Install TrustedSigning (Windows ARM64) + run: | + Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile .\nuget.exe + .\nuget.exe install Microsoft.Windows.SDK.BuildTools -Version 10.0.22621.3233 -x + .\nuget.exe install Microsoft.Trusted.Signing.Client -Version 1.0.86 -x + shell: pwsh + if: ${{ needs.check-secret.outputs.sign-state == 'exists' }} + + - name: create-json + id: create-json + uses: jsdaniell/create-json@b8e77fa01397ca39cc4a6198cc29a3be5481afef # v1.2.3 + with: + name: "credentials.json" + dir: '${{ steps.set-file-base.outputs.SOURCE_BASE }}' + json: '{"Endpoint": "${{ secrets.AZURE_ENDPOINT }}","CodeSigningAccountName": "${{ secrets.AZURE_CODE_SIGNING_NAME }}","CertificateProfileName": "${{ secrets.AZURE_CERT_PROFILE_NAME }}"}' + if: ${{ needs.check-secret.outputs.sign-state == 'exists' }} + + - name: Install WiX v3.14 + run: | + Invoke-WebRequest -Uri https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip -OutFile wix314-binaries.zip + Expand-Archive -Path wix314-binaries.zip -DestinationPath C:\wix314 + echo "C:\wix314" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "WIX=C:\wix314" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh + + - name: Run CTest (Windows ARM64) + env: + BINSIGN: ${{ needs.check-secret.outputs.sign-state }} + SIGNTOOLDIR: ${{ github.workspace }}/Microsoft.Windows.SDK.BuildTools/bin/10.0.22621.0/arm64 + run: | + cd "${{ runner.workspace }}/hdf5/${{ steps.set-file-base.outputs.SOURCE_BASE }}" + cmake --workflow --preset=${{ inputs.preset_name }}-MSVC-ARM64 --fresh + shell: bash + + - name: Sign files with Trusted Signing + uses: azure/trusted-signing-action@1d365fec12862c4aa68fcac418143d73f0cea293 # v0.5.11 + with: + azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} + azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} + azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} + endpoint: ${{ secrets.AZURE_ENDPOINT }} + trusted-signing-account-name: ${{ secrets.AZURE_CODE_SIGNING_NAME }} + certificate-profile-name: ${{ secrets.AZURE_CERT_PROFILE_NAME }} + files-folder: ${{ runner.workspace }}/hdf5/build/${{ inputs.preset_name }}-MSVC-ARM64 + files-folder-filter: msi + file-digest: SHA256 + timestamp-rfc3161: http://timestamp.acs.microsoft.com + timestamp-digest: SHA256 + if: ${{ needs.check-secret.outputs.sign-state == 'exists' }} + + - name: Publish binary (Windows ARM64) + id: publish-ctest-binary + run: | + mkdir "${{ runner.workspace }}/build" + mkdir "${{ runner.workspace }}/build/hdf5" + Copy-Item -Path ${{ runner.workspace }}/hdf5/${{ steps.set-file-base.outputs.SOURCE_BASE }}/LICENSE -Destination ${{ runner.workspace }}/build/hdf5/ + Copy-Item -Path ${{ runner.workspace }}/hdf5/build/${{ inputs.preset_name }}-MSVC-ARM64/README.md -Destination ${{ runner.workspace }}/build/hdf5/ + Copy-Item -Path ${{ runner.workspace }}/hdf5/build/${{ inputs.preset_name }}-MSVC-ARM64/* -Destination ${{ runner.workspace }}/build/hdf5/ -Include *.zip + cd "${{ runner.workspace }}/build" + 7z a -tzip ${{ steps.set-file-base.outputs.FILE_BASE }}-win-vs2022_cl_arm64.zip hdf5 + shell: pwsh + + - name: Publish msi binary (Windows ARM64) + id: publish-ctest-msi-binary + run: | + mkdir "${{ runner.workspace }}/buildmsi" + Copy-Item -Path ${{ runner.workspace }}/hdf5/build/${{ inputs.preset_name }}-MSVC-ARM64/* -Destination ${{ runner.workspace }}/buildmsi/${{ steps.set-file-base.outputs.FILE_BASE }}-win-vs2022_cl_arm64.msi -Include *.msi + shell: pwsh + + - name: List files in the space (Windows ARM64) + run: | + Get-ChildItem -Path ${{ github.workspace }} + Get-ChildItem -Path ${{ runner.workspace }} + shell: pwsh + + # Save files created by CTest script + - name: Save published binary (Windows ARM64) + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v5 + with: + name: zip-vs2022_cl_arm64-binary + path: ${{ runner.workspace }}/build/${{ steps.set-file-base.outputs.FILE_BASE }}-win-vs2022_cl_arm64.zip + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + + - name: Save published msi binary (Windows ARM64) + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v5 + with: + name: msi-vs2022_cl_arm64-binary + path: ${{ runner.workspace }}/buildmsi/${{ steps.set-file-base.outputs.FILE_BASE }}-win-vs2022_cl_arm64.msi + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + build_and_test_linux: # Linux (Ubuntu) w/ gcc # @@ -959,4 +1131,4 @@ jobs: with: name: tgz-ubuntu-2404_intel-binary path: ${{ runner.workspace }}/build/${{ steps.set-file-base.outputs.FILE_BASE }}-ubuntu-2404_intel.tar.gz - if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` \ No newline at end of file diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml index 7bb3a07f794..7cef086e37a 100644 --- a/.github/workflows/msys2.yml +++ b/.github/workflows/msys2.yml @@ -20,7 +20,7 @@ jobs: Build_and_test: # The type of runner that the job will run on - runs-on: windows-latest + runs-on: ${{ matrix.sys == 'clangarm64' && 'windows-11-arm' || 'windows-latest' }} strategy: matrix: include: @@ -28,6 +28,7 @@ jobs: - { icon: '🟦', sys: mingw64 } - { icon: '🟨', sys: ucrt64 } - { icon: '🟧', sys: clang64 } + - { icon: '🟪', sys: clangarm64 } name: ${{ matrix.icon }} MSYS2-${{ matrix.sys }}-${{ inputs.build_mode }} defaults: run: diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index 861e9c207c7..b44c8920627 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -299,6 +299,9 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) else () set (CPACK_PACKAGE_VERSION "${HDF5_PACKAGE_VERSION}") endif () + if (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64") + set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-winarm64") + endif () set (CPACK_PACKAGE_VERSION_MAJOR "${HDF5_PACKAGE_VERSION_MAJOR}") set (CPACK_PACKAGE_VERSION_MINOR "${HDF5_PACKAGE_VERSION_MINOR}") set (CPACK_PACKAGE_VERSION_PATCH "") diff --git a/CMakePresets.json b/CMakePresets.json index a80d24a0ea6..da49d765bf1 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -346,6 +346,16 @@ "ci-StdShar" ] }, + { + "name": "ci-StdShar-MSVC-ARM64", + "description": "MSVC Standard Config for ARM64 (Release)", + "inherits": [ + "ci-arm64-Release-MSVC", + "ci-CPP", + "ci-Java", + "ci-StdShar" + ] + }, { "name": "ci-StdShar-MSVC-FFM", "description": "MSVC Standard Config for x64 with Java FFM (Requires Java 25+) (Release)", @@ -664,6 +674,14 @@ "ci-x64-Release-MSVC" ] }, + { + "name": "ci-StdShar-MSVC-ARM64", + "description": "MSVC Standard Build for ARM64 (Release)", + "configurePreset": "ci-StdShar-MSVC-ARM64", + "inherits": [ + "ci-arm64-Release-MSVC" + ] + }, { "name": "ci-StdShar-MSVC-FFM", "description": "MSVC Standard Build for x64 with Java FFM (Requires Java 25+) (Release)", @@ -938,6 +956,13 @@ "ci-x64-Release-MSVC" ] }, + { + "name": "ci-StdShar-MSVC-ARM64", + "configurePreset": "ci-StdShar-MSVC-ARM64", + "inherits": [ + "ci-arm64-Release-MSVC" + ] + }, { "name": "ci-StdShar-MSVC-FFM", "configurePreset": "ci-StdShar-MSVC-FFM", @@ -1189,6 +1214,11 @@ "configurePreset": "ci-StdShar-MSVC", "inherits": "ci-x64-Release-MSVC" }, + { + "name": "ci-StdShar-MSVC-ARM64", + "configurePreset": "ci-StdShar-MSVC-ARM64", + "inherits": "ci-arm64-Release-MSVC" + }, { "name": "ci-StdShar-MSVC-FFM", "configurePreset": "ci-StdShar-MSVC-FFM", @@ -1332,6 +1362,27 @@ } ] }, + { + "name": "ci-StdShar-MSVC-ARM64", + "steps": [ + { + "type": "configure", + "name": "ci-StdShar-MSVC-ARM64" + }, + { + "type": "build", + "name": "ci-StdShar-MSVC-ARM64" + }, + { + "type": "test", + "name": "ci-StdShar-MSVC-ARM64" + }, + { + "type": "package", + "name": "ci-StdShar-MSVC-ARM64" + } + ] + }, { "name": "ci-StdShar-MSVC-FFM", "steps": [ diff --git a/config/cmake-presets/hidden-presets.json b/config/cmake-presets/hidden-presets.json index f453ec30699..c36c27a1335 100644 --- a/config/cmake-presets/hidden-presets.json +++ b/config/cmake-presets/hidden-presets.json @@ -167,6 +167,28 @@ "ci-MSVC" ] }, + { + "name": "ci-arm64-Debug-MSVC", + "description": "MSVC for ARM64 (Debug)", + "hidden": true, + "inherits": [ + "ci-base", + "ci-arm64", + "ci-Debug", + "ci-MSVC" + ] + }, + { + "name": "ci-arm64-Release-MSVC", + "description": "MSVC for ARM64 (Release)", + "hidden": true, + "inherits": [ + "ci-base", + "ci-arm64", + "ci-Release", + "ci-MSVC" + ] + }, { "name": "ci-x64-Debug-Clang", "description": "Clang/LLVM for x64 (Debug)", @@ -350,6 +372,24 @@ ], "configuration": "RelWithDebInfo" }, + { + "name": "ci-arm64-Debug-MSVC", + "configurePreset": "ci-arm64-Debug-MSVC", + "hidden": true, + "inherits": [ + "ci-base" + ], + "configuration": "Debug" + }, + { + "name": "ci-arm64-Release-MSVC", + "configurePreset": "ci-arm64-Release-MSVC", + "hidden": true, + "inherits": [ + "ci-base" + ], + "configuration": "RelWithDebInfo" + }, { "name": "ci-x64-Debug-Clang", "configurePreset": "ci-x64-Debug-Clang", @@ -507,6 +547,24 @@ ], "configuration": "RelWithDebInfo" }, + { + "name": "ci-arm64-Debug-MSVC", + "configurePreset": "ci-arm64-Debug-MSVC", + "hidden": true, + "inherits": [ + "ci-base" + ], + "configuration": "Debug" + }, + { + "name": "ci-arm64-Release-MSVC", + "configurePreset": "ci-arm64-Release-MSVC", + "hidden": true, + "inherits": [ + "ci-base" + ], + "configuration": "RelWithDebInfo" + }, { "name": "ci-x64-Debug-Clang", "configurePreset": "ci-x64-Debug-Clang", @@ -642,6 +700,13 @@ "inherits": "ci-base", "configurations": ["RelWithDebInfo"] }, + { + "name": "ci-arm64-Release-MSVC", + "configurePreset": "ci-arm64-Release-MSVC", + "hidden": true, + "inherits": "ci-base", + "configurations": ["RelWithDebInfo"] + }, { "name": "ci-x64-Release-Clang", "configurePreset": "ci-x64-Release-Clang", diff --git a/config/cmake/ZLIB/CMakeLists.txt b/config/cmake/ZLIB/CMakeLists.txt index c41db31deec..a8e350f0026 100644 --- a/config/cmake/ZLIB/CMakeLists.txt +++ b/config/cmake/ZLIB/CMakeLists.txt @@ -179,9 +179,13 @@ target_include_directories(${ZLIB_LIB_TARGET} PRIVATE "${CMAKE_BINARY_DIR}" PUBLIC "${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}" ) -if (MSVC AND CMAKE_CL_64) - set_target_properties (${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64") -endif () +if (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) + if (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64") + set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:ARM64") + else() + set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64") + endif() +endif() set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES PUBLIC_HEADER "" LINKER_LANGUAGE C diff --git a/config/cmake/ZLIB/devCMakeLists.txt b/config/cmake/ZLIB/devCMakeLists.txt index 3be9fafeded..41049723d22 100644 --- a/config/cmake/ZLIB/devCMakeLists.txt +++ b/config/cmake/ZLIB/devCMakeLists.txt @@ -246,9 +246,13 @@ target_include_directories(${ZLIB_LIB_TARGET} PRIVATE "${CMAKE_BINARY_DIR}" PUBLIC "${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}" ) -if (MSVC AND CMAKE_CL_64) - set_target_properties (${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64") -endif () +if (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) + if (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64") + set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:ARM64") + else() + set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64") + endif() +endif() set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES PUBLIC_HEADER "" LINKER_LANGUAGE C