Skip to content

Commit

Permalink
openblas: Use less aggressive optimization level.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmuetzel committed Aug 31, 2022
1 parent 2d746c6 commit e9bea4f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions mingw-w64-openblas/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pkgbase=mingw-w64-openblas
pkgname=("${MINGW_PACKAGE_PREFIX}-openblas"
$([[ "${CARCH}" == "i686" ]] || echo "${MINGW_PACKAGE_PREFIX}-openblas64"))
pkgver=0.3.21
pkgrel=1
pkgrel=2
pkgdesc="An optimized BLAS library based on GotoBLAS2 1.13 BSD, providing optimized blas, lapack, and cblas (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
Expand Down Expand Up @@ -58,12 +58,27 @@ _build_openblas() {
_idx_opt=$1

declare -a _build_type
declare -a _optimization_opts
if check_option "debug" "n"; then
_build_type+=("Release")
# See: https://wiki.archlinux.org/title/CMake_package_guidelines#CMake_can_automatically_override_the_default_compiler_optimization_flag
_build_type+=("None")
if [[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]]; then
_optimization_opts=("-DCOMMON_OPT=-O2"
"-DCCOMMON_OPT=-O2"
"-DFCOMMON_OPT=-O2")
else
# GCC 12 enables `-ftree-vectorize` at optimization level `-O2`.
# Library built with that optimization might segfault for some functions.
# See also: https://github.com/xianyi/OpenBLAS/issues/3740
_optimization_opts=("-DCOMMON_OPT=-O2 -fno-tree-vectorize"
"-DCCOMMON_OPT=-O2 -fno-tree-vectorize"
"-DFCOMMON_OPT=-O2 -fno-tree-vectorize")
fi
else
_build_type+=("Debug")
fi

declare _c_lapack_opt
if [[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]]; then
_c_lapack_opt="-DC_LAPACK=ON"
fi
Expand Down Expand Up @@ -93,6 +108,7 @@ _build_openblas() {
-DTARGET=${target} \
${_c_lapack_opt} \
${_idx_opt} \
"${_optimization_opts[@]}" \
../${_realname}-${pkgver}

${MINGW_PREFIX}/bin/cmake --build .
Expand Down

0 comments on commit e9bea4f

Please sign in to comment.