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

Commit

Permalink
Fixed several issues with build scripts that allow for shared library…
Browse files Browse the repository at this point in the history
… builds on Mac and Linux
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Sep 2, 2023
1 parent abe9c52 commit 3357312
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 47 deletions.
4 changes: 2 additions & 2 deletions buildscripts/_build_getopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions buildscripts/build_macwheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions buildscripts/intelbash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
ARGS=$@

eval "$(/usr/local/bin/brew shellenv)"
arch -x86_64 /bin/bash -c "${ARGS}"
59 changes: 18 additions & 41 deletions buildscripts/set_compilers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

0 comments on commit 3357312

Please sign in to comment.