Skip to content

Commit

Permalink
feat(macos): add distribution for apple silicon (#29)
Browse files Browse the repository at this point in the history
Introduce a statically linked distribution built with GCC 12 for ARM macs.

Also, update integration.yml:

* add a macos-14 test job building with GCC 12 and requisite workarounds
* bump linux test job runner image ubuntu-20.04 -> ubuntu-22.04
  • Loading branch information
wpbonelli committed Jun 20, 2024
1 parent 3515643 commit 5b80421
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 147 deletions.
57 changes: 49 additions & 8 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, macos-latest, windows-2019 ]
os: [ ubuntu-22.04, macos-13, macos-14, windows-2019 ]
defaults:
run:
shell: bash -l {0}
Expand All @@ -33,17 +33,39 @@ jobs:
cache-downloads: true
init-shell: bash

- name: Setup Intel fortran
- name: Setup ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 'gcc' || 'intel-classic' }} ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 12 || 2021.7 }}
uses: fortran-lang/setup-fortran@v1
with:
compiler: intel-classic
version: 2021.7
compiler: ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 'gcc' || 'intel-classic' }}
version: ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 12 || 2021.7 }}

- name: Set LDFLAGS (macOS)
if: matrix.os == 'macos-14'
run: |
os_ver=$(sw_vers -productVersion | cut -d'.' -f1)
if (( "$os_ver" > 12 )); then
ldflags="$LDFLAGS -Wl,-ld_classic"
echo "LDFLAGS=$ldflags" >> $GITHUB_ENV
fi
- name: Hide dylibs (macOS)
if: matrix.os == 'macos-14'
run: |
version="12"
libpath="/opt/homebrew/opt/gcc@$version/lib/gcc/$version"
mv $libpath/libgfortran.5.dylib $libpath/libgfortran.5.dylib.bak
mv $libpath/libquadmath.0.dylib $libpath/libquadmath.0.dylib.bak
mv $libpath/libstdc++.6.dylib $libpath/libstdc++.6.dylib.bak
# only necessary because we need mf5to6 for mf6 autotests
- name: Build modflow6
working-directory: modflow6
run: |
meson setup builddir --prefix=$(pwd) --libdir=bin -Ddebug=false
setupargs="--prefix=$(pwd) --libdir=bin -Ddebug=false"
if [[ "${{ matrix.os }}" == "macos-14" ]]; then
setupargs="$setupargs -Doptimization=1"
fi
meson setup builddir $setupargs
meson install -C builddir
- name: Get OS tag
Expand All @@ -53,11 +75,24 @@ jobs:
echo "ostag=$ostag" >> $GITHUB_OUTPUT
- name: Build programs
uses: nick-fields/retry@v3
with:
shell: bash
timeout_minutes: 40
command: |
ostag="${{ steps.ostag.outputs.ostag }}"
mkdir $ostag
make-program : --appdir $ostag --zip $ostag.zip --verbose
make-program mf2005,mflgr,mfnwt,mfusg --appdir $ostag --double --keep --zip $ostag.zip --verbose
if [[ "${{ matrix.os }}" == "macos-14" ]]; then
make-program mf6 --appdir $ostag --keep --zip $ostag.zip --verbose --fflags='-O1'
fi
make-code-json --appdir $ostag --zip $ostag.zip --verbose
- name: Move programs
run: |
# build programs
ostag="${{ steps.ostag.outputs.ostag }}"
mkdir $ostag
python executables/scripts/build_programs.py -p $ostag
# move programs where mf6 autotests expect them
mkdir modflow6/bin/downloaded
Expand All @@ -83,6 +118,12 @@ jobs:
sudo chmod +x modflow6/bin/*
sudo chmod +x modflow6/bin/downloaded/*
fi
- name: Check linked libs (macOS)
if: matrix.os == 'macos-14'
run: |
ostag="${{ steps.ostag.outputs.ostag }}"
find $ostag -perm +111 -type f | xargs -I{} sh -c "otool -L {}"
- name: Upload programs
uses: actions/upload-artifact@v3
Expand All @@ -94,7 +135,7 @@ jobs:
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: metadata
name: ${{ steps.ostag.outputs.ostag }}
path: |
./code.json
./code.md
Expand Down
85 changes: 69 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ on:
branches:
- master
workflow_dispatch:
env:
DIST: dist
jobs:
build:
name: Build distribution
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-latest, windows-2019]
os: [ubuntu-22.04, macos-13, macos-14, windows-2019]
defaults:
run:
shell: bash
Expand All @@ -25,11 +23,35 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Intel fortran
- name: Setup ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 'gcc' || 'intel-classic' }} ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 12 || 2021.7 }}
uses: fortran-lang/setup-fortran@v1
with:
compiler: intel-classic
version: 2021.7
compiler: ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 'gcc' || 'intel-classic' }}
version: ${{ contains(fromJSON('["macos-14"]'), matrix.os) && 12 || 2021.7 }}

- name: Set LDFLAGS (ARM mac)
if: matrix.os == 'macos-14'
run: |
os_ver=$(sw_vers -productVersion | cut -d'.' -f1)
if (( "$os_ver" > 12 )); then
ldflags="$LDFLAGS -Wl,-ld_classic"
echo "LDFLAGS=$ldflags" >> $GITHUB_ENV
fi
- name: Hide dylibs (ARM mac)
if: matrix.os == 'macos-14'
run: |
version="12"
libpath="/opt/homebrew/opt/gcc@$version/lib/gcc/$version"
mv $libpath/libgfortran.5.dylib $libpath/libgfortran.5.dylib.bak
mv $libpath/libquadmath.0.dylib $libpath/libquadmath.0.dylib.bak
mv $libpath/libstdc++.6.dylib $libpath/libstdc++.6.dylib.bak
- name: Setup Xcode CLT (mac)
uses: maxim-lobanov/setup-xcode@v1
if: runner.os == 'macOS'
with:
xcode-version: "14.3.1"

- uses: oprypin/find-latest-tag@v1
id: tag
Expand All @@ -53,20 +75,44 @@ jobs:
pip install -r requirements.txt
pip list
- name: Get OS tag
id: ostag
run: |
ostag=$(python -c "from modflow_devtools.ostags import get_ostag; print(get_ostag())")
echo "ostag=$ostag" >> $GITHUB_OUTPUT
- name: Build programs
run: python scripts/build_programs.py
uses: nick-fields/retry@v3
with:
shell: bash
timeout_minutes: 40
command: |
ostag="${{ steps.ostag.outputs.ostag }}"
mkdir $ostag
make-program : --appdir $ostag --zip $ostag.zip --verbose
make-program mf2005,mflgr,mfnwt,mfusg --appdir $ostag --double --keep --zip $ostag.zip --verbose
if [[ "${{ matrix.os }}" == "macos-14" ]]; then
make-program mf6 --appdir $ostag --keep --zip $ostag.zip --verbose --fflags='-O1'
fi
make-code-json --appdir $ostag --zip $ostag.zip --verbose
- name: Check linked libs (ARM mac)
if: matrix.os == 'macos-14'
run: |
ostag="${{ steps.ostag.outputs.ostag }}"
find $ostag -perm +111 -type f | xargs -I{} sh -c "otool -L {}"
- name: Upload distribution archive
uses: actions/upload-artifact@v3
with:
name: ${{ env.DIST }}
name: ${{ steps.ostag.outputs.ostag }}
path: ./*.zip

- name: Upload distribution metadata
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: ${{ env.DIST }}
name: ${{ steps.ostag.outputs.ostag }}
path: |
./code.json
./code.md
Expand All @@ -93,6 +139,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install https://github.com/modflowpy/pymake/zipball/master
pip install https://github.com/MODFLOW-USGS/modflow-devtools/zipball/develop
- name: Get last release tag
id: last-tag
Expand All @@ -112,14 +159,20 @@ jobs:
echo "$repo current version is $current"
echo "$repo next version is $next"
- name: Get OS tag
id: ostag
run: |
ostag=$(python -c "from modflow_devtools.ostags import get_ostag; print(get_ostag())")
echo "ostag=$ostag" >> $GITHUB_OUTPUT
- name: Download distribution
uses: actions/download-artifact@v3
with:
name: ${{ env.DIST }}
path: ${{ env.DIST }}
name: ${{ steps.ostag.outputs.ostag }}
path: ${{ steps.ostag.outputs.ostag }}

- name: List distribution files
run: ls -l ${{ env.DIST }}
run: ls -l ${{ steps.ostag.outputs.ostag }}

- name: Create release body header
shell: python
Expand All @@ -134,7 +187,7 @@ jobs:
- name: Build release body
run: |
cat Header.md ${{ env.DIST }}/code.md > BodyFile.md
cat Header.md ${{ steps.ostag.outputs.ostag }}/code.md > BodyFile.md
cat BodyFile.md
# interactive debugging
Expand All @@ -147,8 +200,8 @@ jobs:
id: update-readme
run: |
# update readme from metadata
cp ${{ env.DIST }}/code.md code.md
cp ${{ env.DIST }}/code.json code.json
cp ${{ steps.ostag.outputs.ostag }}/code.md code.md
cp ${{ steps.ostag.outputs.ostag }}/code.json code.json
python scripts/update_readme.py
# determine whether changes need to be committed
Expand Down Expand Up @@ -195,7 +248,7 @@ jobs:
tag: ${{ steps.next-tag.outputs.tag }}
name: "MODFLOW and related programs binary executables"
bodyFile: "./BodyFile.md"
artifacts: "${{ env.DIST }}/*"
artifacts: "${{ steps.ostag.outputs.ostag }}/*"
draft: false
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
123 changes: 0 additions & 123 deletions scripts/build_programs.py

This file was deleted.

0 comments on commit 5b80421

Please sign in to comment.