From a86c4cb75ffb577922334cf6e212bcd5bac1716d Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 3 May 2022 15:51:34 +0100 Subject: Update to MacOSX SDK 11.1, add Mac M1 --- contrib/depends/README.md | 4 ++-- contrib/depends/hosts/darwin.mk | 11 ++++++++--- contrib/depends/toolchain.cmake.in | 31 ++++++++++++++++++++++--------- contrib/gitian/dockrun.sh | 4 ++-- contrib/gitian/gitian-build.py | 2 +- contrib/gitian/gitian-osx.yml | 6 +++--- 6 files changed, 38 insertions(+), 20 deletions(-) diff --git a/contrib/depends/README.md b/contrib/depends/README.md index 10866acbe..f7c0b922f 100644 --- a/contrib/depends/README.md +++ b/contrib/depends/README.md @@ -61,9 +61,9 @@ download-linux: run 'make download-linux' to fetch all sources needed for linux #Darwin (macos) builds: -To build with the x86_64-apple-darwin11 you require the mac os developer tools in MacOSX10.11.sdk. +To build with the x86_64-apple-darwin11 you require the mac os developer tools in MacOSX11.1.sdk. Download it from apple, or search for it on github. Create a new directoty called SDKs in this -directory and place the entire MacOSX10.11.sdk folder in it. The depends build will then pick it up automatically +directory and place the entire MacOSX11.1.sdk folder in it. The depends build will then pick it up automatically (without requiring SDK_PATH). diff --git a/contrib/depends/hosts/darwin.mk b/contrib/depends/hosts/darwin.mk index 7b5c8b051..0b6582003 100644 --- a/contrib/depends/hosts/darwin.mk +++ b/contrib/depends/hosts/darwin.mk @@ -1,9 +1,14 @@ OSX_MIN_VERSION=10.8 -OSX_SDK_VERSION=10.11 +OSX_SDK_VERSION=11.1 OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk LD64_VERSION=253.9 -darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -B $(host_prefix)/native/bin -darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++ -B $(host_prefix)/native/bin +ifeq (aarch64, $(host_arch)) +CC_target=arm64-apple-darwin11 +else +CC_target=$(host) +endif +darwin_CC=clang -target $(CC_target) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -B$(host_prefix)/native/bin/$(host)- +darwin_CXX=clang++ -target $(CC_target) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++ -B$(host_prefix)/native/bin/$(host)- darwin_CFLAGS=-pipe darwin_CXXFLAGS=$(darwin_CFLAGS) diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in index c3a0df59b..3ed97633b 100644 --- a/contrib/depends/toolchain.cmake.in +++ b/contrib/depends/toolchain.cmake.in @@ -69,22 +69,35 @@ set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Find includes in target # specify the cross compiler to be used. Darwin uses clang provided by the SDK. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + if(ARCHITECTURE STREQUAL "aarch64") + SET(CLANG_TARGET "arm64-apple-darwin11") + SET(CONF_TRIPLE "aarch64-apple-darwin11") + SET(BUILD_TAG "mac-armv8") + SET(CMAKE_OSX_ARCHITECTURES "arm64") + set(ARM ON) + set(ARM_ID "armv8-a") + else() + SET(CLANG_TARGET "x86_64-apple-darwin11") + SET(CONF_TRIPLE "x86_64-apple-darwin11") + SET(BUILD_TAG "mac-x64") + SET(CMAKE_OSX_ARCHITECTURES "x86_64") + endif() + SET(_CMAKE_TOOLCHAIN_PREFIX @prefix@/native/bin/${CONF_TRIPLE}-) SET(CMAKE_C_COMPILER @prefix@/native/bin/clang) - SET(CMAKE_C_COMPILER_TARGET x86_64-apple-darwin11) + SET(CMAKE_C_COMPILER_TARGET ${CLANG_TARGET}) + SET(CMAKE_C_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX}) SET(CMAKE_CXX_COMPILER @prefix@/native/bin/clang++ -stdlib=libc++) - SET(CMAKE_CXX_COMPILER_TARGET x86_64-apple-darwin11) - SET(CMAKE_ASM_COMPILER_TARGET x86_64-apple-darwin11) - SET(CMAKE_ASM-ATT_COMPILER_TARGET x86_64-apple-darwin11) - SET(_CMAKE_TOOLCHAIN_PREFIX x86_64-apple-darwin11-) + SET(CMAKE_CXX_COMPILER_TARGET ${CLANG_TARGET}) + SET(CMAKE_CXX_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX}) + SET(CMAKE_ASM_COMPILER_TARGET ${CLANG_TARGET}) + SET(CMAKE_ASM-ATT_COMPILER_TARGET ${CLANG_TARGET}) SET(APPLE True) - SET(BUILD_TAG "mac-x64") SET(BUILD_64 ON) SET(BREW OFF) SET(PORT OFF) - SET(CMAKE_OSX_SYSROOT "@sdk@/MacOSX10.11.sdk/") + SET(CMAKE_OSX_SYSROOT "@sdk@/MacOSX11.1.sdk/") SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.08") SET(CMAKE_CXX_STANDARD 14) - SET(CMAKE_OSX_ARCHITECTURES "x86_64") SET(LLVM_ENABLE_PIC OFF) SET(LLVM_ENABLE_PIE OFF) elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") @@ -126,7 +139,7 @@ elseif(ARCHITECTURE STREQUAL "aarch64") set(ARM_ID "armv8-a") if(ANDROID) set(BUILD_TAG "android-armv8") - else() + elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(BUILD_TAG "linux-armv8") endif() set(BUILD_64 ON) diff --git a/contrib/gitian/dockrun.sh b/contrib/gitian/dockrun.sh index 015c411fd..ef671116a 100755 --- a/contrib/gitian/dockrun.sh +++ b/contrib/gitian/dockrun.sh @@ -53,8 +53,8 @@ docker build --pull -f ${TAG}.Dockerfile -t $TAG . cd .. docker run -v /var/run/docker.sock:/var/run/docker.sock -d --name gitrun $TAG -if [ -f MacOSX10.11.sdk.tar.gz ]; then - docker cp MacOSX10.11.sdk.tar.gz gitrun:$WORKDIR/builder/inputs/ +if [ -f MacOSX11.1.sdk.tar.xz ]; then + docker cp MacOSX11.1.sdk.tar.xz gitrun:$WORKDIR/builder/inputs/ else echo "No MacOS SDK found, Mac builds will be omitted" fi diff --git a/contrib/gitian/gitian-build.py b/contrib/gitian/gitian-build.py index 6bf936958..1db337e41 100755 --- a/contrib/gitian/gitian-build.py +++ b/contrib/gitian/gitian-build.py @@ -162,7 +162,7 @@ def main(): # Disable MacOS build if no SDK found args.nomac = False - if 'm' in args.os and not os.path.isfile('builder/inputs/MacOSX10.11.sdk.tar.gz'): + if 'm' in args.os and not os.path.isfile('builder/inputs/MacOSX11.1.sdk.tar.xz'): if args.build: print('Cannot build for MacOS, SDK does not exist. Will build for other OSes') args.nomac = True diff --git a/contrib/gitian/gitian-osx.yml b/contrib/gitian/gitian-osx.yml index 3434861d2..630f7a0d3 100644 --- a/contrib/gitian/gitian-osx.yml +++ b/contrib/gitian/gitian-osx.yml @@ -27,10 +27,10 @@ remotes: - "url": "https://github.com/monero-project/monero.git" "dir": "monero" files: -- "MacOSX10.11.sdk.tar.gz" +- "MacOSX11.1.sdk.tar.xz" script: | WRAP_DIR=$HOME/wrapped - HOSTS="x86_64-apple-darwin11" + HOSTS="x86_64-apple-darwin11 aarch64-apple-darwin11" FAKETIME_HOST_PROGS="" FAKETIME_PROGS="ar ranlib date dmg genisoimage python" @@ -89,7 +89,7 @@ script: | BASEPREFIX=`pwd`/contrib/depends mkdir -p ${BASEPREFIX}/SDKs - tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/MacOSX10.11.sdk.tar.gz + tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/MacOSX11.1.sdk.tar.xz # Build dependencies for each host export TAR_OPTIONS=--mtime=2000-01-01T12:00:00 -- cgit v1.2.3