Skip to content

Commit 1559b60

Browse files
authored
CI: use setup-fortran (#1061)
* use setup-fortran * macOS: patch libgfortran
1 parent 0d9da44 commit 1559b60

File tree

1 file changed

+52
-57
lines changed

1 file changed

+52
-57
lines changed

Diff for: .github/workflows/CI.yml

+52-57
Original file line numberDiff line numberDiff line change
@@ -21,70 +21,70 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
os: [ubuntu-latest, macos-11, windows-latest]
25-
gcc_v: [10,11,12] # Version of GFortran we want to use.
24+
os: [ubuntu-latest, macos-12, windows-latest]
25+
toolchain:
26+
- {compiler: gcc, version: 10}
27+
- {compiler: gcc, version: 11}
28+
- {compiler: gcc, version: 12}
29+
- {compiler: gcc, version: 13}
30+
exclude:
31+
- os: macos-12
32+
toolchain: {compiler: gcc, version: 13}
2633
include:
27-
- os: ubuntu-latest
28-
os-arch: linux-x86_64
29-
release-flags: --flag '--static -g -fbacktrace -O3'
30-
31-
- os: macos-11
32-
os-arch: macos-x86_64
33-
release-flags: --flag '-g -fbacktrace -O3'
34-
35-
- os: windows-latest
36-
os-arch: windows-x86_64
37-
release-flags: --flag '--static -g -fbacktrace -O3'
38-
exe: .exe
39-
40-
env:
41-
FC: gfortran
42-
GCC_V: ${{ matrix.gcc_v }}
34+
- os: ubuntu-latest
35+
os-arch: linux-x86_64
36+
release-flags: --flag '--static -g -fbacktrace -O3'
37+
- os: macos-12
38+
os-arch: macos-x86_64
39+
release-flags: --flag '-g -fbacktrace -O3'
40+
- os: windows-latest
41+
os-arch: windows-x86_64
42+
release-flags: --flag '--static -g -fbacktrace -O3'
43+
exe: .exe
4344

4445
steps:
4546
- name: Checkout code
4647
uses: actions/checkout@v4
4748

48-
- name: Install GFortran macOS
49-
if: contains(matrix.os, 'macos')
50-
run: |
51-
ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
52-
which gfortran-${GCC_V}
53-
which gfortran
54-
# Backport gfortran shared libraries to version 9 folder. This is necessary because all macOS releases of fpm
55-
# have these paths hardcoded in the executable (no PIC?). As the gcc ABIs have not changed from 9 to 10, we
56-
# can just create symbolic links for now. This can be removed when an updated fpm release is built with gcc-10
57-
mkdir /usr/local/opt/gcc@9
58-
mkdir /usr/local/opt/gcc@9/lib
59-
mkdir /usr/local/opt/gcc@9/lib/gcc
60-
mkdir /usr/local/opt/gcc@9/lib/gcc/9
61-
mkdir /usr/local/lib/gcc/9
62-
ln -fs /usr/local/opt/gcc@${GCC_V}/lib/gcc/${GCC_V}/libquadmath.0.dylib /usr/local/opt/gcc@9/lib/gcc/9/libquadmath.0.dylib
63-
ln -fs /usr/local/opt/gcc@${GCC_V}/lib/gcc/${GCC_V}/libgfortran.5.dylib /usr/local/opt/gcc@9/lib/gcc/9/libgfortran.5.dylib
64-
ln -fs /usr/local/lib/gcc/${GCC_V}/libgcc_s.1.dylib /usr/local/lib/gcc/9/libgcc_s.1.dylib
65-
66-
- name: Install GFortran Linux
67-
if: contains(matrix.os, 'ubuntu')
68-
run: |
69-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
70-
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
71-
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
72-
73-
- name: Install GFortran Windows
74-
if: contains(matrix.os, 'windows')
75-
run: |
76-
Invoke-WebRequest -Uri $Env:GCC_DOWNLOAD -OutFile mingw-w64.zip
77-
Expand-Archive mingw-w64.zip
78-
echo "$pwd\mingw-w64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
79-
env:
80-
GCC_DOWNLOAD: "https://github.com/brechtsanders/winlibs_mingw/releases/download/10.4.0-10.0.0-msvcrt-r1/winlibs-x86_64-posix-seh-gcc-10.4.0-mingw-w64msvcrt-10.0.0-r1.zip"
49+
- name: Setup Fortran compiler
50+
uses: fortran-lang/[email protected]
51+
id: setup-fortran
52+
with:
53+
compiler: ${{ matrix.toolchain.compiler }}
54+
version: ${{ matrix.toolchain.version }}
8155

8256
# Phase 1: Bootstrap fpm with existing version
8357
- name: Install fpm
8458
uses: fortran-lang/setup-fpm@v5
8559
with:
8660
fpm-version: 'v0.8.0'
8761

62+
# Backport gfortran shared libraries to version 9 folder. This is necessary because the macOS release of fpm
63+
# 0.10.0 used for bootstrapping has these paths hardcoded in the executable.
64+
- name: MacOS patch libgfortran
65+
if: contains(matrix.os, 'macos') && !contains(matrix.toolchain.version, '10')
66+
run: |
67+
which gfortran-${{ matrix.toolchain.version }}
68+
which gfortran
69+
mkdir /usr/local/opt/gcc@10
70+
mkdir /usr/local/opt/gcc@10/lib
71+
mkdir /usr/local/opt/gcc@10/lib/gcc
72+
mkdir /usr/local/opt/gcc@10/lib/gcc/10
73+
mkdir /usr/local/lib/gcc/10
74+
ln -fs /usr/local/opt/gcc@${{ matrix.toolchain.version }}/lib/gcc/${{ matrix.toolchain.version }}/libquadmath.0.dylib /usr/local/opt/gcc@10/lib/gcc/10/libquadmath.0.dylib
75+
ln -fs /usr/local/opt/gcc@${{ matrix.toolchain.version }}/lib/gcc/${{ matrix.toolchain.version }}/libgfortran.5.dylib /usr/local/opt/gcc@10/lib/gcc/10/libgfortran.5.dylib
76+
ln -fs /usr/local/lib/gcc/${{ matrix.toolchain.version }}/libgcc_s.1.dylib /usr/local/lib/gcc/10/libgcc_s.1.dylib
77+
78+
# gcc and g++ will point to clang/clang++: use versioned alias for fpm
79+
- name: MacOS patch C and C++ compilers
80+
if: contains(matrix.os, 'macos')
81+
run: |
82+
echo "CC=gcc-${{ matrix.toolchain.version }}" >> $GITHUB_ENV
83+
echo "FPM_CC=gcc-${{ matrix.toolchain.version }}" >> $GITHUB_ENV
84+
echo "CXX=g++-${{ matrix.toolchain.version }}" >> $GITHUB_ENV
85+
echo "FPM_CXX=g++-${{ matrix.toolchain.version }}" >> $GITHUB_ENV
86+
echo "FPM_LDFLAGS=-lstdc++" >> $GITHUB_ENV
87+
8888
- name: Remove fpm from path
8989
shell: bash
9090
run: |
@@ -139,11 +139,6 @@ jobs:
139139
env:
140140
REGEX: '[0-9]\{1,4\}\.[0-9]\{1,4\}\.[0-9]\{1,4\}'
141141

142-
- name: Build example packages
143-
shell: bash
144-
run: |
145-
ci/run_tests.sh "${{ env.FPM }}"
146-
147142
- name: Build Fortran fpm
148143
shell: bash
149144
run: |
@@ -173,7 +168,7 @@ jobs:
173168
rm -v ${{ env.FPM }}
174169
echo "FPM_RELEASE=${{ env.EXE }}" >> $GITHUB_ENV
175170
env:
176-
EXE: fpm-${{ env.VERSION }}-${{ matrix.os-arch }}-gcc-${{ matrix.gcc_v }}${{ matrix.exe }}
171+
EXE: fpm-${{ env.VERSION }}-${{ matrix.os-arch }}-gcc-${{ matrix.toolchain.version }}${{ matrix.exe }}
177172

178173
- name: Run release version
179174
shell: bash

0 commit comments

Comments
 (0)