Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "OpenBLAS"]
path = OpenBLAS
url = https://github.com/xianyi/OpenBLAS.git
[submodule "gfortran-install"]
path = gfortran-install
url = https://github.com/MacPython/gfortran-install.git
1 change: 0 additions & 1 deletion gfortran-install
Submodule gfortran-install deleted from 3dd38d
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "scipy-openblas64"
# v0.3.30-349-gf6df9beb
version = "0.3.30.349.0"
version = "0.3.30.349.1"
requires-python = ">=3.7"
description = "Provides OpenBLAS for python packaging"
readme = "README.md"
Expand Down
85 changes: 47 additions & 38 deletions tools/build_steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,20 @@ function get_os {


function before_build {
# Manylinux Python version set in build_lib
if [ ! -e /usr/local/lib ]; then
sudo mkdir -p /usr/local/lib
sudo chmod 777 /usr/local/lib
touch /usr/local/lib/.dir_exists
fi
if [ ! -e /usr/local/include ]; then
sudo mkdir -p /usr/local/include
sudo chmod 777 /usr/local/include
touch /usr/local/include/.dir_exists
fi
if [ -n "$IS_OSX" ]; then
if [ ! -e /usr/local/lib ]; then
sudo mkdir -p /usr/local/lib
sudo chmod 777 /usr/local/lib
touch /usr/local/lib/.dir_exists
fi
if [ ! -e /usr/local/include ]; then
sudo mkdir -p /usr/local/include
sudo chmod 777 /usr/local/include
touch /usr/local/include/.dir_exists
fi
# get_macpython_environment ${MB_PYTHON_VERSION} venv
python3.9 -m venv venv
source venv/bin/activate
alias gfortran=gfortran-15
# Deployment target set by gfortran_utils
echo "Deployment target $MACOSX_DEPLOYMENT_TARGET"

# Build the objconv tool
(cd ${ROOT_DIR}/objconv && bash ../tools/build_objconv.sh)
fi
Expand All @@ -55,13 +50,9 @@ function clean_code {
[ -z "$build_commit" ] && echo "build_commit not defined" && exit 1
pushd OpenBLAS
git fetch origin --tags
echo after git fetch origin
git checkout $build_commit
echo after git checkout $build_commit
git clean -fxd
echo after git clean
git submodule update --init --recursive
echo after git submodule update
popd
}

Expand Down Expand Up @@ -110,9 +101,9 @@ function build_lib {
local manylinux=${MB_ML_VER:-1}
if [ -n "$IS_OSX" ]; then
# Do build, add gfortran hash to end of name
do_build_lib "$plat" "gf_${GFORTRAN_SHA:0:7}" "$interface64" "$nightly"
do_build_lib "$plat" "$interface64" "$nightly"
else
do_build_lib "$plat" "" "$interface64" "$nightly"
do_build_lib "$plat" "$interface64" "$nightly"
fi
}

Expand All @@ -129,18 +120,15 @@ function do_build_lib {
# Build openblas lib
# Input arg
# plat - one of i686, x86_64, arm64
# suffix (optional) - suffix for output archive name
# Suffix added with hyphen prefix
# interface64 (optional) - whether to build ILP64 openblas
# with 64_ symbol suffix
# nightly (optional) - whether to build for nightlies
#
# Depends on globals
# BUILD_PREFIX - install suffix e.g. "/usr/local"
local plat=$1
local suffix=$2
local interface64=$3
local nightly=$4
local interface64=$2
local nightly=$3
case $(get_os)-$plat in
Linux-x86_64)
local bitness=64
Expand All @@ -150,18 +138,25 @@ function do_build_lib {
Darwin-x86_64)
local bitness=64
local target="CORE2"
# Use gfortran-11
unalias gfortran
# Use gfortran from conda
# Since install_fortran uses `uname -a` to determine arch,
# force the architecture
arch -${PLAT} bash -s << EOF
source ${ROOT_DIR}/gfortran-install/gfortran_utils.sh
install_gfortran
EOF
# force the architecture when using rosetta
unalias gfortran || true
arch -${PLAT} bash -s << " EOF"
set -xe
source tools/gfortran_utils.sh
install_gfortran
EOF
# re-export these, since we ran in a shell
export FC=$(find /opt/gfortran/gfortran-darwin-${PLAT}-native/bin -name "*-gfortran")
local libdir=/opt/gfortran/gfortran-darwin-${PLAT}-native/lib
export FFLAGS="-L${libdir} -Wl,-rpath,${libdir}"

export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH
CFLAGS="$CFLAGS -arch x86_64"
export SDKROOT=${SDKROOT:-$(xcrun --show-sdk-path)}
local dynamic_list="CORE2 NEHALEM SANDYBRIDGE HASWELL SKYLAKEX"
MACOSX_DEPLOYMENT_TARGET="10.9"
;;
*-i686)
local bitness=32
Expand All @@ -178,6 +173,18 @@ EOF
fi
;;
Darwin-arm64)
export FC=gfortran-15
which $FC
# guess?
local libdir=/opt/homebrew/Cellar/gcc/15.2.0/lib/gcc/current
if [ ! -e $libdir/libgfortran.a ]; then
echo where is libfortran.a?
find /opt -name libgfortran.a
exit 1
fi
export FFLAGS="-L${libdir} -Wl,-rpath,${libdir}"
export GFORTRAN_LIBDIR=$($FC -print-file-name=libgfortran.dylib | xargs dirname)
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib -L$GFORTRAN_LIBDIR"
local bitness=64
local target="VORTEX"
CFLAGS="$CFLAGS -ftrapping-math -mmacos-version-min=11.0"
Expand All @@ -187,6 +194,7 @@ EOF
;;
*-s390x)
local bitness=64
local target="ZARCH_GENERIC"
;;
*-ppc64le)
local bitness=64
Expand Down Expand Up @@ -216,7 +224,10 @@ EOF
git config --global --add safe.directory '*'
pushd OpenBLAS
patch_source
# force failure when fortran compiler is no detected
sed -i.bak -e 's/info OpenBLAS: Detecting fortran compiler failed/error OpenBLAS: Detecting fortran compiler failed/g' Makefile
echo start building

if [ "$plat" == "loongarch64" ]; then
# https://github.com/OpenMathLib/OpenBLAS/blob/develop/.github/workflows/loongarch64.yml#L65
echo -n > utest/test_dsdot.c
Expand All @@ -225,14 +236,14 @@ EOF
fi
if [ -n "$dynamic_list" ]; then
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized" \
make BUFFERSIZE=20 DYNAMIC_ARCH=1 QUIET_MAKE=1 \
make BUFFERSIZE=20 DYNAMIC_ARCH=1 \
USE_OPENMP=0 NUM_THREADS=64 \
DYNAMIC_LIST="$dynamic_list" \
BINARY="$bitness" $interface_flags \
TARGET="$target"
else
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized" \
make BUFFERSIZE=20 DYNAMIC_ARCH=1 QUIET_MAKE=1 \
make BUFFERSIZE=20 DYNAMIC_ARCH=1 \
USE_OPENMP=0 NUM_THREADS=64 \
BINARY="$bitness" $interface_flags \
TARGET="$target"
Expand All @@ -246,8 +257,6 @@ EOF
fi
mv $BUILD_PREFIX/lib/pkgconfig/openblas*.pc $BUILD_PREFIX/lib/pkgconfig/scipy-openblas.pc
local plat_tag=$(get_plat_tag $plat)
local suff=""
[ -n "$suffix" ] && suff="-$suffix"
if [ "$interface64" = "1" ]; then
# OpenBLAS does not install the symbol suffixed static library,
# do it ourselves
Expand All @@ -260,7 +269,7 @@ EOF
rm $BUILD_PREFIX/lib/pkgconfig/scipy-openblas.pc.bak
fi

local out_name="openblas${symbolsuffix}-${version}-${plat_tag}${suff}.tar.gz"
local out_name="openblas${symbolsuffix}-${version}-${plat_tag}.tar.gz"
tar zcvf libs/$out_name \
$BUILD_PREFIX/include/*blas* \
$BUILD_PREFIX/include/*lapack* \
Expand Down
Loading
Loading