From 8b5319350bc46e9087c0cfd14e80e59bdebb8b47 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Mon, 6 Dec 2021 19:01:47 +0000 Subject: [PATCH 1/3] Build openblas with ucrt mingw --- build_openblas.ps1 | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 build_openblas.ps1 diff --git a/build_openblas.ps1 b/build_openblas.ps1 new file mode 100755 index 0000000..a713579 --- /dev/null +++ b/build_openblas.ps1 @@ -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}" From f7de5b68e619cce4c70e6cf7d7949cc4ab7b091b Mon Sep 17 00:00:00 2001 From: mattip Date: Wed, 18 May 2022 12:59:16 +0300 Subject: [PATCH 2/3] use mingw 11.2 and build_openblas.ps1 script --- .github/workflows/build.yml | 15 ++++++++++++--- build_openblas.ps1 => tools/build_openblas.ps1 | 0 2 files changed, 12 insertions(+), 3 deletions(-) rename build_openblas.ps1 => tools/build_openblas.ps1 (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 52f65fa..16d39a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,14 +46,22 @@ jobs: choco install -y zip - run: | - choco install -y mingw --forcex86 --force --version=8.1.0 + choco install -y mingw --forcex86 --force --version=11.2 choco install -y make - name: Install 32-bit mingw + name: Install 32-bit mingw 11.2 shell: powershell if: ${{ matrix.BUILD_BITS == '32' }} + - run: | + choco install -y mingw --force --version=11.2 + choco install -y make + name: Install 64-bit mingw 11.2 + shell: powershell + if: ${{ matrix.BUILD_BITS != '32' }} + - run: | # see https://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg586184.html + # for gcc 8.1 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 @@ -61,6 +69,7 @@ jobs: fi sed -i -e"s/_mm512_abs_pd (__m512 __A)/_mm512_abs_pd (__m512d __A)/" $include name: Fix gcc bug + if: ${{ 0 }} - name: Build run: | @@ -73,7 +82,7 @@ jobs: fi echo $PATH git submodule update --init --recursive - tools/build_openblas.sh + tools/build_openblas.ps1 - name: Test run: | diff --git a/build_openblas.ps1 b/tools/build_openblas.ps1 similarity index 100% rename from build_openblas.ps1 rename to tools/build_openblas.ps1 From eabedef30a6dac9ad437f67085a4273546232608 Mon Sep 17 00:00:00 2001 From: mattip Date: Thu, 19 May 2022 09:18:00 +0300 Subject: [PATCH 3/3] use rtools instead of mingw, go back to build_openblas.sh --- .github/workflows/build.yml | 39 +++++---------- tools/build_openblas.ps1 | 95 +++++++++++++++++++------------------ 2 files changed, 59 insertions(+), 75 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16d39a9..d98a166 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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; @@ -45,32 +54,6 @@ jobs: echo "START_DIR=$PWD" >> $GITHUB_ENV; choco install -y zip - - run: | - choco install -y mingw --forcex86 --force --version=11.2 - choco install -y make - name: Install 32-bit mingw 11.2 - shell: powershell - if: ${{ matrix.BUILD_BITS == '32' }} - - - run: | - choco install -y mingw --force --version=11.2 - choco install -y make - name: Install 64-bit mingw 11.2 - shell: powershell - if: ${{ matrix.BUILD_BITS != '32' }} - - - run: | - # see https://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg586184.html - # for gcc 8.1 - 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 - if: ${{ 0 }} - - name: Build run: | BITS=${{ matrix.BUILD_BITS }} @@ -82,7 +65,7 @@ jobs: fi echo $PATH git submodule update --init --recursive - tools/build_openblas.ps1 + tools/build_openblas.sh - name: Test run: | diff --git a/tools/build_openblas.ps1 b/tools/build_openblas.ps1 index a713579..aba10db 100755 --- a/tools/build_openblas.ps1 +++ b/tools/build_openblas.ps1 @@ -1,47 +1,48 @@ -# 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}" +# 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}"