From 92cd47cdc7e8bb86ed9db0e01915859c619c5bde Mon Sep 17 00:00:00 2001 From: edoapra Date: Tue, 8 Oct 2024 15:50:56 -0700 Subject: [PATCH] handle gcc versions with brew --- travis/build_env.sh | 23 ++++++++++++++++++----- travis/nwchem.bashrc | 12 ++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/travis/build_env.sh b/travis/build_env.sh index 596905dd20..30fb51220d 100755 --- a/travis/build_env.sh +++ b/travis/build_env.sh @@ -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 diff --git a/travis/nwchem.bashrc b/travis/nwchem.bashrc index d52f9e32ae..90f8046052 100644 --- a/travis/nwchem.bashrc +++ b/travis/nwchem.bashrc @@ -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