From db9a6a161482e2d910958d315f2c0dae8cace2f6 Mon Sep 17 00:00:00 2001 From: Nikhil Dabas Date: Fri, 2 Oct 2026 11:51:20 +0100 Subject: [PATCH 1/2] Fix OpenBLASConfig.cmake for Windows targets --- Makefile.install | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Makefile.install b/Makefile.install index f09d1f0631..00f19679ea 100644 --- a/Makefile.install +++ b/Makefile.install @@ -37,10 +37,10 @@ PKGFILE := $(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/$(LIBSONAMEBASE)$(SUFFIX64).pc ifeq ($(USE_OPENMP), 1) ifeq ($(C_COMPILER), PGI) PKG_EXTRALIB += -lomp - else + else PKG_EXTRALIB += -lgomp endif -endif +endif .PHONY : install .NOTPARALLEL : install @@ -235,12 +235,19 @@ endif ifeq ($(OSNAME), Darwin) @echo "SET(OpenBLAS_LIBRARIES \$${_OpenBLAS_ROOT_DIR}/lib/$(LIBPREFIX).dylib)" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" endif - @echo "add_library(OpenBLAS::OpenBLAS SHARED IMPORTED)" - @echo "target_include_directories(OpenBLAS::OpenBLAS INTERFACE \$${OpenBLAS_INCLUDE_DIRS})" + @echo "if (NOT TARGET OpenBLAS::OpenBLAS)" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" + @echo " add_library(OpenBLAS::OpenBLAS SHARED IMPORTED)" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" + @echo " target_include_directories(OpenBLAS::OpenBLAS INTERFACE \$${OpenBLAS_INCLUDE_DIRS})" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" + @echo " set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_LOCATION \$${OpenBLAS_LIBRARIES})" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" ifeq ($(OSNAME), $(filter $(OSNAME),WINNT CYGWIN_NT)) - @echo "set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_LOCATION \$${OpenBLAS_LIBRARIES})" - @echo "set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB \$${_OpenBLAS_ROOT_DIR}/lib/libopenblas.lib)" -endif +# prefer an MSVC import library if one was added to the install tree, else use the MinGW one + @echo " if (EXISTS \"\$${_OpenBLAS_ROOT_DIR}/lib/lib$(LIBNAMEBASE).lib\")" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" + @echo " set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB \$${_OpenBLAS_ROOT_DIR}/lib/lib$(LIBNAMEBASE).lib)" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" + @echo " else ()" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" + @echo " set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB \$${_OpenBLAS_ROOT_DIR}/lib/$(IMPLIBNAME))" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" + @echo " endif ()" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" +endif + @echo "endif ()" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" else #only static @echo "SET(OpenBLAS_LIBRARIES \$${_OpenBLAS_ROOT_DIR}/lib/$(LIBPREFIX).$(LIBSUFFIX))" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" From 40b07ccfddef3139fa8cbff4b4069d19976595eb Mon Sep 17 00:00:00 2001 From: Nikhil Dabas Date: Fri, 2 Oct 2026 16:41:27 +0100 Subject: [PATCH 2/2] Improve Windows ARM64 workflow --- .github/workflows/windows_arm64.yml | 80 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/.github/workflows/windows_arm64.yml b/.github/workflows/windows_arm64.yml index f0a709790c..9d2c4265e8 100644 --- a/.github/workflows/windows_arm64.yml +++ b/.github/workflows/windows_arm64.yml @@ -29,62 +29,60 @@ jobs: - name: Checkout repository uses: actions/checkout@v6 - - name: Install LLVM for Win-ARM64 + # The runner's preinstalled LLVM archive has no flang; the official installer does + - name: Install LLVM with flang shell: pwsh run: | - Invoke-WebRequest https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.8/LLVM-20.1.8-woa64.exe -UseBasicParsing -OutFile LLVM-woa64.exe - Start-Process -FilePath ".\LLVM-woa64.exe" -ArgumentList "/S" -Wait - echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - #dir "C:\Program Files\LLVM\include\flang" - #rmdir /Q /S "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/ARM64" - - - name: Install CMake and Ninja for Win-ARM64 + $version = '22.1.8' + Invoke-WebRequest "https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/LLVM-$version-woa64.exe" -OutFile LLVM-woa64.exe + $proc = Start-Process -FilePath .\LLVM-woa64.exe -ArgumentList '/S', '/D=C:\LLVM' -Wait -PassThru + if ($proc.ExitCode) { throw "LLVM installer failed with exit code $($proc.ExitCode)" } + + - name: Set up Visual Studio environment shell: pwsh run: | - Invoke-WebRequest https://github.com/Kitware/CMake/releases/download/v3.29.4/cmake-3.29.4-windows-arm64.msi -OutFile cmake-arm64.msi - Start-Process msiexec.exe -ArgumentList "/i cmake-arm64.msi /quiet /norestart" -Wait - echo "C:\Program Files\CMake\bin" >> $env:GITHUB_PATH - - Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-winarm64.zip -OutFile ninja-winarm64.zip - Expand-Archive ninja-winarm64.zip -DestinationPath ninja - Copy-Item ninja\ninja.exe -Destination "C:\Windows\System32" + $vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * ` + -requires Microsoft.VisualStudio.Component.VC.Tools.ARM64 -property installationPath + if (-not $vsPath) { throw "No Visual Studio installation with ARM64 C++ tools found" } + + $before = @{} + Get-ChildItem env: | ForEach-Object { $before[$_.Name] = $_.Value } + & "$vsPath\Common7\Tools\Launch-VsDevShell.ps1" -Arch arm64 -HostArch arm64 -SkipAutomaticLocation + # VS ships its own LLVM (with an incomplete flang); ours must come first + $llvmBin = 'C:\LLVM\bin' + foreach ($tool in 'clang-cl.exe', 'flang.exe') { + if (-not (Test-Path "$llvmBin\$tool")) { throw "$tool not found in $llvmBin" } + } + $env:PATH = "$llvmBin;$env:PATH" + + Get-ChildItem env: | Where-Object { $before[$_.Name] -cne $_.Value } | + ForEach-Object { "$($_.Name)=$($_.Value)" } >> $env:GITHUB_ENV - name: Configure OpenBLAS - shell: cmd + shell: pwsh run: | - CALL "C:\Program Files\Microsoft Visual Studio\18\Enterprise\VC\Auxiliary\Build\vcvarsarm64.bat" - set PATH=C:\Program Files\LLVM\bin;%PATH% - - mkdir build - cd build - cmake .. -G Ninja ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DTARGET=ARMV8 ^ - -DBINARY=64 ^ - -DCMAKE_C_COMPILER=clang-cl ^ - -DCMAKE_Fortran_COMPILER=flang-new ^ - -DBUILD_SHARED_LIBS=ON ^ - -DCMAKE_SYSTEM_PROCESSOR=arm64 ^ - -DCMAKE_SYSTEM_NAME=Windows ^ + cmake -S . -B build -G Ninja ` + -DCMAKE_BUILD_TYPE=Release ` + -DTARGET=ARMV8 ` + -DBINARY=64 ` + -DCMAKE_C_COMPILER=C:/LLVM/bin/clang-cl.exe ` + -DCMAKE_Fortran_COMPILER=C:/LLVM/bin/flang.exe ` + -DBUILD_SHARED_LIBS=ON ` + -DCMAKE_SYSTEM_PROCESSOR=arm64 ` + -DCMAKE_SYSTEM_NAME=Windows ` -DCMAKE_INSTALL_PREFIX=C:/opt - name: Build OpenBLAS - shell: cmd - run: | - cd build - ninja -j16 + shell: pwsh + run: cmake --build build -j16 - name: Install OpenBLAS - shell: cmd - run: | - cd build - cmake --install . + shell: pwsh + run: cmake --install build - - name: Run ctests + - name: Run ctests shell: pwsh run: | $env:PATH = "C:\opt\bin;$env:PATH" cd build ctest - -