handle gcc versions with brew

This commit is contained in:
edoapra 2024-10-08 15:50:56 -07:00
parent 3670d86cce
commit 92cd47cdc7
No known key found for this signature in database
GPG key ID: 9E6A0B70826967BA
2 changed files with 30 additions and 5 deletions

View file

@ -53,19 +53,32 @@ fi
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew reinstall $MPI_IMPL ||true
# HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew link --overwrite $MPI_IMPL ||true
fi
if [ -z "$HOMEBREW_CELLAR" ] ; then
HOMEBREW_CELLAR=/usr/local/Cellar
fi
if [[ "$FC" != "gfortran" ]] && [[ "$FC" == "gfortran*" ]]; then
#install non default gfortran, ie gfortran-9
#get version
mygccver=$(echo "$FC"|cut -d - -f 2)
echo mygccver is "$mygccver"
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew reinstall gcc@"$mygccver" || true
export PATH=$HOMEBREW_CELLAR/../opt/gcc@"$mygccver"/bin:$PATH
echo gfortran is $(gfortran -v)
echo gfortran-"$mygccver" is $(gfortran-"$mygccver" -v)
fi
if [[ "$CC" != gcc ]] && [[ "$CC" == gcc* ]]; then
#install non default gfortran, ie gcc-9
#get version
mygccver=$(echo "$CC"|cut -d - -f 2)
echo mygccver is "$mygccver"
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew reinstall gcc@"$mygccver" || true
export PATH=$HOMEBREW_CELLAR/../opt/gcc@"$mygccver"/bin:$PATH
echo gcc is $(gcc -v)
echo gcc-"$mygccver" is $(gcc-"$mygccver" -v)
fi
#hack to fix Github actions mpif90
gccver=`brew list --versions gcc| head -1 |cut -c 5-`
echo brew gccver is $gccver
if [ -z "$HOMEBREW_CELLAR" ] ; then
HOMEBREW_CELLAR=/usr/local/Cellar
fi
ln -sf $HOMEBREW_CELLAR/gcc/$gccver/bin/gfortran-* $HOMEBREW_CELLAR/gcc/$gccver/bin/gfortran || true
ln -sf $HOMEBREW_CELLAR/gcc/$gccver/bin/gfortran-* /usr/local/bin/gfortran || true
# ln -sf /usr/local/bin/$FC /usr/local/bin/gfortran
@ -125,10 +138,10 @@ fi
if [[ "$MPI_IMPL" != "build_mpich" ]]; then
#check mpi install
if [[ "$MPI_IMPL" == "mpich" ]]; then
echo 'mpicc -show' $("$HOMEBREW_PREFIX"/opt/mpich/bin/mpif90 -show)
echo 'mpi90 -show' $("$HOMEBREW_PREFIX"/opt/mpich/bin/mpif90 -show)
fi
if [[ "$MPI_IMPL" == "openmpi" ]]; then
echo 'mpicc -show' $("$HOMEBREW_PREFIX"/opt/open-mpi/bin/mpif90 -show)
echo 'mpif90 -show' $("$HOMEBREW_PREFIX"/opt/open-mpi/bin/mpif90 -show)
fi
fi
if [[ "$BLAS_ENV" == "brew_openblas" ]]; then

View file

@ -70,6 +70,18 @@ if [[ "$FC" == "ifort" ]] || [[ "$FC" == "ifx" ]] ; then
#force icc on macos to cross-compile x86 on arm64
# icx not available on macos
if [[ "$os" == "Darwin" ]]; then
if [[ "$FC" != "gfortran" ]] && [[ "$FC" == "gfortran*" ]]; then
mygccver=$(echo "$FC"|cut -d - -f 2)
export PATH=$HOMEBREW_CELLAR/../opt/gcc@"$mygccver"/bin:$PATH
echo gfortran is $(gfortran -v)
echo gfortran-"$mygccver" is $(gfortran-"$mygccver" -v)
fi
if [[ "$CC" != gcc ]] && [[ "$CC" == gcc* ]]; then
mygccver=$(echo "$CC"|cut -d - -f 2)
export PATH=$HOMEBREW_CELLAR/../opt/gcc@"$mygccver"/bin:$PATH
echo gcc is $(gcc -v)
echo gcc-"$mygccver" is $(gcc-"$mygccver" -v)
fi
# CC=icc
# CXX=icc
# Intel MPI not available on macos