From 335731282c6bd88d4ee04d338ded8acca4a2267d Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Sat, 2 Sep 2023 09:36:08 -0400 Subject: [PATCH] Fixed several issues with build scripts that allow for shared library builds on Mac and Linux --- buildscripts/_build_getopts.sh | 4 +-- buildscripts/build_macwheels.sh | 9 +++-- buildscripts/intelbash.sh | 5 +++ buildscripts/set_compilers.sh | 59 ++++++++++----------------------- pyproject.toml | 2 +- 5 files changed, 32 insertions(+), 47 deletions(-) create mode 100755 buildscripts/intelbash.sh diff --git a/buildscripts/_build_getopts.sh b/buildscripts/_build_getopts.sh index 4380b4ad7..fc9728db7 100755 --- a/buildscripts/_build_getopts.sh +++ b/buildscripts/_build_getopts.sh @@ -45,9 +45,9 @@ while getopts ":d:p:m:h" ARG; do done read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) -BUILD_DIR=${BUILD_DIR:-$(mktemp -ut swiftest_build)} +BUILD_DIR=${BUILD_DIR:-$(mktemp -ut swiftest_build.XXXXXXXX)} PREFIX=${PREFIX:-${ROOT_DIR}} -DEPENDENCY_DIR=${DEPENDENCY_DIR:-${BUILD_DIR}/downloads} +DEPENDENCY_DIR=${DEPENDENCY_DIR:-${BUILD_DIR}} if [ -z ${DEPENDENCY_ENV_VARS+x} ]; then . ${SCRIPT_DIR}/set_compilers.sh diff --git a/buildscripts/build_macwheels.sh b/buildscripts/build_macwheels.sh index 366bead2e..49acbec91 100755 --- a/buildscripts/build_macwheels.sh +++ b/buildscripts/build_macwheels.sh @@ -18,10 +18,13 @@ PREFIX=${ROOT_DIR} DEPENDENCY_DIR=${BUILD_DIR}/downloads # The versions of MacOS that we have development tools for -declare -a MACVER=("10.13" "11.0" "12.4" "13.0") +declare -a MACVER=("10.13" "11.0" "12.0" "13.0") for MACOSX_DEPLOYMENT_TARGET in "${MACVER[@]}"; do ARGS="-p ${PREFIX} -d ${DEPENDENCY_DIR} -m ${MACOSX_DEPLOYMENT_TARGET}" + printf "**********************************************************************\n" + printf "ARGS: ${ARGS}\n" + printf "**********************************************************************\n" if [ "${MACOSX_DEPLOYMENT_TARGET}" != "10.13" ]; then ${SCRIPT_DIR}/build_dependencies.sh ${ARGS} @@ -30,8 +33,8 @@ for MACOSX_DEPLOYMENT_TARGET in "${MACVER[@]}"; do fi if [ "${MACOSX_DEPLOYMENT_TARGET}" != "13.0" ]; then - arch -x86_64 /bin/bash -c "${SCRIPT_DIR}/build_dependencies.sh ${ARGS}" - arch -x86_64 /bin/bash -c "${SCRIPT_DIR}/build_swiftest.sh ${ARGS}" + ${SCRIPT_DIR}/intelbash.sh ${SCRIPT_DIR}/build_dependencies.sh ${ARGS} + ${SCRIPT_DIR}/intelbash.sh ${SCRIPT_DIR}/build_swiftest.sh ${ARGS} cmake -P distclean.cmake fi done diff --git a/buildscripts/intelbash.sh b/buildscripts/intelbash.sh new file mode 100755 index 000000000..7f42e5534 --- /dev/null +++ b/buildscripts/intelbash.sh @@ -0,0 +1,5 @@ +#!/bin/bash +ARGS=$@ + +eval "$(/usr/local/bin/brew shellenv)" +arch -x86_64 /bin/bash -c "${ARGS}" diff --git a/buildscripts/set_compilers.sh b/buildscripts/set_compilers.sh index 8a78ade50..7523628ee 100755 --- a/buildscripts/set_compilers.sh +++ b/buildscripts/set_compilers.sh @@ -30,49 +30,26 @@ set -a # Only replace compiler definitions if they are not already set case $OS in Linux) - FC=${$(command -v gfortran)} - CC=${$(command -v gcc)} - CXX=${$(command -v g++)} - CPP=${$(command -v cpp)} + FC=$(command -v gfortran) + CC=$(command -v gcc) + CXX=$(command -v g++) + CPP=$(command -v cpp) ;; MacOSX) - # For Apple Silicon, use native clang for everything except gfortran, in which case we assume Homebrew - # For Intel, use Homebrew for everything - case $ARCH in - arm64) - COMPILER_PREFIX="/usr" - CC=${COMPILER_PREFIX}/bin/clang - CXX=${COMPILER_PREFIX}/bin/clang++ - CPP=${COMPILER_PREFIX}/bin/cpp - AR=${COMPILER_PREFIX}/bin/ar - NM=${COMPILER_PREFIX}/bin/nm - RANLIB=${COMPILER_PREFIX}/bin/ranlib - - # Use Homebrew gfortran location for a given MacOS Target version if vailable - FROOT=/opt/homebrew - FC=${FROOT}/bin/gfortran - LDFLAGS="-Wl,-no_compact_unwind" - CFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -Wno-deprecated-non-prototype" - LD_LIBRARY_PATH="" - CPATH="" - ;; - x86_64) - COMPILER_PREFIX=/usr/local - CC=${COMPILER_PREFIX}/bin/gcc-13 - CXX=${COMPILER_PREFIX}/bin/g++-13 - CPP=${COMPILER_PREFIX}/bin/cpp-13 - AR=${COMPILER_PREFIX}/bin/gcc-ar-13 - NM=${COMPILER_PREFIX}/bin/gcc-nm-13 - RANLIB=${COMPILER_PREFIX}/bin/gcc-ranlib-13 - - # Use custom gfortran location for a given MacOS Target version if vailable - FC=${COMPILER_PREFIX}/bin/gfortran-13 - LDFLAGS="-Wl,-no_compact_unwind" - CFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -Wno-deprecated-non-prototype" - LD_LIBRARY_PATH="" - CPATH="" - ;; - esac + FC=${HOMEBREW_PREFIX}/bin/gfortran-12 + CFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -Wno-deprecated-non-prototype -arch ${ARCH}" + FCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -arch ${ARCH}" + FFLAGS=$FCFLAGS + LD_LIBRARY_PATH="" + CPATH="" + COMPILER_PREFIX="/usr" + CC=${COMPILER_PREFIX}/bin/clang + CXX=${COMPILER_PREFIX}/bin/clang++ + CPP=${COMPILER_PREFIX}/bin/cpp + AR=${COMPILER_PREFIX}/bin/ar + NM=${COMPILER_PREFIX}/bin/nm + RANLIB=${COMPILER_PREFIX}/bin/ranlib + LDFLAGS="-Wl,-no_compact_unwind" ;; *) printf "Unknown compiler type: ${OS}\n" diff --git a/pyproject.toml b/pyproject.toml index 0a7efb357..e445532a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,6 @@ skip = "pp* *i686 *-manylinux_i686 *_ppc64le *_s390x *-musllinux* *-win32" [tool.cibuildwheel.linux] environment = {FFLAGS="${FFLAGS} -fPIC", CFLAGS="${CFLAGS} -fPIC", LDFLAGS="${LDFLAGS} -fPIE", LIBS="-lgomp"} before-all = [ - "yum install doxygen -y || apt-get install doxygen -y", + "yum install doxygen libxml2-devel -y || apt-get install doxygen libxml2-dev -y", "buildscripts/build_dependencies.sh -p /usr/local", ]