diff --git a/contrib/depends/Makefile b/contrib/depends/Makefile index 70ed3f8..26e4397 100644 --- a/contrib/depends/Makefile +++ b/contrib/depends/Makefile @@ -31,7 +31,6 @@ MAKEOVERRIDES := $(filter V=%,$(MAKEOVERRIDES)) SOURCES_PATH ?= $(BASEDIR)/sources WORK_PATH = $(BASEDIR)/work BASE_CACHE ?= $(BASEDIR)/built -SDK_PATH ?= $(BASEDIR)/SDKs FALLBACK_DOWNLOAD_PATH ?= https://featherwallet.org/files/sources BUILD = $(shell ./config.guess) diff --git a/contrib/depends/hosts/darwin.mk b/contrib/depends/hosts/darwin.mk index 6ba716a..87d9776 100644 --- a/contrib/depends/hosts/darwin.mk +++ b/contrib/depends/hosts/darwin.mk @@ -4,7 +4,7 @@ XCODE_VERSION=12.2 XCODE_BUILD_ID=12B45b LD64_VERSION=609 -OSX_SDK=$(SDK_PATH)/Xcode-$(XCODE_VERSION)-$(XCODE_BUILD_ID)-extracted-SDK-with-libcxx-headers +OSX_SDK=$(host_prefix)/native/SDK darwin_native_binutils=native_cctools @@ -13,7 +13,7 @@ ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),) # from llvm.org # Clang is a dependency of native_cctools when FORCE_USE_SYSTEM_CLANG is empty -darwin_native_toolchain=native_cctools +darwin_native_toolchain=native_cctools darwin_sdk clang_prog=$(build_prefix)/bin/clang clangxx_prog=$(clang_prog)++ @@ -23,7 +23,7 @@ else # FORCE_USE_SYSTEM_CLANG is non-empty, so we use the clang from the user's # system -darwin_native_toolchain= +darwin_native_toolchain=darwin_sdk # We can't just use $(shell command -v clang) because GNU Make handles builtins # in a special way and doesn't know that `command` is a POSIX-standard builtin diff --git a/contrib/depends/packages/darwin_sdk.mk b/contrib/depends/packages/darwin_sdk.mk new file mode 100644 index 0000000..0e82fa5 --- /dev/null +++ b/contrib/depends/packages/darwin_sdk.mk @@ -0,0 +1,10 @@ +package=darwin_sdk +$(package)_version=12.2 +$(package)_download_path=https://featherwallet.org/files/sources/ +$(package)_file_name=Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz +$(package)_sha256_hash=332477876917786b26dd7c3fc1665d2c5cdca81c72755e6a9754f308de77d33b + +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 4f31ec2..e21e465 100644 --- a/contrib/depends/packages/packages.mk +++ b/contrib/depends/packages/packages.mk @@ -5,7 +5,7 @@ linux_packages := eudev liblzma libarchive libfuse libsquashfuse libappimage app linux_native_packages = native_patchelf darwin_packages := -darwin_native_packages = native_cctools native_libtapi native_clang +darwin_native_packages = darwin_sdk native_cctools native_libtapi native_clang mingw32_packages = icu4c mingw32_native_packages = native_cmake diff --git a/contrib/depends/packages/qt.mk b/contrib/depends/packages/qt.mk index a2f26da..67f0fb2 100644 --- a/contrib/depends/packages/qt.mk +++ b/contrib/depends/packages/qt.mk @@ -132,7 +132,7 @@ $(package)_config_opts_darwin += QMAKE_MACOSX_DEPLOYMENT_TARGET=$(OSX_MIN_VERSIO ifneq ($(build_os),darwin) $(package)_config_opts_darwin += -xplatform macx-clang -$(package)_config_opts_darwin += -device-option MAC_SDK_PATH=$(OSX_SDK) +$(package)_config_opts_darwin += -device-option MAC_SDK_PATH=$(host_prefix)/native/SDK $(package)_config_opts_darwin += -device-option MAC_SDK_VERSION=$(OSX_SDK_VERSION) $(package)_config_opts_darwin += -device-option CROSS_COMPILE="$(host)-" $(package)_config_opts_darwin += -device-option MAC_TARGET=$(host) diff --git a/contrib/depends/patches/qt/MacToolchain.cmake b/contrib/depends/patches/qt/MacToolchain.cmake index 15a53fa..041e7ed 100644 --- a/contrib/depends/patches/qt/MacToolchain.cmake +++ b/contrib/depends/patches/qt/MacToolchain.cmake @@ -2,7 +2,7 @@ set(CMAKE_SYSTEM_NAME Darwin) # TODO: don't hardcode this -set(TARGET_SYSROOT /feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers) +set(TARGET_SYSROOT /feather/contrib/depends/x86_64-apple-darwin/native/SDK) set(CMAKE_SYSROOT ${TARGET_SYSROOT}) set(CMAKE_OSX_SYSROOT ${TARGET_SYSROOT}) @@ -10,8 +10,8 @@ set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) # TODO: don't hardcode this -set(CMAKE_C_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.14 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include") -set(CMAKE_CXX_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.14 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers -stdlib=libc++ -stdlib++-isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include/c++/v1 -isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include/c++/v1 -isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include") +set(CMAKE_C_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.14 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/x86_64-apple-darwin/native/SDK -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include") +set(CMAKE_CXX_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.14 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/x86_64-apple-darwin/native/SDK -stdlib=libc++ -stdlib++-isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include/c++/v1 -isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include/c++/v1 -isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include") set(CMAKE_INSTALL_NAME_TOOL x86_64-apple-darwin-install_name_tool) set(CMAKE_FIND_ROOT_PATH /feather/contrib/depends/x86_64-apple-darwin/) diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in index 91c3322..0239be5 100644 --- a/contrib/depends/toolchain.cmake.in +++ b/contrib/depends/toolchain.cmake.in @@ -15,7 +15,7 @@ SET(BUILD_TESTS @build_tests@) SET(TREZOR_DEBUG @build_tests@) # where is the target environment -SET(CMAKE_FIND_ROOT_PATH @prefix@ /feather/contrib/depends/SDKs/ /home/user/.guix-profile/@HOST@) +SET(CMAKE_FIND_ROOT_PATH @prefix@ /home/user/.guix-profile/@HOST@) if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND ARCHITECTURE STREQUAL "x86_64") SET(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} /home/user/.guix-profile/) @@ -61,6 +61,8 @@ endif() endif() +set(ICONV_LIBRARIES @prefix@/lib/libiconv.a) + SET(ZMQ_INCLUDE_PATH @prefix@/include) SET(ZMQ_LIB @prefix@/lib/libzmq.a) @@ -111,7 +113,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") SET(BUILD_64 ON) SET(BREW OFF) SET(PORT OFF) - SET(CMAKE_OSX_SYSROOT "@prefix@/../SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/") + SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK") SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") SET(CMAKE_CXX_STANDARD 14) SET(LLVM_ENABLE_PIC OFF) diff --git a/contrib/guix/README.md b/contrib/guix/README.md index b0babbe..a0ec561 100644 --- a/contrib/guix/README.md +++ b/contrib/guix/README.md @@ -27,29 +27,6 @@ If you don't have Guix installed and set up, please follow the instructions in If you haven't considered your security model yet, please read [the relevant section](#choosing-your-security-model) before proceeding to perform a build. -## Making the Xcode SDK available for macOS cross-compilation - -In order to perform a build for macOS (which is included in the default set of -platform triples to build), you'll need to extract the macOS SDK tarball using -tools found in the [`macdeploy` directory](../macdeploy/README.md). - -You can then either point to the SDK using the `SDK_PATH` environment variable: - -```sh -# Extract the SDK tarball to /path/to/parent/dir/of/extracted/SDK/Xcode---extracted-SDK-with-libcxx-headers -tar -C /path/to/parent/dir/of/extracted/SDK -xaf /path/to/Xcode---extracted-SDK-with-libcxx-headers.tar.gz - -# Indicate where to locate the SDK tarball -export SDK_PATH=/path/to/parent/dir/of/extracted/SDK -``` - -or extract it into `depends/SDKs`: - -```sh -mkdir -p depends/SDKs -tar -C depends/SDKs -xaf /path/to/SDK/tarball -``` - ## Building *The author highly recommends at least reading over the [common usage patterns @@ -79,17 +56,17 @@ worktree to save disk space: ## Common `guix-build` invocation patterns and examples -### Keeping caches and SDKs outside of the worktree +### Keeping caches outside of the worktree If you perform a lot of builds and have a bunch of worktrees, you may find it -more efficient to keep the depends tree's download cache, build cache, and SDKs +more efficient to keep the depends tree's download cache and build cache outside of the worktrees to avoid duplicate downloads and unnecessary builds. To help with this situation, the `guix-build` script honours the `SOURCES_PATH`, -`BASE_CACHE`, and `SDK_PATH` environment variables and will pass them on to the +`BASE_CACHE` environment variables and will pass them on to the depends tree so that you can do something like: ```sh -env SOURCES_PATH="$HOME/depends-SOURCES_PATH" BASE_CACHE="$HOME/depends-BASE_CACHE" SDK_PATH="$HOME/macOS-SDKs" ./contrib/guix/guix-build +env SOURCES_PATH="$HOME/depends-SOURCES_PATH" BASE_CACHE="$HOME/depends-BASE_CACHE" ./contrib/guix/guix-build ``` Note that the paths that these environment variables point to **must be @@ -190,16 +167,6 @@ details. The path that this environment variable points to **must be a directory**, and **NOT a symlink to a directory**. -* _**SDK_PATH**_ - - Set the path where _extracted_ SDKs can be found. This is passed through to - the depends tree. Note that this is should be set to the _parent_ directory of - the actual SDK (e.g. `SDK_PATH=$HOME/Downloads/macOS-SDKs` instead of - `$HOME/Downloads/macOS-SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers`). - - The path that this environment variable points to **must be a directory**, and - **NOT a symlink to a directory**. - * _**JOBS**_ Override the number of jobs to run simultaneously, you might want to do so on diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index f01714a..cd263a9 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -109,7 +109,7 @@ Hint: To blow everything away, you may want to use: $ ./contrib/guix/guix-clean Specifically, this will remove all files without an entry in the index, -excluding the SDK directory, the depends download cache, the depends built +excluding the depends download cache, the depends built packages cache, the garbage collector roots for Guix environments, and the output directory. EOF @@ -121,25 +121,6 @@ else mkdir -p "$DISTSRC_BASE" fi -################ -# When building for darwin, the macOS SDK should exist -################ - -for host in $HOSTS; do - case "$host" in - *darwin*) - OSX_SDK="$(make -C "${PWD}/contrib/depends" --no-print-directory HOST="$host" print-OSX_SDK | sed 's@^[^=]\+=@@g')" - if [ -e "$OSX_SDK" ]; then - echo "Found macOS SDK at '${OSX_SDK}', using..." - break - else - echo "macOS SDK does not exist at '${OSX_SDK}', please place the extracted, untarred SDK there to perform darwin builds, or define SDK_PATH environment variable. Exiting..." - exit 1 - fi - ;; - esac -done - ################ # VERSION_BASE should have enough space ################ @@ -237,7 +218,7 @@ SOURCE_DATE_EPOCH="1676215618" # Precious directories are those which should not be cleaned between successive # guix builds -depends_precious_dir_names='SOURCES_PATH BASE_CACHE SDK_PATH' +depends_precious_dir_names='SOURCES_PATH BASE_CACHE' precious_dir_names="${depends_precious_dir_names} OUTDIR_BASE PROFILES_BASE" # Usage: contains IFS-SEPARATED-LIST ITEM @@ -332,7 +313,7 @@ Hint: To blow everything away, you may want to use: $ ./contrib/guix/guix-clean Specifically, this will remove all files without an entry in the index, -excluding the SDK directory, the depends download cache, the depends built +excluding the depends download cache, the depends built packages cache, the garbage collector roots for Guix environments, and the output directory. EOF @@ -441,7 +422,6 @@ EOF --expose="$(git rev-parse --git-common-dir)" \ ${SOURCES_PATH:+--share="$SOURCES_PATH"} \ ${BASE_CACHE:+--share="$BASE_CACHE"} \ - ${SDK_PATH:+--share="$SDK_PATH"} \ --cores="$JOBS" \ --keep-failed \ --fallback \ @@ -457,7 +437,6 @@ EOF ${V:+V=1} \ ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \ ${BASE_CACHE:+BASE_CACHE="$BASE_CACHE"} \ - ${SDK_PATH:+SDK_PATH="$SDK_PATH"} \ DISTSRC="$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$host")" \ OUTDIR="$(OUTDIR_BASE=/outdir-base && outdir_for_host "$host")" \ DIST_ARCHIVE_BASE=/outdir-base/dist-archive \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0235fb3..ada21ff 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,10 +32,6 @@ add_subdirectory(openpgp) qt_add_resources(RESOURCES assets.qrc assets_tor.qrc) -if (DEPENDS) - find_library(ICONV_LIBRARIES iconv) -endif() - # Compile source files (.h/.cpp) file(GLOB SOURCE_FILES "*.h"