Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Made some adjustments to scripts to ensure the proper gcc version for…
Browse files Browse the repository at this point in the history
… the dependency build
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Aug 18, 2023
1 parent 3edf4d9 commit cfc7705
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 51 deletions.
8 changes: 3 additions & 5 deletions buildscripts/_build_getopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ SCRIPT_DIR=$(realpath $(dirname $0))
ROOT_DIR=$(realpath ${SCRIPT_DIR}/..)

# Parse arguments
USTMT="Usage: ${0} <-d /path/to/dependency/source> [-p /prefix/path|{/usr/local}] [-m MACOSX_DEPLOYMENT_TARGET|{10.9}]"
USTMT="Usage: ${0} <-d /path/to/dependency/source> [-p /prefix/path|{/usr/local}] [-m MACOSX_DEPLOYMENT_TARGET|{11.0}]"
PREFIX=/usr/local
DEPENDENCY_DIR="${ROOT_DIR}/_dependencies"
MACOSX_DEPLOYMENT_TARGET="10.9"
MACOSX_DEPLOYMENT_TARGET="11.0"
while getopts ":d:p:m:h" ARG; do
case "${ARG}" in
d)
Expand Down Expand Up @@ -59,9 +59,7 @@ case $OS in
esac

if [ -z ${DEPENDENCY_ENV_VARS+x} ]; then
CMD="${SCRIPT_DIR}/set_compilers.sh -c $COMPILER"
read -r CC CXX FC F77 CPP < <($CMD)
unset CMD
. ${SCRIPT_DIR}/set_compilers.sh

LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}"
CPPFLAGS="${CPPFLAGS} -isystem ${PREFIX}/include"
Expand Down
75 changes: 30 additions & 45 deletions buildscripts/set_compilers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,6 @@
# You should have received a copy of the GNU General Public License along with Swiftest.
# If not, see: https://www.gnu.org/licenses.
# Parse arguments
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-f|--force-ifort]"
IFORT=false
COMPILER=""
while getopts ":c:f" ARG; do
case "${ARG}" in
f)
;;
c)
COMPILER="${OPTARG}"
;;
:)
echo "Error: -${OPTARG} requires an argument."
echo $USTMT
exit 1
;;
*)
;;
esac
done

case "$COMPILER" in
Intel|GNU-Linux|GNU-Mac)
;;
Expand All @@ -45,28 +25,29 @@ case "$COMPILER" in
;;
esac

set -a
# Only replace compiler definitions if they are not already set
case $COMPILER in
Intel)
if [ ! -v FC ]; then
if command -v ifx &> /dev/null; then
export FC=$(command -v ifx)
FC=$(command -v ifx)
elif command -v ifort &> /dev/null; then
export FC=$(command -v mpiifort)
FC=$(command -v mpiifort)
else
printf "Error. Cannot find valid Intel Fortran compiler.\n"
exit 1
fi
fi
if [ ! -v F77 ]; then
export F77="${FC}"
F77="${FC}"
fi

if [ ! -v CC ]; then
if command -v icx &> /dev/null; then
export CC=$(command -v icx)
CC=$(command -v icx)
elif command -v icc &> /dev/null; then
export CC=$(command -v icc)
CC=$(command -v icc)
else
printf "Error. Cannot find valid Intel C compiler.\n"
exit 1
Expand All @@ -75,43 +56,49 @@ case $COMPILER in

if [ ! -v CXX ]; then
if command -v icpx &> /dev/null; then
export CXX=$(command -v icpx)
CXX=$(command -v icpx)
elif command -v icpc &> /dev/null; then
export CXX=$(command -v icpc)
CXX=$(command -v icpc)
else
printf "Error. Cannot find valid Intel C++ compiler.\n"
exit 1
fi
fi

if command -v mpiifort &> /dev/null; then
export I_MPI_F90=${FC}
export FC=$(command -v mpiifort)
I_MPI_F90=${FC}
FC=$(command -v mpiifort)
fi

if command -v mpiicc &> /dev/null; then
export I_MPI_CC =${CC}
export CC=$(command -v mpiicc)
I_MPI_CC =${CC}
CC=$(command -v mpiicc)
fi

if command -v mpiicpc &> /dev/null; then
export I_MPI_CXX =${CXX}
export CXX=$(command -v mpiicpc)
I_MPI_CXX =${CXX}
CXX=$(command -v mpiicpc)
fi

export CPP=${CPP:-$HOMEBRE_PREFIX/bin/cpp-13}
CPP=${CPP:-$HOMEBRE_PREFIX/bin/cpp-13}
;;
GNU-Linux)
export FC=${FC:-$(command -v gfortran)}
export CC=${CC:-$(command -v gcc)}
export CXX=${CXX:-$(command -v g++)}
export CPP=${CPP:-$(command -v cpp)}
FC=${FC:-$(command -v gfortran)}
CC=${CC:-$(command -v gcc)}
CXX=${CXX:-$(command -v g++)}
CPP=${CPP:-$(command -v cpp)}
;;
GNU-Mac)
export FC=${FC:-$HOMEBREW_PREFIX/bin/gfortran-13}
export CC=${CC:-$HOMEBREW_PREFIX/bin/gcc-13}
export CXX=${CXX:-$HOMEBREW_PREFIX/bin/g++-13}
export CPP=${CPP:-$HOMEBRE_PREFIX/bin/cpp-13}
MAJOR=$(echo ${MACOSX_DEPLOYMENT_TARGET} | awk '{print $1}' FS=.)
printf "MACOS Major Version: ${MAJOR}\n"
FC=${FC:-$HOMEBREW_PREFIX/bin/gfortran-${MAJOR}}
CC=${CC:-$HOMEBREW_PREFIX/bin/gcc-${MAJOR}}
CXX=${CXX:-$HOMEBREW_PREFIX/bin/g++-${MAJOR}}
CPP=${CPP:-$HOMEBREW_PREFIX/bin/cpp-${MAJOR}}
AR=${AR:-$HOMEBREW_PREFIX/bin/gcc-ar-${MAJOR}}
NM=${NM:-$HOMEBREW_PREFIX/bin/gcc-nm-${MAJOR}}
RANLIB=${RANLIB:-$HOMEBREW_PREFIX/bin/gcc-ranlib-${MAJOR}}
LD_LIBRARY_PATH="${HOMEBREW_PREFIX}/lib/gcc/${MAJOR}/lib:${LD_LIBRARY_PATH}"
;;
*)
printf "Unknown compiler type: ${COMPILER}\n"
Expand All @@ -120,6 +107,4 @@ case $COMPILER in
exit 1
;;
esac
export F77=${FC}

printf "${CC} ${CXX} ${FC} ${F77} ${CPP}"
F77=${FC}
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ test-skip = "cp312-*"
skip = "pp*"

[tool.cibuildwheel.linux]
archs = ["x86_64", "aarch64"]

environment = {SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=OFF", FFLAGS="${FFLAGS} -fPIC", CFLAGS="${CFLAGS} -fPIC", LDFLAGS="${LDFLAGS} -fPIE", LIBS="-lgomp"}
before-all = [
"yum install wget m4 doxygen -y",
"buildscripts/build_dependencies.sh -d /_dependencies -p /usr/local",
]

[tool.cibuildwheel.macos]
environment = {PATH="${TMPDIR}/bin:${PATH}",MACOSX_DEPLOYMENT_TARGET="10.9", LD_LIBRARY_PATH="${TMPDIR}/lib:${LD_LIBRARY_PATH}",CPPFLAGS="${CPPFLAGS} -isystem ${TMPDIR}/include",LDFLAGS="${LDFLAGS} -L${TMPDIR}/lib -fPIE -Wl,-no_compact_unwind",CPATH="${CPATH} ${TMPDIR}/include}", CFLAGS="${CFLAGS} -Wno-unused-but-set-variable -fPIC -Wno-deprecated-non-prototype", SKBUILD_CONFIGURE_OPTIONS="-DUSE_OPENMP=OFF -DUSE_SIMD=OFF -DBUILD_SHARED_LIBS=OFF",FFLAGS="${FFLAGS} -fPIC"}
archs = ["x86_64", "universal2", "arm64"]
environment = {PATH="${TMPDIR}/bin:${PATH}",MACOSX_DEPLOYMENT_TARGET="11.0", LD_LIBRARY_PATH="${TMPDIR}/lib:${LD_LIBRARY_PATH}",CPPFLAGS="${CPPFLAGS} -isystem ${TMPDIR}/include",LDFLAGS="${LDFLAGS} -L${TMPDIR}/lib -fPIE -Wl,-no_compact_unwind",CPATH="${CPATH} ${TMPDIR}/include}", CFLAGS="${CFLAGS} -Wno-unused-but-set-variable -fPIC -Wno-deprecated-non-prototype", SKBUILD_CONFIGURE_OPTIONS="-DUSE_OPENMP=OFF -DUSE_SIMD=OFF -DBUILD_SHARED_LIBS=OFF",FFLAGS="${FFLAGS} -fPIC"}
before-all = [
"buildscripts/build_dependencies.sh -d ${TMPDIR} -p ${TMPDIR} -m ${MACOSX_DEPLOYMENT_TARGET}"
]
Expand Down

0 comments on commit cfc7705

Please sign in to comment.