Unverified Commit 2bf2b360 authored by Matthew Brett's avatar Matthew Brett Committed by GitHub
Browse files

Merge pull request #384 from isuruf/arm64

MRG: set MACOSX_DEPLOYMENT_TARGET for arm64 build
parents 0d93db54 42799f20
...@@ -434,6 +434,7 @@ To use these scripts ...@@ -434,6 +434,7 @@ To use these scripts
using Rosetta2 emulation. using Rosetta2 emulation.
There are two ways to build ``universal2`` builds. There are two ways to build ``universal2`` builds.
1. Build with ``-arch x86_64 -arch arm64``. 1. Build with ``-arch x86_64 -arch arm64``.
These flags instruct the C/C++ compiler to compile twice and create a These flags instruct the C/C++ compiler to compile twice and create a
fat object/executable/library. This is the easiest, but has several fat object/executable/library. This is the easiest, but has several
......
...@@ -329,6 +329,12 @@ function pip_opts { ...@@ -329,6 +329,12 @@ function pip_opts {
[ -n "$MANYLINUX_URL" ] && echo "--find-links $MANYLINUX_URL" [ -n "$MANYLINUX_URL" ] && echo "--find-links $MANYLINUX_URL"
} }
function get_os {
# Report OS as given by uname
# Use any Python that comes to hand.
python -c 'import platform; print(platform.uname()[0])'
}
function get_platform { function get_platform {
# Report platform as given by uname # Report platform as given by uname
# Use any Python that comes to hand. # Use any Python that comes to hand.
......
...@@ -424,8 +424,8 @@ function activate_ccache { ...@@ -424,8 +424,8 @@ function activate_ccache {
echo "Using C compiler: $(which clang)" echo "Using C compiler: $(which clang)"
} }
function macos_intel_build_setup { function macos_intel_native_build_setup {
# Setup build for single arch x86_64 wheels # Setup native build for single arch x86_64 wheels
export PLAT="x86_64" export PLAT="x86_64"
export _PYTHON_HOST_PLATFORM="macosx-${MB_PYTHON_OSX_VER}-x86_64" export _PYTHON_HOST_PLATFORM="macosx-${MB_PYTHON_OSX_VER}-x86_64"
export CFLAGS+=" -arch x86_64" export CFLAGS+=" -arch x86_64"
...@@ -435,8 +435,13 @@ function macos_intel_build_setup { ...@@ -435,8 +435,13 @@ function macos_intel_build_setup {
export LDFLAGS+=" -arch x86_64" export LDFLAGS+=" -arch x86_64"
} }
function macos_arm64_build_setup { function macos_intel_cross_build_setup {
# Setup build for single arch arm_64 wheels echo "universal2 builds on arm64 are not supported yet."
exit 1
}
function macos_arm64_cross_build_setup {
# Setup cross build for single arch arm_64 wheels
export PLAT="arm64" export PLAT="arm64"
export BUILD_PREFIX=/opt/arm64-builds export BUILD_PREFIX=/opt/arm64-builds
sudo mkdir -p $BUILD_PREFIX sudo mkdir -p $BUILD_PREFIX
...@@ -449,11 +454,22 @@ function macos_arm64_build_setup { ...@@ -449,11 +454,22 @@ function macos_arm64_build_setup {
export ARCHFLAGS+=" -arch arm64" export ARCHFLAGS+=" -arch arm64"
export FCFLAGS+=" -arch arm64" export FCFLAGS+=" -arch arm64"
export FC=$FC_ARM64 export FC=$FC_ARM64
export MACOSX_DEPLOYMENT_TARGET="11.0"
export CROSS_COMPILING=1
export LDFLAGS+=" -arch arm64 -L$BUILD_PREFIX/lib -Wl,-rpath,$BUILD_PREFIX/lib ${FC_ARM64_LDFLAGS:-}" export LDFLAGS+=" -arch arm64 -L$BUILD_PREFIX/lib -Wl,-rpath,$BUILD_PREFIX/lib ${FC_ARM64_LDFLAGS:-}"
# This would automatically let autoconf know that we are cross compiling for arm64 darwin # This would automatically let autoconf know that we are cross compiling for arm64 darwin
export host_alias="aarch64-apple-darwin20.0.0" export host_alias="aarch64-apple-darwin20.0.0"
} }
function macos_arm64_native_build_setup {
# Setup native build for single arch arm_64 wheels
export PLAT="arm64"
# We don't want universal2 builds and only want an arm64 build
export _PYTHON_HOST_PLATFORM="macosx-11.0-arm64"
export ARCHFLAGS+="-arch arm64"
$@
}
function fuse_macos_intel_arm64 { function fuse_macos_intel_arm64 {
local wheelhouse=$(abspath ${WHEEL_SDIR:-wheelhouse}) local wheelhouse=$(abspath ${WHEEL_SDIR:-wheelhouse})
local py_osx_ver=$(echo ${MB_PYTHON_OSX_VER} | sed "s/\./_/g") local py_osx_ver=$(echo ${MB_PYTHON_OSX_VER} | sed "s/\./_/g")
...@@ -475,12 +491,22 @@ function fuse_macos_intel_arm64 { ...@@ -475,12 +491,22 @@ function fuse_macos_intel_arm64 {
function wrap_wheel_builder { function wrap_wheel_builder {
if [[ "${PLAT:-}" == "universal2" ]]; then if [[ "${PLAT:-}" == "universal2" ]]; then
(macos_intel_build_setup && $@) if [[ "$(uname -m)" == "arm64" ]]; then
rm -rf *-stamp (macos_intel_cross_build_setup && $@)
(macos_arm64_build_setup && $@) rm -rf *-stamp
(macos_arm64_native_build_setup && $@)
else
(macos_intel_native_build_setup && $@)
rm -rf *-stamp
(macos_arm64_cross_build_setup && $@)
fi
fuse_macos_intel_arm64 fuse_macos_intel_arm64
elif [[ "${PLAT:-}" == "arm64" ]]; then elif [[ "${PLAT:-}" == "arm64" ]]; then
(macos_arm64_build_setup && $@) if [[ "$(uname -m)" == "arm64" ]]; then
(macos_arm64_native_build_setup && $@)
else
(macos_arm64_cross_build_setup && $@)
fi
else else
$@ $@
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment