diff --git a/.github/workflows/posix.yml b/.github/workflows/posix.yml index 6d4fe64..1bae4cc 100644 --- a/.github/workflows/posix.yml +++ b/.github/workflows/posix.yml @@ -1,3 +1,6 @@ +Break the workflow to not waste resources + + name: posix on: diff --git a/.github/workflows/windows-arm.yml b/.github/workflows/windows-arm.yml deleted file mode 100644 index 01c66e2..0000000 --- a/.github/workflows/windows-arm.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: Windows-on-ARM - -on: - push: - branches: [ main ] - pull_request: - branches: - - main - - maintenance/** - -env: - OPENBLAS_ROOT: "c:\\opt" - # Preserve working directory for calls into bash - # Without this, invoking bash will cd to the home directory - CHERE_INVOKING: "yes" - BASH_PATH: "C:\\Program Files\\Git\\bin\\bash.exe" - PLAT: arm64 - -jobs: - build: - runs-on: windows-11-arm - timeout-minutes: 90 - - strategy: - matrix: - INTERFACE64: ['1', '0'] - - env: - INTERFACE64: ${{ matrix.INTERFACE64 }} - - steps: - - - uses: actions/checkout@v4.1.1 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - architecture: arm64 - - - name: Download and install LLVM installer - 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 - - - name: Install CMake and Ninja for Win-ARM64 - 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" - - - name: Set env variables - run: | - if ( ${{ matrix.INTERFACE64 }} -eq "1" ) { - echo "INTERFACE_BITS=64" >> $env:GITHUB_ENV - } else { - echo "INTERFACE_BITS=32" >> $env:GITHUB_ENV - } - - - name: Build - run: | - git submodule update --init --recursive - .\tools\build_steps_win_arm64.bat 64 ${env:INTERFACE_BITS} - - - name: Test ${{ matrix.INTERFACE_BITS }}-bit interface wheel - run: | - python -m pip install --no-index --find-links dist scipy_openblas${env:INTERFACE_BITS} - python -m scipy_openblas${env:INTERFACE_BITS} - python -c "import scipy_openblas${env:INTERFACE_BITS}; print(scipy_openblas${env:INTERFACE_BITS}.get_pkg_config())" - - - uses: actions/upload-artifact@v4.3.0 - with: - name: wheels-${{ env.PLAT }}-${{ env.INTERFACE64 }} - path: dist/scipy_openblas*.whl - - - name: Install Anaconda client - run: | - # Rust installation needed for rpds-py. - Invoke-WebRequest https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe -UseBasicParsing -Outfile rustup-init.exe - .\rustup-init.exe -y - $env:PATH="$env:PATH;$env:USERPROFILE\.cargo\bin" - pip install anaconda-client - - - name: Upload - # see https://github.com/marketplace/actions/setup-miniconda for why - # `-el {0}` is required. - shell: bash -el {0} - env: - ANACONDA_SCIENTIFIC_PYTHON_UPLOAD: ${{ secrets.ANACONDA_SCIENTIFIC_PYTHON_UPLOAD }} - run: | - source tools/upload_to_anaconda_staging.sh - upload_wheels diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c2b3460..89b0c79 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -10,7 +10,6 @@ on: workflow_dispatch: null env: - OPENBLAS_ROOT: "c:\\opt" # Preserve working directory for calls into bash # Without this, invoking bash will cd to the home directory CHERE_INVOKING: "yes" @@ -20,22 +19,51 @@ jobs: build: strategy: matrix: - plat: ['x64', 'x86'] - INTERFACE64: ['1', '0'] - os: [windows-latest] - exclude: - - plat: x86 - INTERFACE64: '1' + include: + - { os: windows-latest, PLAT: x86, INTERFACE64: '0'} + - { os: windows-latest, PLAT: x64, INTERFACE64: '0'} + - { os: windows-latest, PLAT: x64, INTERFACE64: '1'} + - { os: windows-11-arm, PLAT: arm64, INTERFACE64: '0'} + - { os: windows-11-arm, PLAT: arm64, INTERFACE64: '1'} fail-fast: false runs-on: ${{ matrix.os }} timeout-minutes: 90 steps: - uses: actions/checkout@v4.1.1 - - name: install-rtools + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + architecture: ${{ matrix.plat }} + + - name: Setup conda + # No conda for arm64 + if: matrix.os == 'windows-latest' + uses: conda-incubator/setup-miniconda@v3.1.1 + with: + channels: conda-forge + channel-priority: true + activate-environment: openblas + miniforge-version: latest + + - name: Install compilers and python from conda + # No conda for arm64 + if: matrix.os == 'windows-latest' + shell: bash -el {0} + run: conda install compilers python==3.11 cmake ninja anaconda-client + + - name: Download and install LLVM (arm64) and other tools + if: matrix.os == 'windows-11-arm' + shell: pwsh run: | - # rtools 42+ does not support 32 bits builds. - choco install -y rtools --no-progress --force --version=4.0.0.20220206 + Invoke-WebRequest https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.0/LLVM-21.1.0-woa64.exe -UseBasicParsing -OutFile LLVM-woa64.exe + Start-Process -FilePath ".\LLVM-woa64.exe" -ArgumentList "/S" -Wait + Invoke-WebRequest https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe -UseBasicParsing -Outfile rustup-init.exe + $env:PATH="$env:PATH;$env:USERPROFILE\.cargo\bin" + pip install anaconda-client + python -m pip install cmake ninja - name: Set env variables run: | @@ -56,6 +84,9 @@ jobs: echo "LDFLAGS=-lucrt -static -static-libgcc -Wl,--defsym,quadmath_snprintf=snprintf" >> $env:GITHUB_ENV echo "BUILD_BITS=64" >> $env:GITHUB_ENV } + if ( "${{ matrix.plat }}" -eq "arm64") { + echo "PLAT=arm64" >> $env:GITHUB_ENV + } if ( ${{ matrix.INTERFACE64 }} -eq "1" ) { echo "INTERFACE64=1" >> $env:GITHUB_ENV } @@ -68,36 +99,29 @@ jobs: echo CIBW_ENVIRONMENT_WINDOWS=$env:CIBW_ENVIRONMENT_WINDOWS - name: Build - run: | - git submodule update --init --recursive - & $env:BASH_PATH -lc tools/build_steps_windows.sh + shell: bash -el {0} + run: tools/build_steps_windows.sh - name: Test + shell: bash run: | - & $env:BASH_PATH -lc tools/build_gfortran.sh + bash -lc tools/build_gfortran.sh echo "Static test" - .\for_test\test.exe + ./for_test/test.exe echo "Dynamic test" - .\for_test\test_dyn.exe + ./for_test/test_dyn.exe - name: Copy run: | cp for_test\test*.exe builds - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.9 - architecture: ${{ matrix.plat }} - - - name: Build wheel shell: bash run: | set -xeo pipefail python -m pip install wheel # This will fail if there is more than one file in libs - unzip -d local/scipy_openblas64 builds/openblas*.zip + unzip -d local/scipy_openblas64 builds/openblas.zip if [[ -d local/scipy_openblas64/64 ]]; then mv local/scipy_openblas64/64/* local/scipy_openblas64 else @@ -140,12 +164,6 @@ jobs: for f in dist/*.whl; do mv $f "${f/%any.whl/$WHEEL_PLAT.whl}"; done fi - - name: Set up different Python - uses: actions/setup-python@v5 - with: - python-version: 3.11 - architecture: ${{ matrix.plat }} - - uses: actions/upload-artifact@v4.3.0 with: name: wheels-${{matrix.plat }}-${{ matrix.INTERFACE64 }} @@ -169,13 +187,6 @@ jobs: python -m pip install pkgconf python -m pkgconf scipy-openblas --cflags - - uses: conda-incubator/setup-miniconda@v3.1.1 - with: - channels: conda-forge - channel-priority: true - activate-environment: upload - miniforge-version: latest - - name: Upload # see https://github.com/marketplace/actions/setup-miniconda for why # `-el {0}` is required. diff --git a/pyproject.toml b/pyproject.toml index 9922c2c..7da6cee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta" [project] name = "scipy-openblas64" # v0.3.30-359-g29fab2b9 -version = "0.3.30.359.2" +version = "0.3.30.359.3" requires-python = ">=3.7" description = "Provides OpenBLAS for python packaging" readme = "README.md" diff --git a/tools/build_steps_win_arm64.bat b/tools/build_steps_win_arm64.bat deleted file mode 100755 index 9b78ce0..0000000 --- a/tools/build_steps_win_arm64.bat +++ /dev/null @@ -1,242 +0,0 @@ -:: Build script for scipy_openblas wheel on Windows on ARM64 - -:: Usage: build_steps_win_arm64.bat [build_bits] [if_bits] -:: e.g build_steps_win_arm64.bat 64 64 - -:: build_bits (default binary architecture, 32 or 64, unspec -> 64). -:: if_bits (default interface size, 32 or 64, unspec -> 32) -:: If INTERFACE64 environment variable is 1, then if_bits defaults to 64 -:: Expects these binaries on the PATH: -:: clang-cl, flang-new, cmake, perl -:: First commit containing WoA build fixes. -:: Minimum OpenBLAS commit to build; we'll update to this if commit not -:: present. -set first_woa_buildable_commit="de2380e5a6149706a633322a16a0f66faa5591fc" - -@echo off -setlocal enabledelayedexpansion - -if "%1"=="" ( - set build_bits=64 -) else ( - set build_bits=%1 -) -if "%INTERFACE64%"=="1" ( - set "if_default=64" -) else ( - set "if_default=32" -) -if "%2"=="" ( - set "if_bits=%if_default%" -) else ( - set "if_bits=%2" -) -echo Building for %build_bits%-bit binary, %if_bits%-bit interface... - -:: Define destination directory -pushd "%~dp0\.." -set "ob_out_root=%CD%\local\scipy_openblas" -set "ob_64=%ob_out_root%64" -set "ob_32=%ob_out_root%32" -set "local_dir=%CD%\local" -for /d %%D in ("%local_dir%\*") do ( - if /I not "%%~nxD"=="scipy_openblas64" ( - rmdir /S /Q "%%D" - ) -) -if "%if_bits%"=="64" ( - set "DEST_DIR=%ob_64%" -) else ( - if exist "%ob_64%" ( - xcopy /Y /H "%ob_64%\*.py" "%CD%\ob64_backup\" - move "%ob_64%" "%ob_32%" - set "DEST_DIR=%ob_32%" - ) -) - -:: Clone OpenBLAS -echo Cloning OpenBLAS repository with submodules... -git submodule update --init --recursive OpenBLAS -if errorlevel 1 exit /b 1 -set /p OPENBLAS_COMMIT=NUL -if errorlevel 1 ( - echo OpenBLAS commit does not contain WoA build fixes. - echo Commit needs to contain %first_woa_buildable_commit%. - exit /b 2 -) - -:: Patch -for /r %%f in (..\patches\*) do git apply %%f -if errorlevel 1 exit /b 1 - -:: Set suffixed-ILP64 flags -if "%if_bits%"=="64" ( - set "interface_flags=-DINTERFACE64=1 -DSYMBOLSUFFIX=64_" -) else ( - set "interface_flags=" -) - -:: Create build directory and navigate to it -if exist build (rmdir /S /Q build || exit /b 1) -mkdir build || exit /b 1 & cd build || exit /b 1 - -echo Setting up ARM64 Developer Command Prompt and running CMake... - -:: Initialize VS ARM64 environment -CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsarm64.bat" - -:: Prefer LLVM flang -PATH=C:\Program Files\LLVM\bin;%PATH% - -:: Run CMake and Ninja build - -set CFLAGS=-Wno-reserved-macro-identifier -Wno-unsafe-buffer-usage -Wno-unused-macros -Wno-sign-conversion -Wno-reserved-identifier -cmake .. -G Ninja ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DTARGET=ARMV8 ^ - -DBINARY=%build_bits% ^ - -DCMAKE_C_COMPILER=clang-cl ^ - -DCMAKE_Fortran_COMPILER=flang-new ^ - -DBUILD_SHARED_LIBS=ON ^ - -DCMAKE_SYSTEM_PROCESSOR=arm64 ^ - -DCMAKE_SYSTEM_NAME=Windows ^ - -DSYMBOLPREFIX="scipy_" ^ - -DLIBNAMEPREFIX="scipy_" ^ - -DUSE_THREADS=1 ^ - -DNUM_THREADS=24 ^ - %interface_flags% - -if errorlevel 1 exit /b 1 - -ninja -j 16 -if errorlevel 1 exit /b 1 - -echo Build complete. Returning to Batch. - -cd ../.. -if "%if_bits%"=="32" ( - echo Rewrite to scipy_openblas32 - set out_pyproject=pyproject_64_32.toml - powershell -Command "(Get-Content 'pyproject.toml') -replace 'openblas64', 'openblas32' | Set-Content !out_pyproject!" - cd local - move scipy_openblas64 scipy_openblas32 - powershell -Command "(Get-Content 'scipy_openblas32\__main__.py') -replace 'openblas64', 'openblas32' | Out-File 'scipy_openblas32\__main__.py' -Encoding utf8" - powershell -Command "(Get-Content 'scipy_openblas32\__init__.py') -replace 'openblas64', 'openblas32' | Out-File 'scipy_openblas32\__init__.py' -Encoding utf8" - powershell -Command "(Get-Content 'scipy_openblas32\__init__.py') -replace 'openblas_get_config64_', 'openblas_get_config' | Out-File 'scipy_openblas32\__init__.py' -Encoding utf8" - powershell -Command "(Get-Content 'scipy_openblas32\__init__.py') -replace 'cflags =.*', 'cflags = \"-DBLAS_SYMBOL_PREFIX=scipy_\"' | Out-File 'local\scipy_openblas32\__init__.py' -Encoding utf8" - cd .. -) - -:: Prepare destination directory -cd OpenBLAS/build -echo Preparing destination directory at %DEST_DIR% -if not exist "%DEST_DIR%\lib\cmake\OpenBLAS" mkdir "%DEST_DIR%\lib\cmake\OpenBLAS" -if not exist "%DEST_DIR%\include" mkdir "%DEST_DIR%\include" - -:: Move library files -echo Moving library files... -if exist lib\release ( - move /Y lib\release\*.dll "%DEST_DIR%\lib\" - if errorlevel 1 exit /b 1 - for %%f in (lib\release\*.dll.a) do ( - set "orig_name=%%~nxf" - call set "base_name=%%orig_name:.dll.a=%%" - move /Y "%%f" "%DEST_DIR%\lib\!base_name!.lib" - ) - if errorlevel 1 exit /b 1 -) else ( - echo Error: lib/release directory not found! - exit /b 1 -) - -:: Copy CMake configuration files -echo Copying CMake configuration files... -if exist openblasconfig.cmake copy /Y openblasconfig.cmake "%DEST_DIR%\lib\cmake\openblas\" -if exist openblasconfigversion.cmake copy /Y openblasconfigversion.cmake "%DEST_DIR%\lib\cmake\openblas\" - -:: Copy header files -echo Copying generated header files... -if exist generated xcopy /E /Y generated "%DEST_DIR%\include\" -if exist lapacke_mangling.h copy /Y lapacke_mangling.h "%DEST_DIR%\include\" -if exist openblas_config.h copy /Y openblas_config.h "%DEST_DIR%\include\" - - -:: Copy LAPACKE header files -echo Copying LAPACKE header files... -xcopy /Y "..\lapack-netlib\lapacke\include\*.h" "%DEST_DIR%\include\" -if errorlevel 1 exit /b 1 - -echo Create pkgconfig scipy-openblas.pc -cd ../../local -if errorlevel 1 ( - echo Current directory %CD%, cannot cd ../../local - exit /b 1 -) -if "%if_bits%"=="32" ( - mkdir scipy_openblas32\lib\pkgconfig - python -c "import scipy_openblas32 as s; print(s.get_pkg_config(use_prefix=True))" > scipy_openblas32/lib/pkgconfig/scipy-openblas.pc -) else ( - mkdir scipy_openblas64\lib\pkgconfig - python -c "import scipy_openblas64 as s; print(s.get_pkg_config(use_prefix=True))" > scipy_openblas64/lib/pkgconfig/scipy-openblas.pc -) -if errorlevel 1 ( - echo could not construct scipy-openblas.pc - exit /b 1 -) - -:: Move back to the root directory -cd .. -if errorlevel 1 ( - echo Current directory %CD%, cannot cd .. - exit /b 1 -) - -:: Build the Wheel & Install It -echo Running 'python -m build' to build the wheel in %CD% -python -c "import build" 2>NUL || pip install build -if "%if_bits%"=="64" ( - python -m build - if errorlevel 1 exit /b 1 -) else ( - move /Y pyproject.toml pyproject.toml.bak - move /Y %out_pyproject% pyproject.toml - python -m build - if errorlevel 1 exit /b 1 - move /Y pyproject.toml.bak pyproject.toml -) -if "%if_bits%"=="32" ( - move /Y "%CD%\ob64_backup" "%ob_64%" -) - -:: Rename the wheel -for %%f in (dist\*any.whl) do ( - set WHEEL_FILE=dist\%%f - set "filename=%%~nxf" - set "newname=!filename:any.whl=win_arm64.whl!" - ren "dist\!filename!" "!newname!" -) - -:: Locate the built wheel -for /f %%f in ('dir /b dist\scipy_openblas*.whl 2^>nul') do set WHEEL_FILE=dist\%%f - -if not defined WHEEL_FILE ( - echo Error: No wheel file found in dist folder. - exit /b 1 -) - -echo Installing wheel: %WHEEL_FILE% -pip install "%WHEEL_FILE%" -if errorlevel 1 exit /b 1 - -echo Testing -python -m pip install pkgconf -python -m pkgconf scipy-openblas --cflags -if errorlevel 1 exit /b 1 - -echo Done. -exit /b 0 diff --git a/tools/build_steps_windows.sh b/tools/build_steps_windows.sh index 5ae3cc3..effb4a5 100644 --- a/tools/build_steps_windows.sh +++ b/tools/build_steps_windows.sh @@ -1,49 +1,26 @@ #!/bin/bash # Build script for OpenBLAS on Windows # -# Usage: build_steps_windows.sh [openblas_root [build_bits [if_bits]]] +# Uses the environment variables # -# e.g build_steps_windows.sh c:\\opt 64 32 -# -# Uses the optional environment variables. We always prefer command line argument -# values above to environment variable values: -# -# OPENBLAS_ROOT (default directory root for binaries, unspecified -> c:\opt). # BUILD_BITS (default binary architecture, 32 or 64, unspec -> 64). # INTERFACE64 (1 for 64-bit interface, anything else or undefined for 32, # This gives the default value if if_bits not specified above). # START_DIR (directory containing OpenBLAS source, unspec -> .. from here) # LDFLAGS (example: "-lucrt -static -static-libgcc") +# PLAT (x86_64 or arm64) # -# Expects at leasts these binaries on the PATH: -# realpath, cygpath, zip, gcc, make, ar, dlltool -# usually as part of an msys installation. +# Expects at leasts these binaries installed from conda-forge +# zip, clang-cl, flang-new cmake, ninja set -xe -# Convert to Unix-style path -openblas_root="$(cygpath ${1:-${OPENBLAS_ROOT:-c:\\opt}})" -build_bits="${2:-${BUILD_BITS:-64}}" +build_bits="${BUILD_BITS:-64}}" if [ "$INTERFACE64" == "1" ]; then if_default=64; else if_default=32; fi -if_bits=${3:-${if_default}} -# Our directory for later copying -if [ -z "$START_DIR" ]; then - our_wd="$(realpath $(dirname "${BASH_SOURCE[0]}")/..)" -else - our_wd=$(cygpath "$START_DIR") -fi - -echo "Building from $our_wd, to $openblas_root" +if_bits=${2:-${if_default}} echo "Binaries are $build_bits bit, interface is $if_bits bit" -echo "Using gcc at $(which gcc), --version:" -gcc --version - -# Make output directory for build artifacts -builds_dir="$our_wd/builds" -rm -rf $builds_dir -mkdir $builds_dir -cd "${our_wd}/OpenBLAS" +cd OpenBLAS git submodule update --init --recursive @@ -52,7 +29,6 @@ git fetch origin git checkout $(cat ../openblas_commit.txt) git clean -fxd git reset --hard -rm -rf $openblas_root/$build_bits # Set architecture flags if [ "$build_bits" == 64 ]; then @@ -62,6 +38,7 @@ if [ "$build_bits" == 64 ]; then vc_arch="X64" plat_tag="win_amd64" dynamic_list="PRESCOTT NEHALEM SANDYBRIDGE HASWELL SKYLAKEX" + target=PRESCOTT else march=pentium4 extra="-mfpmath=sse -msse2" @@ -69,14 +46,32 @@ else vc_arch="i386" plat_tag="win32" dynamic_list="PRESCOTT NEHALEM SANDYBRIDGE HASWELL" + target=PRESCOTT +fi +if [ "$PLAT" == "arm64" ]; then + CC=clang-cl + FC=flang-new + extra="-Wno-reserved-macro-identifier -Wno-unsafe-buffer-usage -Wno-unused-macros -Wno-sign-conversion -Wno-reserved-identifier" + march=arm64 + target=ARMV8 + # This is quite minimal, may need to add NOEVERSEN1 and more? + dynamic_list="ARMV8 CORTEXA57 NEOVERSEV1 THUNDERX" fi + +CC=clang-cl +FC=flang-new cflags="-O2 -march=$march -mtune=generic $extra" fflags="$fextra $cflags -frecursive -ffpe-summary=invalid,zero" +echo "using C compiler $(which $CC), --version:" +$CC --version +echo "using F compiler $(which $FC), --version:" +$FC --version + # Set suffixed-ILP64 flags if [ "$if_bits" == "64" ]; then LIBNAMESUFFIX="64_" - interface_flags="INTERFACE64=1 SYMBOLSUFFIX=64_ LIBNAMESUFFIX=64_" + interface_flags="-DINTERFACE64=1 -DSYMBOLSUFFIX=64_ -DLIBNAMESUFFIX=64_" # We override FCOMMON_OPT, so we need to set default integer manually fflags="$fflags -fdefault-integer-8" else @@ -84,7 +79,7 @@ else fi # On windows, the LIBNAMEPREFIX is not needed, SYMBOLPREFIX is added to the lib # name LIBPREFIX in Makefile.system. -interface_flags="$interface_flags SYMBOLPREFIX=scipy_ LIBNAMEPREFIX=scipy_ FIXED_LIBNAME=1" +interface_flags="$interface_flags -DSYMBOLPREFIX=scipy_ -DLIBNAMEPREFIX=scipy_ -DFIXED_LIBNAME=1" # Build name for output library from gcc version and OpenBLAS commit. GCC_TAG="gcc_$(gcc -dumpversion | tr .- _)" @@ -94,17 +89,34 @@ OPENBLAS_VERSION=$(git describe --tags --abbrev=8) # with libquadmath patch -p1 < ../patches-windows/openblas-make-libs.patch +mkdir build +cd build +cp "$(which llvm-mt.exe)" /llvm-mt.exe + # Build OpenBLAS -CFLAGS="$CFLAGS -fvisibility=protected -fno-ident" \ -make BINARY=$build_bits DYNAMIC_ARCH=1 USE_THREAD=1 USE_OPENMP=0 \ - NUM_THREADS=24 NO_WARMUP=1 NO_AFFINITY=1 CONSISTENT_FPCSR=1 \ - BUILD_LAPACK_DEPRECATED=1 TARGET=PRESCOTT BUFFERSIZE=20 \ - LDFLAGS="$LDFLAGS" \ - DYNAMIC_LIST="$dynamic_list" \ - COMMON_OPT="$cflags" \ - FCOMMON_OPT="$fflags" \ - MAX_STACK_ALLOC=2048 \ - $interface_flags +CFLAGS=$cflags +cmake .. -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DTARGET=$target \ + -DYNAMIC_ARCH=1 \ + -DYNAMIC_LIST="$dynamic_list" \ + -DBINARY=$build_bits \ + -DBUFFERSIZE=20 \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_Fortran_COMPILER=$FC \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_SYSTEM_PROCESSOR=$march \ + -DCMAKE_MT=D:/llvm-mt.exe \ + -DCMAKE_SYSTEM_NAME=Windows \ + -DSYMBOLPREFIX="scipy_" \ + -DLIBNAMEPREFIX="scipy_" \ + -DUSE_THREADS=1 \ + -DNUM_THREADS=24 \ + $interface_flags + +ninja -j 16 + +cd .. # Make sure quadmath library is not statically linked in to the DLL by checking # the output.map generated by the linker when using `-Wl,-gc-sections -Wl,-s` @@ -134,52 +146,14 @@ case $? in esac set -e -make PREFIX=$openblas_root/$build_bits $interface_flags install -DLL_BASENAME=libscipy_openblas${LIBNAMESUFFIX} -cp -f *.dll.a $openblas_root/$build_bits/lib/${DLL_BASENAME}.dll.a -# OpenBLAS does not build a symbol-suffixed static library on Windows: -# do it ourselves. On 32-bit builds, the objcopy.def names need a '_' prefix -static_libname=$(find . -maxdepth 1 -type f -name '*.a' \! -name '*.dll.a' | tail -1) -make -C exports $interface_flags objcopy.def - -if [ "$build_bits" == "32" ]; then - sed -i "s/^/_/" exports/objcopy.def - sed -i "s/scipy_/_scipy_/" exports/objcopy.def -else - echo not updating objcopy,def, buildbits=$build_bits -fi -echo "\nshow some of objcopy.def" -head -10 exports/objcopy.def -echo -objcopy --redefine-syms exports/objcopy.def "${static_libname}" "${static_libname}.renamed" -cp -f "${static_libname}.renamed" "$openblas_root/$build_bits/lib/${static_libname}" -cp -f "${static_libname}.renamed" "$openblas_root/$build_bits/lib/${DLL_BASENAME}.a" - -cd $openblas_root -# Copy library link file for custom name -pushd $build_bits/lib -cp ${our_wd}/OpenBLAS/exports/${DLL_BASENAME}.def ${DLL_BASENAME}.def -# At least for the mingwpy wheel, we have to use the VC tools to build the -# export library. Maybe fixed in later binutils by patch referred to in -# https://sourceware.org/ml/binutils/2016-02/msg00002.html -# "lib.exe" /machine:${vc_arch} /def:${DLL_BASENAME}.def -# Maybe this will now work (after 2016 patch above). -dlltool --input-def ${DLL_BASENAME}.def \ - --output-exp ${DLL_BASENAME}.exp \ - --dllname ${DLL_BASENAME}.dll \ - --output-lib ${DLL_BASENAME}.lib -# Replace the DLL name with the generated name. -sed -i "s/ -lopenblas.*$/ -l${DLL_BASENAME:3}/g" pkgconfig/openblas*.pc mv pkgconfig/*.pc pkgconfig/scipy-openblas.pc if [ "$if_bits" == "64" ]; then sed -e "s/^Cflags.*/\0 -DBLAS_SYMBOL_PREFIX=scipy_ -DBLAS_SYMBOL_SUFFIX=64_/" -i pkgconfig/scipy-openblas.pc else sed -e "s/^Cflags.*/\0 -DBLAS_SYMBOL_PREFIX=scipy_/" -i pkgconfig/scipy-openblas.pc fi -popd -ls $openblas_root/$build_bits/lib +ls build/lib -zip_name="openblas${LIBNAMESUFFIX}-${OPENBLAS_VERSION}-${plat_tag}-${GCC_TAG}.zip" -zip -r $zip_name $build_bits -cp $zip_name ${builds_dir} +zip_name="openblas.zip" +zip -r $zip_name build