Skip to content

Build openblas with ucrt mingw #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
47 changes: 47 additions & 0 deletions build_openblas.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Build script for OpenBLAS on Windows
# Expects environment variables:
$OPENBLAS_ROOT="c:\opt\openblas"
$BUILD_BITS="64"
$IF_BITS = "32"
$SUFFIX = "_m64"
# Expects "gcc" to be on the path
$march="x86-64"
# https://csharp.wekeepcoding.com/article/10463345/invalid+register+for+.seh_savexmm+in+Cygwin
$extra="-fno-asynchronous-unwind-tables"
$long_double="mlong-double-64"
$plat_tag="win_amd64"
$cflags="-O2 -march=$march -mtune=generic $extra $long_double"
$fflags="$extra $cflags -frecursive -ffpe-summary=invalid,zero $long_double"

if ($IF_BITS -eq '64') {
$interface64_flags = "INTERFACE64=1 SYMBOLSUFFIX=64_"
$SYMBOLSUFFIX="64_"
# We override FCOMMON_OPT, so we need to set default integer manually
$fflags="$fflags -fdefault-integer-8"
} else {
$interface64_flags = ""
$SYMBOL_SUFFIX = ""
}

# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90329
$fflags="$fflags -fno-optimize-sibling-calls"

# Build OpenBLAS
make BINARY=$BUILD_BITS DYNAMIC_ARCH=1 USE_THREAD=1 USE_OPENMP=0 `
NUM_THREADS=24 NO_WARMUP=1 NO_AFFINITY=1 CONSISTENT_FPCSR=1 `
BUILD_LAPACK_DEPRECATED=1 TARGET=PRESCOTT BUFFERSIZE=20 `
COMMON_OPT="$cflags" `
FCOMMON_OPT="$fflags" `
LDFLAGS="-lucrt -static" `
MAX_STACK_ALLOC=2048 `
$interface64_flags
$out_root="$OPENBLAS_ROOT\if_$IF_BITS$SUFFIX\$BUILD_BITS"
make PREFIX=$out_root $interface64_flags install
# Powershell specific? Paths in pkg-config file lack separators.
# Patch
$pkg_cfg_pc = "$out_root\lib\pkgconfig\openblas.pc"
$unix_out_root = $out_root -replace '\\','/'
(Get-Content -path $pkg_cfg_pc -Raw) `
-replace "(?m)^libdir=.*$", "libdir=$unix_out_root/lib" `
-replace "(?m)^includedir=.*$", "includedir=$unix_out_root/include" `
| Set-Content -Path "${pkg_cfg_pc}"