-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.sh
59 lines (48 loc) · 2.12 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# https://github.com/xianyi/OpenBLAS/wiki/faq#Linux_SEGFAULT
patch < segfaults.patch
# See this workaround
# ( https://github.com/xianyi/OpenBLAS/issues/818#issuecomment-207365134 ).
CF="${CFLAGS}"
unset CFLAGS
if [[ `uname` == 'Darwin' ]]; then
USE_OPENMP="0"
else
# Gnu OpenMP is not fork-safe. We disable openmp right now, so that downstream packages don't hang as a result of this.
# USE_OPENMP="1"
USE_OPENMP="0"
fi
if [ ! -z "$FFLAGS" ]; then
export FFLAGS="${FFLAGS/-fopenmp/ }";
fi
# Because -Wno-missing-include-dirs does not work with gfortran:
[[ -d "${PREFIX}"/include ]] || mkdir "${PREFIX}"/include
[[ -d "${PREFIX}"/lib ]] || mkdir "${PREFIX}"/lib
# USE_SIMPLE_THREADED_LEVEL3 is necessary to avoid hangs when more than one process uses blas:
# https://github.com/xianyi/OpenBLAS/issues/1456
# https://github.com/xianyi/OpenBLAS/issues/294
# https://github.com/scikit-learn/scikit-learn/issues/636
# Set CPU Target
TARGET=""
if [[ ${target_platform} == linux-aarch64 ]]; then
TARGET="TARGET=ARMV8"
fi
if [[ ${target_platform} == linux-ppc64le ]]; then
TARGET="TARGET=POWER8"
fi
# Build all CPU targets and allow dynamic configuration
# Build LAPACK.
# Enable threading. This can be controlled to a certain number by
# setting OPENBLAS_NUM_THREADS before loading the library.
make QUIET_MAKE=1 DYNAMIC_ARCH=1 BINARY=${ARCH} NO_LAPACK=0 NO_AFFINITY=1 USE_THREAD=1 NUM_THREADS=128 \
USE_OPENMP="${USE_OPENMP}" USE_SIMPLE_THREADED_LEVEL3=1 CFLAGS="${CF}" FFLAGS="${FFLAGS} -frecursive" \
HOST=${HOST} $TARGET
OPENBLAS_NUM_THREADS="${CPU_COUNT}" CFLAGS="${CF}" FFLAGS="${FFLAGS} -frecursive" make test
make install PREFIX="${PREFIX}"
if [[ `uname` == 'Darwin' ]]; then
# Needs to fix the install name of the dylib so that the downstream projects will link
# to libopenblas.dylib instead of libopenblasp-r0.2.20.dylib
# In linux, SONAME is libopenblas.so.0 instead of libopenblasp-r0.2.20.so, so no change needed
ln -s ${PREFIX}/lib/libopenblas.dylib ${PREFIX}/lib/libopenblas.0.dylib
install_name_tool -id ${PREFIX}/lib/libopenblas.0.dylib ${PREFIX}/lib/libopenblas.dylib;
fi