diff --git a/.github/workflows/posix.yml b/.github/workflows/posix.yml index aca4445..eeaff43 100644 --- a/.github/workflows/posix.yml +++ b/.github/workflows/posix.yml @@ -46,7 +46,7 @@ jobs: INTERFACE64: '1' env: REPO_DIR: OpenBLAS - OPENBLAS_COMMIT: "c2f4bdb" + OPENBLAS_COMMIT: "9d425a5f" NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} MACOSX_DEPLOYMENT_TARGET: 10.9 MB_PYTHON_VERSION: ${{ matrix.python-version }} @@ -68,17 +68,15 @@ jobs: python-version: 3.7 - name: Set extra env run: | - if [ "macos-11" == "${{ matrix.os }}" ]; then - echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; - echo "LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib" >> $GITHUB_ENV; - echo "LIBRARY_PATH=-L/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib" >> $GITHUB_ENV; - else - echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; - fi + # if [ "macos-11" == "${{ matrix.os }}" ]; then + # Use xcrun --sdk macosx --show-sdk-path instead of hardcoding the path + # echo "LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib" >> $GITHUB_ENV; + # echo "LIBRARY_PATH=-L/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib" >> $GITHUB_ENV; + # else + # fi echo "DOCKER_TEST_IMAGE=$(echo multibuild/xenial_${{ matrix.PLAT}})" >> $GITHUB_ENV; - name: Print some Environment variable run: | - echo "TRAVIS_OS_NAME: ${TRAVIS_OS_NAME}" echo "PLAT: ${PLAT}" echo "DOCKER_TEST_IMAGE: ${DOCKER_TEST_IMAGE}" - name: Install VirtualEnv @@ -115,7 +113,7 @@ jobs: version=$(cd OpenBLAS && git describe --tags --abbrev=8 | sed -e "s/^v\(.*\)-g.*/\1/" | sed -e "s/-/./g") sed -e "s/^version = .*/version = \"${version}\"/" -i.bak pyproject.toml fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + if [ "macos-11" == "${{ matrix.os }}" ]; then source tools/build_wheel.sh else libc=${MB_ML_LIBC:-manylinux} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f8dbc5c..8e3660d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -7,7 +7,7 @@ on: branches: [ main ] env: - OPENBLAS_COMMIT: "c2f4bdb" + OPENBLAS_COMMIT: "9d425a5f" OPENBLAS_ROOT: "c:\\opt" # Preserve working directory for calls into bash # Without this, invoking bash will cd to the home directory @@ -32,7 +32,7 @@ jobs: - name: install-rtools run: | # rtools 42+ does not support 32 bits builds. - choco install -y rtools --noprogress --force --version=4.0.0.20220206 + choco install -y rtools --no-progress --force --version=4.0.0.20220206 - name: Set env variables run: | @@ -94,7 +94,7 @@ jobs: fi mv local/scipy_openblas64/bin/*.dll local/scipy_openblas64/lib rm local/scipy_openblas64/lib/*.a - rm local/scipy_openblas64/lib/*.exp + rm -f local/scipy_openblas64/lib/*.exp # may not exist? rm local/scipy_openblas64/lib/*.def rm -rf local/scipy_openblas64/lib/pkgconfig if [[ -d local/scipy_openblas64/64 ]]; then @@ -109,7 +109,7 @@ jobs: # of a pyproject.toml project sed -e "s/openblas64/openblas32/" -i pyproject.toml sed -e "s/openblas_get_config64_/openblas_get_config/" -i local/scipy_openblas32/__init__.py - sed -e "s/cflags_suffix64 =.*/cflags_suffix64 = ''/" -i local/scipy_openblas32/__init__.py + sed -e "s/cflags =.*/cflags = '-DBLAS_SYMBOL_PREFIX=scipy_'/" -i local/scipy_openblas32/__init__.py sed -e "s/openblas64/openblas32/" -i local/scipy_openblas32/__init__.py sed -e "s/openblas64/openblas32/" -i local/scipy_openblas32/__main__.py fi diff --git a/.travis.yml b/.travis.yml index 544128f..10b691e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ env: global: # The archive that gets built has name from ``git describe`` on this # commit. - - OPENBLAS_COMMIT="c2f4bdb" + - OPENBLAS_COMMIT="9d425a5f" - REPO_DIR=OpenBLAS # Following generated with: # travis encrypt -r MacPython/openblas-libs OPENBLAS_LIBS_STAGING_UPLOAD_TOKEN= diff --git a/OpenBLAS b/OpenBLAS index 138ed79..9d425a5 160000 --- a/OpenBLAS +++ b/OpenBLAS @@ -1 +1 @@ -Subproject commit 138ed79fe7f06d114ffbaee9b36ca9d040203e4c +Subproject commit 9d425a5fe79e10e68a4c2ff591ba268343972c96 diff --git a/local/scipy_openblas64/__init__.py b/local/scipy_openblas64/__init__.py index 57c0441..4ee4752 100644 --- a/local/scipy_openblas64/__init__.py +++ b/local/scipy_openblas64/__init__.py @@ -49,7 +49,9 @@ def get_library(): libs = [x for x in os.listdir(get_lib_dir()) if x.endswith(".lib")] return os.path.splitext(libs[0])[0] else: - return "openblas_python" + libs = [x for x in os.listdir(get_lib_dir()) if x.startswith("libscipy_openblas")] + # remove the leading lib from libscipy_openblas* + return os.path.splitext(libs[0])[0][3:] def get_pkg_config(): """Return a multi-line string that, when saved to a file, can be used with @@ -59,9 +61,9 @@ def get_pkg_config(): extralib = "-defaultlib:advapi32 -lgfortran -lquadmath" libs_flags = f"-L${{libdir}} -l{get_library()}" else: - extralib = "-lm -lpthread -lgfortran -lquadmath -L${libdir} -lopenblas_python" + extralib = "-lm -lpthread -lgfortran -lquadmath -L${libdir} -l{get_library()}" libs_flags = "" - cflags_suffix64 = "-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64" + cflags = "-DBLAS_SYMBOL_PREFIX=scipy_ -DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64 -DOPENBLAS_ILP64_NAMING_SCHEME" return dedent(f"""\ libdir={get_lib_dir()} includedir={get_include_dir()} @@ -74,7 +76,7 @@ def get_pkg_config(): URL: https://github.com/xianyi/OpenBLAS Libs: {libs_flags} Libs.private: ${{extralib}} - Cflags: -I${{includedir}} {cflags_suffix64} + Cflags: -I${{includedir}} {cflags} """) @@ -109,10 +111,10 @@ def get_openblas_config(): libnames = [x for x in os.listdir(lib_dir) if x.endswith(".dll")] else: # Get openblas* - libnames = [x for x in os.listdir(lib_dir) if x.startswith("libopenblas")] + libnames = [x for x in os.listdir(lib_dir) if x.startswith("libscipy")] dll = ctypes.CDLL(os.path.join(lib_dir, libnames[0]), ctypes.RTLD_GLOBAL) - openblas_config = dll.openblas_get_config64_ + openblas_config = dll.scipy_openblas_get_config64_ openblas_config.restype = ctypes.c_char_p bytes = openblas_config() return bytes.decode("utf8") diff --git a/multibuild b/multibuild index 4eb8556..452dd2d 160000 --- a/multibuild +++ b/multibuild @@ -1 +1 @@ -Subproject commit 4eb855680308fd279357896dfe0afe59e5c307fa +Subproject commit 452dd2d1705f6b2375369a6570c415beb3163f70 diff --git a/pyproject.toml b/pyproject.toml index dbc3a73..5fcee80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [project] name = "scipy_openblas64" -version = "0.3.23.293.2" +version = "0.3.24.95.0" requires-python = ">=3.7" description = "Provides OpenBLAS for python packaging" readme = "README.md" diff --git a/test.f90 b/test.f90 index c1554f6..c025eca 100644 --- a/test.f90 +++ b/test.f90 @@ -1,4 +1,4 @@ -!testdpotr_test_gh_2691.f90 +!testdpotr_test_gh_2691.f90 with scipy_ prefix subroutine garbage(okflag) implicit none integer, intent(out) :: okflag @@ -23,7 +23,7 @@ subroutine garbage(okflag) a2 = a - call dpotrf('L', 3, a, 3, info) + call scipy_dpotrf('L', 3, a, 3, info) if (info.ne.0) then okflag = 0 write(*,*) 'DPOTRF failed' @@ -39,20 +39,20 @@ subroutine garbage(okflag) a(i,j) = 0 end do end do - call dpotri('L', 3, a, 3, info) + call scipy_dpotri('L', 3, a, 3, info) if (info.ne.0) then okflag = 0 write(*,*) 'DPOTRI failed' return end if - call dgetrf(3, 3, a2, 3, ipiv, info) + call scipy_dgetrf(3, 3, a2, 3, ipiv, info) if (info.ne.0) then okflag = 0 write(*,*) 'DGETRF failed' return end if - call dgetri(3, a2, 3, ipiv, work, lwork, info) + call scipy_dgetri(3, a2, 3, ipiv, work, lwork, info) if (info.ne.0) then okflag = 0 write(*,*) 'DGETRI failed' diff --git a/test64_.f90 b/test64_.f90 index 3d1c9b0..cb7b31d 100644 --- a/test64_.f90 +++ b/test64_.f90 @@ -1,4 +1,4 @@ -!testdpotr_test_gh_2691.f90 with _64 suffix +!testdpotr_test_gh_2691.f90 with _64 suffix and scipy_ prefix subroutine garbage(okflag) implicit none integer, intent(out) :: okflag @@ -23,7 +23,7 @@ subroutine garbage(okflag) a2 = a - call dpotrf_64('L', 3, a, 3, info) + call scipy_dpotrf_64('L', 3, a, 3, info) if (info.ne.0) then okflag = 0 write(*,*) 'DPOTRF failed' @@ -39,20 +39,20 @@ subroutine garbage(okflag) a(i,j) = 0 end do end do - call dpotri_64('L', 3, a, 3, info) + call scipy_dpotri_64('L', 3, a, 3, info) if (info.ne.0) then okflag = 0 write(*,*) 'DPOTRI failed' return end if - call dgetrf_64(3, 3, a2, 3, ipiv, info) + call scipy_dgetrf_64(3, 3, a2, 3, ipiv, info) if (info.ne.0) then okflag = 0 write(*,*) 'DGETRF failed' return end if - call dgetri_64(3, a2, 3, ipiv, work, lwork, info) + call scipy_dgetri_64(3, a2, 3, ipiv, work, lwork, info) if (info.ne.0) then okflag = 0 write(*,*) 'DGETRI failed' diff --git a/tools/build_gfortran.sh b/tools/build_gfortran.sh index 5b7aba9..37d2331 100644 --- a/tools/build_gfortran.sh +++ b/tools/build_gfortran.sh @@ -1,6 +1,6 @@ # Build gfortran binary against OpenBLAS -set -e +set -ex rm -rf for_test mkdir for_test @@ -13,6 +13,9 @@ static_libname=$(find $OBP/lib -maxdepth 1 -type f -name '*.a' \! -name '*.dll.a dynamic_libname=$(find $OBP/lib -maxdepth 1 -type f -name '*.dll.a' | tail -1) dll_name=$(echo $dynamic_libname | sed 's#/lib/#/bin/#' | sed 's/.a$//') +grep dpotrf $OBP/include/* +nm $static_libname | grep dpotrf + cp $dll_name . if [ "$INTERFACE64" == "1" ]; then diff --git a/tools/build_openblas.sh b/tools/build_openblas.sh index f620f65..350dce2 100644 --- a/tools/build_openblas.sh +++ b/tools/build_openblas.sh @@ -20,6 +20,8 @@ # realpath, cygpath, zip, gcc, make, ar, dlltool # usually as part of an msys installation. +set -xe + # Convert to Unix-style path openblas_root="$(cygpath ${1:-${OPENBLAS_ROOT:-c:\\opt}})" build_bits="${2:-${BUILD_BITS:-64}}" @@ -75,12 +77,13 @@ fflags="$fextra $cflags -frecursive -ffpe-summary=invalid,zero" # Set suffixed-ILP64 flags if [ "$if_bits" == "64" ]; then SYMBOLSUFFIX="64_" - interface64_flags="INTERFACE64=1 SYMBOLSUFFIX=${SYMBOLSUFFIX}" + interface_flags="INTERFACE64=1 SYMBOLSUFFIX=${SYMBOLSUFFIX}" # We override FCOMMON_OPT, so we need to set default integer manually fflags="$fflags -fdefault-integer-8" else - interface64_flags="" + interface_flags="" fi +interface_flags="$interface_flags SYMBOLPREFIX=scipy_" # Build name for output library from gcc version and OpenBLAS commit. GCC_TAG="gcc_$(gcc -dumpversion | tr .- _)" @@ -95,20 +98,28 @@ make BINARY=$build_bits DYNAMIC_ARCH=1 USE_THREAD=1 USE_OPENMP=0 \ COMMON_OPT="$cflags" \ FCOMMON_OPT="$fflags" \ MAX_STACK_ALLOC=2048 \ - $interface64_flags -make PREFIX=$openblas_root/$build_bits $interface64_flags install -DLL_BASENAME=libopenblas${SYMBOLSUFFIX}_${LIBNAMESUFFIX} -if [ "$if_bits" == "64" ]; then - # OpenBLAS does not build a symbol-suffixed static library on Windows: - # do it ourselves - set -x # echo commands - static_libname=$(find . -maxdepth 1 -type f -name '*.a' \! -name '*.dll.a' | tail -1) - make -C exports $interface64_flags objcopy.def - 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" - set +x + $interface_flags +make PREFIX=$openblas_root/$build_bits $interface_flags install +DLL_BASENAME=libscipy_openblas${SYMBOLSUFFIX}_${LIBNAMESUFFIX} + +# 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 cd $build_bits/lib @@ -124,10 +135,6 @@ dlltool --input-def ${DLL_BASENAME}.def \ --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 -echo After sed -i, pkgconfig/openblas*.pc is -echo ------------ -cat pkgconfig/openblas*.pc -echo ------------ cd ../.. # Build template site.cfg for using this build cat > ${build_bits}/site.cfg.template << EOF @@ -136,6 +143,9 @@ libraries = $DLL_BASENAME library_dirs = {openblas_root}\\${build_bits}\\lib include_dirs = {openblas_root}\\${build_bits}\\include EOF + +ls $openblas_root/$build_bits/lib + zip_name="openblas${SYMBOLSUFFIX}-${OPENBLAS_VERSION}-${plat_tag}-${GCC_TAG}.zip" zip -r $zip_name $build_bits cp $zip_name ${builds_dir} diff --git a/tools/build_steps.sh b/tools/build_steps.sh index bc4172d..0d4d294 100644 --- a/tools/build_steps.sh +++ b/tools/build_steps.sh @@ -19,10 +19,8 @@ function before_build { # Deployment target set by gfortran_utils echo "Deployment target $MACOSX_DEPLOYMENT_TARGET" - if [ "$INTERFACE64" = "1" ]; then - # Build the objconv tool - (cd ${ROOT_DIR}/objconv && bash ../tools/build_objconv.sh) - fi + # Build the objconv tool + (cd ${ROOT_DIR}/objconv && bash ../tools/build_objconv.sh) fi } @@ -148,14 +146,14 @@ function do_build_lib { esac case $interface64 in 1) - local interface64_flags="INTERFACE64=1 SYMBOLSUFFIX=64_ OBJCONV=$PWD/objconv/objconv"; + local interface_flags="INTERFACE64=1 SYMBOLSUFFIX=64_ SYMBOLPREFIX=scipy_ OBJCONV=$PWD/objconv/objconv"; local symbolsuffix="64_"; if [ -n "$IS_OSX" ]; then $PWD/objconv/objconv --help fi ;; *) - local interface64_flags="" + local interface_flags="SYMBOLPREFIX=scipy_ OBJCONV=$PWD/objconv/objconv" local symbolsuffix=""; ;; esac @@ -165,11 +163,11 @@ function do_build_lib { git config --global --add safe.directory '*' pushd OpenBLAS patch_source - CFLAGS="$CFLAGS -fvisibility=protected" \ + CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized" \ make BUFFERSIZE=20 DYNAMIC_ARCH=1 \ USE_OPENMP=0 NUM_THREADS=64 \ - BINARY=$bitness $interface64_flags $target_flags > /dev/null - make PREFIX=$BUILD_PREFIX $interface64_flags install + BINARY=$bitness $interface_flags $target_flags > /dev/null + make PREFIX=$BUILD_PREFIX $interface_flags install popd stop_spinner if [ "$nightly" = "1" ]; then @@ -193,7 +191,7 @@ function do_build_lib { tar zcvf libs/$out_name \ $BUILD_PREFIX/include/*blas* \ $BUILD_PREFIX/include/*lapack* \ - $BUILD_PREFIX/lib/libopenblas* \ + $BUILD_PREFIX/lib/libscipy_openblas* \ $BUILD_PREFIX/lib/pkgconfig/openblas* \ $BUILD_PREFIX/lib/cmake/openblas } diff --git a/tools/build_wheel.sh b/tools/build_wheel.sh index 415d771..95fbff8 100644 --- a/tools/build_wheel.sh +++ b/tools/build_wheel.sh @@ -24,14 +24,10 @@ find local/scipy_openblas64/lib -maxdepth 1 -type l -delete rm local/scipy_openblas64/lib/*.a # Do not package the pkgconfig stuff, use the wheel functionality instead rm -rf local/scipy_openblas64/lib/pkgconfig -# cleanup from a possible earlier run of the script -rm -f local/scipy_openblas64/lib/libopenblas_python.so -mv local/scipy_openblas64/lib/libopenblas* local/scipy_openblas64/lib/libopenblas_python.so if [ $(uname) == "Darwin" ]; then cat tools/LICENSE_osx.txt >> LICENSE.txt else - patchelf --set-soname libopenblas_python.so local/scipy_openblas64/lib/libopenblas_python.so cat tools/LICENSE_linux.txt >> LICENSE.txt fi @@ -45,7 +41,7 @@ if [ "${INTERFACE64}" != "1" ]; then rm *.bak mv local/scipy_openblas64 local/scipy_openblas32 sed -e "s/openblas_get_config64_/openblas_get_config/" -i.bak local/scipy_openblas32/__init__.py - sed -e "s/cflags_suffix64 =.*/cflags_suffix64 = ''/" -i.bak local/scipy_openblas32/__init__.py + sed -e "s/cflags =.*/cflags = '-DBLAS_SYMBOL_PREFIX=scipy_'/" -i.bak local/scipy_openblas32/__init__.py sed -e "s/openblas64/openblas32/" -i.bak local/scipy_openblas32/__main__.py sed -e "s/openblas64/openblas32/" -i.bak local/scipy_openblas32/__init__.py rm local/scipy_openblas32/*.bak