Skip to content

Commit 7568081

Browse files
committed
Refactor build to use Powershell
Refactor build_gfortran to run builds in own directory.
1 parent 8c8ec9d commit 7568081

File tree

4 files changed

+50
-65
lines changed

4 files changed

+50
-65
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: Windows build
42

5-
defaults:
6-
run:
7-
shell: bash
8-
93
on:
104
push:
115
branches: [ master ]
@@ -15,13 +9,16 @@ on:
159
env:
1610
OPENBLAS_COMMIT: "bfd9c1b58cd3"
1711
OPENBLAS_ROOT: "c:\\opt"
12+
# Preserve working directory for calls into bash
13+
CHERE_INVOKING: "yes"
14+
BASH_PATH: "c:\\rtools40\\usr\\bin\\bash"
1815

1916
jobs:
2017
build:
2118
strategy:
2219
matrix:
2320
BUILD_BITS: [64, 32]
24-
INTERFACE64: ['1', '']
21+
INTERFACE64: ['1', '0']
2522
os: [windows-latest]
2623
exclude:
2724
- BUILD_BITS: 32
@@ -31,65 +28,46 @@ jobs:
3128

3229
steps:
3330
- uses: actions/checkout@v2
34-
- uses: ilammy/msvc-dev-cmd@v1
35-
36-
- name: Setup
31+
- name: install-rtools
3732
run: |
38-
BITS=${{ matrix.BUILD_BITS }}
39-
echo "BUILD_BITS=$BITS" >> $GITHUB_ENV;
40-
if [ "$BITS" == "32" ]; then
41-
echo "PLAT=i686" >> $GITHUB_ENV;
42-
else
43-
echo "PLAT=x86_64" >> $GITHUB_ENV;
44-
fi
45-
echo "START_DIR=$PWD" >> $GITHUB_ENV;
46-
choco install -y zip
47-
48-
- run: |
49-
choco install -y mingw --forcex86 --force --version=8.1.0
50-
choco install -y make
51-
name: Install 32-bit mingw
52-
shell: powershell
53-
if: ${{ matrix.BUILD_BITS == '32' }}
33+
choco install rtools --no-progress
5434
55-
- run: |
56-
# see https://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg586184.html
57-
if [ "${{ matrix.BUILD_BITS }}" == "64" ]; then
58-
include=/c/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/avx512fintrin.h
59-
else
60-
include=/c/ProgramData/Chocolatey/lib/mingw/tools/install/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/avx512fintrin.h
61-
fi
62-
sed -i -e"s/_mm512_abs_pd (__m512 __A)/_mm512_abs_pd (__m512d __A)/" $include
63-
name: Fix gcc bug
35+
- name: Set env variables
36+
run: |
37+
echo "START_DIR=$PWD" >> $env:GITHUB_ENV
38+
$BITS = ${{ matrix.BUILD_BITS }}
39+
echo "BUILD_BITS=$BITS" >> $env:GITHUB_ENV
40+
# For interpretation of MSYSTEM, see:
41+
# https://sourceforge.net/p/msys2/discussion/general/thread/b7dfdac8/#3939
42+
if ($BITS -eq 32) {
43+
echo "PLAT=i686" >> $env:GITHUB_ENV
44+
echo "MSYSTEM=MINGW32" >> $env:GITHUB_ENV
45+
echo "LDFLAGS=-static -static-libgcc" >> $env:GITHUB_ENV
46+
} else {
47+
echo "PLAT=x86_64" >> $env:GITHUB_ENV
48+
echo "MSYSTEM=UCRT64" >> $env:GITHUB_ENV
49+
echo "LDFLAGS=-lucrt -static -static-libgcc" >> $env:GITHUB_ENV
50+
}
51+
if ( ${{ matrix.INTERFACE64 }} -eq 1 ) {
52+
echo "INTERFACE64=1" >> $env:GITHUB_ENV
53+
}
6454
6555
- name: Build
6656
run: |
67-
BITS=${{ matrix.BUILD_BITS }}
68-
if [ "${{ matrix.INTERFACE64 }}" == "1" ]; then
69-
export INTERFACE64=1
70-
fi
71-
if [ "$BITS" == "32" ]; then
72-
export PATH=/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw32/bin:$PATH
73-
fi
74-
echo $PATH
7557
git submodule update --init --recursive
76-
tools/build_openblas.sh
58+
& $env:BASH_PATH -lc tools/build_openblas.sh
7759
7860
- name: Test
7961
run: |
80-
BITS=${{ matrix.BUILD_BITS }}
81-
if [ "$BITS" == "32" ]; then
82-
export PATH=/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw32/bin:$PATH
83-
fi
84-
if [ "${{ matrix.INTERFACE64 }}" == "1" ]; then
85-
export INTERFACE64=1
86-
fi
87-
tools/build_gfortran.sh
88-
cp test.exe builds
89-
cp test_dyn.exe builds
90-
./test.exe
91-
cp $(cygpath $OPENBLAS_ROOT)/$BITS/bin/*.dll .
92-
./test_dyn.exe
62+
& $env:BASH_PATH -lc tools/build_gfortran.sh
63+
echo "Static test"
64+
.\for_test\test.exe
65+
echo "Dynamic test"
66+
.\for_test\test_dyn.exe
67+
68+
- name: Copy
69+
run: |
70+
cp for_test\test*.exe builds
9371
9472
- uses: actions/upload-artifact@v3
9573
with:
@@ -100,4 +78,4 @@ jobs:
10078
OPENBLAS_LIBS_STAGING_UPLOAD_TOKEN: ${{ secrets.MULTIBUILD_WHEELS_STAGING_ACCESS }}
10179
run: |
10280
pip install -q git+https://github.com/Anaconda-Platform/anaconda-client@1.8.0
103-
tools/upload_to_anaconda_staging.sh
81+
& $env:BASH_PATH -lc tools/upload_to_anaconda_staging.sh

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ builds/
33
*~
44
*.pyc
55
*.swp
6-
test.exe
6+
for_test/

OpenBLAS

tools/build_gfortran.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22

33
set -e
44

5-
cd $(cygpath "$START_DIR")
5+
rm -rf for_test
6+
mkdir for_test
7+
cd for_test
8+
9+
repo_path=$(cygpath "$START_DIR")
610
OBP=$(cygpath $OPENBLAS_ROOT\\$BUILD_BITS)
711

812
static_libname=$(find $OBP/lib -maxdepth 1 -type f -name '*.a' \! -name '*.dll.a' | tail -1)
913
dynamic_libname=$(find $OBP/lib -maxdepth 1 -type f -name '*.dll.a' | tail -1)
14+
dll_name=$(echo $dynamic_libname | sed 's#/lib/#/bin/#' | sed 's/.a$//')
15+
16+
cp $dll_name .
1017

1118
if [ "$INTERFACE64" == "1" ]; then
12-
gfortran -I $OBP/include -fdefault-integer-8 -o test.exe test64_.f90 $static_libname
13-
gfortran -I $OBP/include -fdefault-integer-8 -o test_dyn.exe test64_.f90 $dynamic_libname
19+
gfortran -I $OBP/include -fdefault-integer-8 -o test.exe ${repo_path}/test64_.f90 $static_libname
20+
gfortran -I $OBP/include -fdefault-integer-8 -o test_dyn.exe ${repo_path}/test64_.f90 $dynamic_libname
1421
else
15-
gfortran -I $OBP/include -o test.exe test.f90 $static_libname
16-
gfortran -I $OBP/include -o test_dyn.exe test.f90 $dynamic_libname
22+
gfortran -I $OBP/include -o test.exe ${repo_path}/test.f90 $static_libname
23+
gfortran -I $OBP/include -o test_dyn.exe ${repo_path}/test.f90 $dynamic_libname
1724
fi

0 commit comments

Comments
 (0)