Skip to content

Commit f64e97b

Browse files
committed
use image's gfortran-15 on macos-arm64, remove tarball name mangling
1 parent aebe89c commit f64e97b

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

tools/build_steps.sh

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,6 @@ function before_build {
3838
# get_macpython_environment ${MB_PYTHON_VERSION} venv
3939
python3.9 -m venv venv
4040
source venv/bin/activate
41-
# Use gfortran from conda
42-
# Since install_fortran uses `uname -a` to determine arch,
43-
# force the architecture when using rosetta
44-
unalias gfortran || true
45-
arch -${PLAT} bash -s << " EOF"
46-
set -xe
47-
source tools/gfortran_utils.sh
48-
install_gfortran
49-
EOF
50-
# re-export these, since we ran in a shell
51-
export FC=$(find /opt/gfortran/gfortran-darwin-${PLAT}-native/bin -name "*-gfortran")
52-
local libdir=/opt/gfortran/gfortran-darwin-${PLAT}-native/lib
53-
export FFLAGS="-L${libdir} -Wl,-rpath,${libdir}"
54-
5541
# Build the objconv tool
5642
(cd ${ROOT_DIR}/objconv && bash ../tools/build_objconv.sh)
5743
fi
@@ -115,9 +101,9 @@ function build_lib {
115101
local manylinux=${MB_ML_VER:-1}
116102
if [ -n "$IS_OSX" ]; then
117103
# Do build, add gfortran hash to end of name
118-
do_build_lib "$plat" "gf_${GFORTRAN_SHA:0:7}" "$interface64" "$nightly"
104+
do_build_lib "$plat" "$interface64" "$nightly"
119105
else
120-
do_build_lib "$plat" "" "$interface64" "$nightly"
106+
do_build_lib "$plat" "$interface64" "$nightly"
121107
fi
122108
}
123109

@@ -134,18 +120,15 @@ function do_build_lib {
134120
# Build openblas lib
135121
# Input arg
136122
# plat - one of i686, x86_64, arm64
137-
# suffix (optional) - suffix for output archive name
138-
# Suffix added with hyphen prefix
139123
# interface64 (optional) - whether to build ILP64 openblas
140124
# with 64_ symbol suffix
141125
# nightly (optional) - whether to build for nightlies
142126
#
143127
# Depends on globals
144128
# BUILD_PREFIX - install suffix e.g. "/usr/local"
145129
local plat=$1
146-
local suffix=$2
147-
local interface64=$3
148-
local nightly=$4
130+
local interface64=$2
131+
local nightly=$3
149132
case $(get_os)-$plat in
150133
Linux-x86_64)
151134
local bitness=64
@@ -155,6 +138,20 @@ function do_build_lib {
155138
Darwin-x86_64)
156139
local bitness=64
157140
local target="CORE2"
141+
# Use gfortran from conda
142+
# Since install_fortran uses `uname -a` to determine arch,
143+
# force the architecture when using rosetta
144+
unalias gfortran || true
145+
arch -${PLAT} bash -s << " EOF"
146+
set -xe
147+
source tools/gfortran_utils.sh
148+
install_gfortran
149+
EOF
150+
# re-export these, since we ran in a shell
151+
export FC=$(find /opt/gfortran/gfortran-darwin-${PLAT}-native/bin -name "*-gfortran")
152+
local libdir=/opt/gfortran/gfortran-darwin-${PLAT}-native/lib
153+
export FFLAGS="-L${libdir} -Wl,-rpath,${libdir}"
154+
158155
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH
159156
CFLAGS="$CFLAGS -arch x86_64"
160157
export SDKROOT=${SDKROOT:-$(xcrun --show-sdk-path)}
@@ -176,6 +173,16 @@ function do_build_lib {
176173
fi
177174
;;
178175
Darwin-arm64)
176+
export FC=gfortran-15
177+
which $FC
178+
# guess?
179+
local libdir=/opt/homebrew/Cellar/gcc/15.2.0/lib/gcc/current
180+
if [! -d $libdir]; then
181+
echo where is libfortran.a?
182+
find /opt -name libgfortran.a
183+
exit 1
184+
fi
185+
export FFLAGS="-L${libdir} -Wl,-rpath,${libdir}"
179186
local bitness=64
180187
local target="VORTEX"
181188
CFLAGS="$CFLAGS -ftrapping-math -mmacos-version-min=11.0"
@@ -244,8 +251,6 @@ function do_build_lib {
244251
fi
245252
mv $BUILD_PREFIX/lib/pkgconfig/openblas*.pc $BUILD_PREFIX/lib/pkgconfig/scipy-openblas.pc
246253
local plat_tag=$(get_plat_tag $plat)
247-
local suff=""
248-
[ -n "$suffix" ] && suff="-$suffix"
249254
if [ "$interface64" = "1" ]; then
250255
# OpenBLAS does not install the symbol suffixed static library,
251256
# do it ourselves
@@ -258,7 +263,7 @@ function do_build_lib {
258263
rm $BUILD_PREFIX/lib/pkgconfig/scipy-openblas.pc.bak
259264
fi
260265
261-
local out_name="openblas${symbolsuffix}-${version}-${plat_tag}${suff}.tar.gz"
266+
local out_name="openblas${symbolsuffix}-${version}-${plat_tag}.tar.gz"
262267
tar zcvf libs/$out_name \
263268
$BUILD_PREFIX/include/*blas* \
264269
$BUILD_PREFIX/include/*lapack* \

0 commit comments

Comments
 (0)