From 7ea1e214c5db6c48e405f8bb3ede8f5ec9b876db Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 5 May 2022 16:29:11 +0100 Subject: [PATCH] Make Mac SDK into a regular depends package --- contrib/depends/Makefile | 2 -- contrib/depends/README.md | 11 +---------- contrib/depends/hosts/darwin.mk | 8 +++----- contrib/depends/packages/darwin_sdk.mk | 10 ++++++++++ contrib/depends/packages/packages.mk | 2 +- contrib/depends/toolchain.cmake.in | 2 +- contrib/gitian/DOCKRUN.md | 6 ------ contrib/gitian/README.md | 9 --------- contrib/gitian/dockrun.sh | 5 ----- contrib/gitian/gitian-build.py | 10 ---------- contrib/gitian/gitian-osx.yml | 6 +----- 11 files changed, 17 insertions(+), 54 deletions(-) create mode 100644 contrib/depends/packages/darwin_sdk.mk diff --git a/contrib/depends/Makefile b/contrib/depends/Makefile index 9ffe8a106..3df1d677e 100644 --- a/contrib/depends/Makefile +++ b/contrib/depends/Makefile @@ -2,7 +2,6 @@ SOURCES_PATH ?= $(BASEDIR)/sources BASE_CACHE ?= $(BASEDIR)/built -SDK_PATH ?= $(BASEDIR)/SDKs FALLBACK_DOWNLOAD_PATH ?= https://downloads.getmonero.org/depends-sources BUILD = $(shell ./config.guess) @@ -185,7 +184,6 @@ $(host_prefix)/share/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_ -e 's|@build_tests@|$(build_tests)|' \ -e 's|@depends@|$(host_cmake)|' \ -e 's|@prefix@|$($(host_arch)_$(host_os)_prefix)|'\ - -e 's|@sdk@|$(SDK_PATH)|'\ -e 's|@arch@|$(host_arch)|'\ $< > $@ $(AT)touch $@ diff --git a/contrib/depends/README.md b/contrib/depends/README.md index f7c0b922f..1aa5b276f 100644 --- a/contrib/depends/README.md +++ b/contrib/depends/README.md @@ -30,7 +30,7 @@ Common `host-platform-triplets` for cross compilation are: - `i686-w64-mingw32` for Win32 - `x86_64-w64-mingw32` for Win64 -- `x86_64-apple-darwin11` for MacOSX +- `x86_64-apple-darwin11` for MacOSX x86_64 - `arm-linux-gnueabihf` for Linux ARM 32 bit - `aarch64-linux-gnu` for Linux ARM 64 bit - `riscv64-linux-gnu` for Linux RISCV 64 bit @@ -43,7 +43,6 @@ The following can be set when running make: make FOO=bar ``` SOURCES_PATH: downloaded sources will be placed here BASE_CACHE: built packages will be placed here -SDK_PATH: Path where sdk's can be found (used by OSX) FALLBACK_DOWNLOAD_PATH: If a source file can't be fetched, try here before giving up DEBUG: disable some optimizations and enable more runtime checking HOST_ID_SALT: Optional salt to use when generating host package ids @@ -59,14 +58,6 @@ download-win: run 'make download-win' to fetch all sources needed for win builds download-linux: run 'make download-linux' to fetch all sources needed for linux builds ``` -#Darwin (macos) builds: - -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 MacOSX11.1.sdk folder in it. The depends build will then pick it up automatically -(without requiring SDK_PATH). - - #Mingw builds Building for 32/64bit mingw requires switching alternatives to a posix mode diff --git a/contrib/depends/hosts/darwin.mk b/contrib/depends/hosts/darwin.mk index 2226f779c..d8b16f969 100644 --- a/contrib/depends/hosts/darwin.mk +++ b/contrib/depends/hosts/darwin.mk @@ -1,14 +1,12 @@ OSX_MIN_VERSION=10.8 -OSX_SDK_VERSION=11.1 -OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk LD64_VERSION=609 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_CC=clang -target $(CC_target) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(host_prefix)/native/SDK/ -mlinker-version=$(LD64_VERSION) -B$(host_prefix)/native/bin/$(host)- +darwin_CXX=clang++ -target $(CC_target) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(host_prefix)/native/SDK/ -mlinker-version=$(LD64_VERSION) -stdlib=libc++ -B$(host_prefix)/native/bin/$(host)- darwin_CFLAGS=-pipe darwin_CXXFLAGS=$(darwin_CFLAGS) @@ -20,4 +18,4 @@ darwin_release_CXXFLAGS=$(darwin_release_CFLAGS) darwin_debug_CFLAGS=-O1 darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS) -darwin_native_toolchain=native_cctools +darwin_native_toolchain=native_cctools darwin_sdk diff --git a/contrib/depends/packages/darwin_sdk.mk b/contrib/depends/packages/darwin_sdk.mk new file mode 100644 index 000000000..d639c422e --- /dev/null +++ b/contrib/depends/packages/darwin_sdk.mk @@ -0,0 +1,10 @@ +package=darwin_sdk +$(package)_version=11.1 +$(package)_download_path=https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/ +$(package)_file_name=MacOSX$($(package)_version).sdk.tar.xz +$(package)_sha256_hash=68797baaacb52f56f713400de306a58a7ca00b05c3dc6d58f0a8283bcac721f8 + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/SDK &&\ + mv * $($(package)_staging_dir)/$(host_prefix)/native/SDK +endef diff --git a/contrib/depends/packages/packages.mk b/contrib/depends/packages/packages.mk index 416b59801..11e2cb7be 100644 --- a/contrib/depends/packages/packages.mk +++ b/contrib/depends/packages/packages.mk @@ -34,6 +34,6 @@ mingw32_packages = icu4c sodium $(hardware_packages) mingw32_native_packages = $(hardware_native_packages) ifneq ($(build_os),darwin) -darwin_native_packages += native_clang native_cctools native_libtapi +darwin_native_packages += darwin_sdk native_clang native_cctools native_libtapi endif diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in index 3ed97633b..5f9501329 100644 --- a/contrib/depends/toolchain.cmake.in +++ b/contrib/depends/toolchain.cmake.in @@ -95,7 +95,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") SET(BUILD_64 ON) SET(BREW OFF) SET(PORT OFF) - SET(CMAKE_OSX_SYSROOT "@sdk@/MacOSX11.1.sdk/") + SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/") SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.08") SET(CMAKE_CXX_STANDARD 14) SET(LLVM_ENABLE_PIC OFF) diff --git a/contrib/gitian/DOCKRUN.md b/contrib/gitian/DOCKRUN.md index 7f44b7914..dabf090c2 100644 --- a/contrib/gitian/DOCKRUN.md +++ b/contrib/gitian/DOCKRUN.md @@ -30,12 +30,6 @@ git clone https://github.com/monero-project/monero.git cd monero/contrib/gitian ``` -If you want Mac binaries included in your build, you need to obtain the MacOS SDK: - -```bash -curl -O https://bitcoincore.org/depends-sources/sdks/MacOSX10.11.sdk.tar.gz -``` - Other User Preparation ---------------------- diff --git a/contrib/gitian/README.md b/contrib/gitian/README.md index c922a2373..5590acf17 100644 --- a/contrib/gitian/README.md +++ b/contrib/gitian/README.md @@ -165,15 +165,6 @@ popd Build the binaries ------------------ -**Note:** if you intend to build MacOS binaries, please follow [these instructions](https://github.com/bitcoin-core/docs/blob/master/gitian-building/gitian-building-mac-os-sdk.md) to get the required SDK. - -Currently working MacOS solution: - -```bash -curl -O https://bitcoincore.org/depends-sources/sdks/MacOSX10.11.sdk.tar.gz -mv MacOSX10.11.sdk.tar.gz builder/inputs -``` - To build the most recent tag (pass in `--docker` if using docker): ```bash diff --git a/contrib/gitian/dockrun.sh b/contrib/gitian/dockrun.sh index ef671116a..396db126b 100755 --- a/contrib/gitian/dockrun.sh +++ b/contrib/gitian/dockrun.sh @@ -53,11 +53,6 @@ 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 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 fi diff --git a/contrib/gitian/gitian-build.py b/contrib/gitian/gitian-build.py index 1db337e41..859c2c645 100755 --- a/contrib/gitian/gitian-build.py +++ b/contrib/gitian/gitian-build.py @@ -59,9 +59,6 @@ def rebuild(): for i in args.os: - if i is 'm' and args.nomac: - continue - os_name = platforms[i][0] tag_name = platforms[i][1] suffix = platforms[i][2] @@ -160,13 +157,6 @@ def main(): if not 'LXC_GUEST_IP' in os.environ.keys(): os.environ['LXC_GUEST_IP'] = '10.0.2.5' - # Disable MacOS build if no SDK found - args.nomac = False - 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 - script_name = os.path.basename(sys.argv[0]) # Signer and version shouldn't be empty if args.signer == '': diff --git a/contrib/gitian/gitian-osx.yml b/contrib/gitian/gitian-osx.yml index 630f7a0d3..b4929e822 100644 --- a/contrib/gitian/gitian-osx.yml +++ b/contrib/gitian/gitian-osx.yml @@ -26,8 +26,7 @@ packages: remotes: - "url": "https://github.com/monero-project/monero.git" "dir": "monero" -files: -- "MacOSX11.1.sdk.tar.xz" +files: [] script: | WRAP_DIR=$HOME/wrapped HOSTS="x86_64-apple-darwin11 aarch64-apple-darwin11" @@ -88,9 +87,6 @@ script: | BASEPREFIX=`pwd`/contrib/depends - mkdir -p ${BASEPREFIX}/SDKs - 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 for i in $HOSTS; do