Skip to content

Build openblas with ucrt mingw #76

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 3 commits into from
Closed
Show file tree
Hide file tree
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
28 changes: 10 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ jobs:
- uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1

- name: Setup
- name: install-rtools
run: |
choco install rtools --no-progress
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
- name: show-gfortran
run: |
gcc --version
gfortran --version - name: Setup

- name: Set env variables
run: |
BITS=${{ matrix.BUILD_BITS }}
echo "BUILD_BITS=$BITS" >> $GITHUB_ENV;
Expand All @@ -45,23 +54,6 @@ jobs:
echo "START_DIR=$PWD" >> $GITHUB_ENV;
choco install -y zip

- run: |
choco install -y mingw --forcex86 --force --version=8.1.0
choco install -y make
name: Install 32-bit mingw
shell: powershell
if: ${{ matrix.BUILD_BITS == '32' }}

- run: |
# see https://www.mail-archive.com/[email protected]/msg586184.html
if [ "${{ matrix.BUILD_BITS }}" == "64" ]; then
include=/c/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/avx512fintrin.h
else
include=/c/ProgramData/Chocolatey/lib/mingw/tools/install/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/avx512fintrin.h
fi
sed -i -e"s/_mm512_abs_pd (__m512 __A)/_mm512_abs_pd (__m512d __A)/" $include
name: Fix gcc bug

- name: Build
run: |
BITS=${{ matrix.BUILD_BITS }}
Expand Down
48 changes: 48 additions & 0 deletions tools/build_openblas.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Build script for OpenBLAS on Windows
# Expects environment variables:
# $OPENBLAS_ROOT="c:\opt\openblas"
# $INTERFACE64
# $BITS
$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"

# Set suffixed-ILP64 flags
if [ "$INTERFACE64" == "1" ]; then
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}"