Skip to content

Commit 55c82eb

Browse files
committed
use LDFLAGS on Darwin, cleanup
1 parent 71d4bf3 commit 55c82eb

File tree

4 files changed

+30
-53
lines changed

4 files changed

+30
-53
lines changed

tools/build_steps.sh

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
1+
#!bash
2+
13
# Build script for manylinux and OSX
24
BUILD_PREFIX=${BUILD_PREFIX:-/usr/local}
35

46
ROOT_DIR=$(dirname $(dirname "${BASH_SOURCE[0]}"))
57

68
MB_PYTHON_VERSION=3.9
79

8-
function any_python {
9-
for cmd in $PYTHON_EXE python3 python; do
10-
if [ -n "$(type -t $cmd)" ]; then
11-
echo $cmd
12-
return
13-
fi
14-
done
15-
echo "Could not find python or python3"
16-
exit 1
17-
}
18-
19-
function get_os {
20-
# Report OS as given by uname
21-
# Use any Python that comes to hand.
22-
$(any_python) -c 'import platform; print(platform.uname()[0])'
23-
}
24-
25-
2610
function before_build {
2711
# Manylinux Python version set in build_lib
28-
if [ -n "$IS_OSX" ]; then
12+
if [ "$(uname -s)" == "Darwin" ]; then
2913
if [ ! -e /usr/local/lib ]; then
3014
sudo mkdir -p /usr/local/lib
3115
sudo chmod 777 /usr/local/lib
@@ -47,14 +31,19 @@ function before_build {
4731
which ${FC}
4832
${FC} --version
4933
local libdir=/opt/gfortran/gfortran-darwin-${PLAT}-native/lib
50-
# export DYLD_LIBRARY_PATH=$libdir:$DYLD_LIBRARY_PATH
34+
# Remove conflicting shared objects
35+
rm -fv ${libdir}/libiconv*
5136
export FFLAGS="-L${libdir} -Wl,-rpath,${libdir}"
37+
# Not clear why this is needed for tests on arm64...
38+
export LDFLAGS="$FFLAGS"
5239

5340
# Deployment target set by gfortran_utils
5441
echo "Deployment target $MACOSX_DEPLOYMENT_TARGET"
5542

5643
# Build the objconv tool
57-
(cd ${ROOT_DIR}/objconv && bash ../tools/build_objconv.sh)
44+
if [[ ! -x objconv/objconv ]]; then
45+
(cd ${ROOT_DIR}/objconv && bash ../tools/build_objconv.sh)
46+
fi
5847
fi
5948
}
6049

@@ -118,12 +107,7 @@ function build_lib {
118107
local interface64=${2:-$INTERFACE64}
119108
local nightly=${3:0}
120109
local manylinux=${MB_ML_VER:-1}
121-
if [ -n "$IS_OSX" ]; then
122-
# Do build, add gfortran hash to end of name
123-
do_build_lib "$plat" "gf_${GFORTRAN_SHA:0:7}" "$interface64" "$nightly"
124-
else
125-
do_build_lib "$plat" "" "$interface64" "$nightly"
126-
fi
110+
do_build_lib "$plat" "$interface64" "$nightly"
127111
}
128112

129113
function patch_source {
@@ -139,19 +123,16 @@ function do_build_lib {
139123
# Build openblas lib
140124
# Input arg
141125
# plat - one of i686, x86_64, arm64
142-
# suffix (optional) - suffix for output archive name
143-
# Suffix added with hyphen prefix
144126
# interface64 (optional) - whether to build ILP64 openblas
145127
# with 64_ symbol suffix
146128
# nightly (optional) - whether to build for nightlies
147129
#
148130
# Depends on globals
149131
# BUILD_PREFIX - install suffix e.g. "/usr/local"
150132
local plat=$1
151-
local suffix=$2
152-
local interface64=$3
153-
local nightly=$4
154-
case $(get_os)-$plat in
133+
local interface64=$2
134+
local nightly=$3
135+
case $(uname -s)-$plat in
155136
Linux-x86_64)
156137
local bitness=64
157138
local target="PRESCOTT"
@@ -202,9 +183,6 @@ function do_build_lib {
202183
1)
203184
local interface_flags="INTERFACE64=1 SYMBOLSUFFIX=64_ LIBNAMESUFFIX=64_ OBJCONV=$PWD/objconv/objconv";
204185
local symbolsuffix="64_";
205-
if [ -n "$IS_OSX" ]; then
206-
$PWD/objconv/objconv --help
207-
fi
208186
;;
209187
*)
210188
local interface_flags="OBJCONV=$PWD/objconv/objconv"
@@ -226,14 +204,14 @@ function do_build_lib {
226204
fi
227205
if [ -n "$dynamic_list" ]; then
228206
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized" \
229-
make BUFFERSIZE=20 DYNAMIC_ARCH=1 QUIET_MAKE=1 \
207+
make BUFFERSIZE=20 DYNAMIC_ARCH=1 \
230208
USE_OPENMP=0 NUM_THREADS=64 \
231209
DYNAMIC_LIST="$dynamic_list" \
232210
BINARY="$bitness" $interface_flags \
233211
TARGET="$target"
234212
else
235213
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized" \
236-
make BUFFERSIZE=20 DYNAMIC_ARCH=1 QUIET_MAKE=1 \
214+
make BUFFERSIZE=20 DYNAMIC_ARCH=1 \
237215
USE_OPENMP=0 NUM_THREADS=64 \
238216
BINARY="$bitness" $interface_flags \
239217
TARGET="$target"
@@ -247,8 +225,6 @@ function do_build_lib {
247225
fi
248226
mv $BUILD_PREFIX/lib/pkgconfig/openblas*.pc $BUILD_PREFIX/lib/pkgconfig/scipy-openblas.pc
249227
local plat_tag=$(get_plat_tag $plat)
250-
local suff=""
251-
[ -n "$suffix" ] && suff="-$suffix"
252228
if [ "$interface64" = "1" ]; then
253229
# OpenBLAS does not install the symbol suffixed static library,
254230
# do it ourselves
@@ -261,7 +237,7 @@ function do_build_lib {
261237
rm $BUILD_PREFIX/lib/pkgconfig/scipy-openblas.pc.bak
262238
fi
263239

264-
local out_name="openblas${symbolsuffix}-${version}-${plat_tag}${suff}.tar.gz"
240+
local out_name="openblas${symbolsuffix}-${version}-${plat_tag}.tar.gz"
265241
tar zcvf libs/$out_name \
266242
$BUILD_PREFIX/include/*blas* \
267243
$BUILD_PREFIX/include/*lapack* \

tools/docker_build_wrap.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/bin/bash
22
# Depends on:
3-
# BUILD_PREFIX
43
# PLAT
4+
# INTERFACE64 (could be missing or empty)
5+
# NIGHTLY (could be missing or empty)
56
set -e
67

78
# Change into root directory of repo
89
if [[ ! -e tools/build_steps.sh ]];then
910
cd /io
1011
fi
1112
source tools/build_steps.sh
12-
do_build_lib "$PLAT" "" "$INTERFACE64" "$NIGHTLY"
13+
do_build_lib "$PLAT" "$INTERFACE64" "$NIGHTLY"

tools/gfortran_utils.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!bash
12
# this file come from https://github.com/MacPython/gfortran-install
23
# Follow the license below
34

@@ -23,7 +24,6 @@ if [ "$(uname)" == "Darwin" ]; then
2324
function download_and_unpack_gfortran {
2425
local arch=$1
2526
local type=$2
26-
curl -L -O https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-${arch}-${type}.tar.gz
2727
case ${arch}-${type} in
2828
arm64-native)
2929
export GFORTRAN_SHA=0d5c118e5966d0fb9e7ddb49321f63cac1397ce8
@@ -42,6 +42,9 @@ if [ "$(uname)" == "Darwin" ]; then
4242
exit 1
4343
;;
4444
esac
45+
if [[ ! -e gfortran-darwin-${arch}-${type}.tar.gz ]]; then
46+
curl -L -O https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-${arch}-${type}.tar.gz
47+
fi
4548
if [[ "$(shasum gfortran-darwin-${arch}-${type}.tar.gz)" != "${GFORTRAN_SHA} gfortran-darwin-${arch}-${type}.tar.gz" ]]; then
4649
echo "shasum mismatch for gfortran-darwin-${arch}-${type}"
4750
exit 1
@@ -52,8 +55,8 @@ if [ "$(uname)" == "Darwin" ]; then
5255
fi
5356
cp "gfortran-darwin-${arch}-${type}.tar.gz" /opt/gfortran/gfortran-darwin-${arch}-${type}.tar.gz
5457
pushd /opt/gfortran
55-
tar -xvf gfortran-darwin-${arch}-${type}.tar.gz
56-
rm gfortran-darwin-${arch}-${type}.tar.gz
58+
tar -xvf gfortran-darwin-${arch}-${type}.tar.gz
59+
rm gfortran-darwin-${arch}-${type}.tar.gz
5760
popd
5861
}
5962

tools/local_build.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
#!bash
2+
13
# Replicate the workflow from posix.yml locally on posix
24
# This may bitrot, compare it to the original file before using
35

46
set -e
57

68
# Set extra env
79
if [[ $(uname) == "Darwin" ]]; then
8-
# Force x86_64
9-
export PLAT=x86_64
10+
# export PLAT=x86_64
11+
export PLAT=arm64
1012
elif [[ $(uname -m) == "x86_64" ]]; then
1113
echo got x86_64
1214
export PLAT=x86_64
@@ -17,11 +19,6 @@ elif [[ $(uname -m) == arm64 ]]; then
1719
else
1820
echo got nothing
1921
exit -1
20-
export LDFLAGS="-L/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib"
21-
export LIBRARY_PATH="-L/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib"
22-
export PLAT=x86_64
23-
# export PLAT=arm64
24-
export SUFFIX=gf_c469a42
2522
fi
2623
export OPENBLAS_COMMIT="v0.3.30-349-gf6df9beb"
2724

0 commit comments

Comments
 (0)