depends: make mac sdk a package

This commit is contained in:
tobtoht 2023-03-16 02:44:40 +01:00
parent 76ee5b5134
commit 35dac82f6a
10 changed files with 29 additions and 76 deletions

View file

@ -31,7 +31,6 @@ MAKEOVERRIDES := $(filter V=%,$(MAKEOVERRIDES))
SOURCES_PATH ?= $(BASEDIR)/sources SOURCES_PATH ?= $(BASEDIR)/sources
WORK_PATH = $(BASEDIR)/work WORK_PATH = $(BASEDIR)/work
BASE_CACHE ?= $(BASEDIR)/built BASE_CACHE ?= $(BASEDIR)/built
SDK_PATH ?= $(BASEDIR)/SDKs
FALLBACK_DOWNLOAD_PATH ?= https://featherwallet.org/files/sources FALLBACK_DOWNLOAD_PATH ?= https://featherwallet.org/files/sources
BUILD = $(shell ./config.guess) BUILD = $(shell ./config.guess)

View file

@ -4,7 +4,7 @@ XCODE_VERSION=12.2
XCODE_BUILD_ID=12B45b XCODE_BUILD_ID=12B45b
LD64_VERSION=609 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 darwin_native_binutils=native_cctools
@ -13,7 +13,7 @@ ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),)
# from llvm.org # from llvm.org
# Clang is a dependency of native_cctools when FORCE_USE_SYSTEM_CLANG is empty # 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 clang_prog=$(build_prefix)/bin/clang
clangxx_prog=$(clang_prog)++ 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 # FORCE_USE_SYSTEM_CLANG is non-empty, so we use the clang from the user's
# system # system
darwin_native_toolchain= darwin_native_toolchain=darwin_sdk
# We can't just use $(shell command -v clang) because GNU Make handles builtins # 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 # in a special way and doesn't know that `command` is a POSIX-standard builtin

View file

@ -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

View file

@ -5,7 +5,7 @@ linux_packages := eudev liblzma libarchive libfuse libsquashfuse libappimage app
linux_native_packages = native_patchelf linux_native_packages = native_patchelf
darwin_packages := 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_packages = icu4c
mingw32_native_packages = native_cmake mingw32_native_packages = native_cmake

View file

@ -132,7 +132,7 @@ $(package)_config_opts_darwin += QMAKE_MACOSX_DEPLOYMENT_TARGET=$(OSX_MIN_VERSIO
ifneq ($(build_os),darwin) ifneq ($(build_os),darwin)
$(package)_config_opts_darwin += -xplatform macx-clang $(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 MAC_SDK_VERSION=$(OSX_SDK_VERSION)
$(package)_config_opts_darwin += -device-option CROSS_COMPILE="$(host)-" $(package)_config_opts_darwin += -device-option CROSS_COMPILE="$(host)-"
$(package)_config_opts_darwin += -device-option MAC_TARGET=$(host) $(package)_config_opts_darwin += -device-option MAC_TARGET=$(host)

View file

@ -2,7 +2,7 @@
set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_NAME Darwin)
# TODO: don't hardcode this # 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_SYSROOT ${TARGET_SYSROOT})
set(CMAKE_OSX_SYSROOT ${TARGET_SYSROOT}) set(CMAKE_OSX_SYSROOT ${TARGET_SYSROOT})
@ -10,8 +10,8 @@ set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++) set(CMAKE_CXX_COMPILER clang++)
# TODO: don't hardcode this # 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_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/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_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_INSTALL_NAME_TOOL x86_64-apple-darwin-install_name_tool)
set(CMAKE_FIND_ROOT_PATH /feather/contrib/depends/x86_64-apple-darwin/) set(CMAKE_FIND_ROOT_PATH /feather/contrib/depends/x86_64-apple-darwin/)

View file

@ -15,7 +15,7 @@ SET(BUILD_TESTS @build_tests@)
SET(TREZOR_DEBUG @build_tests@) SET(TREZOR_DEBUG @build_tests@)
# where is the target environment # 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") if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND ARCHITECTURE STREQUAL "x86_64")
SET(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} /home/user/.guix-profile/) SET(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} /home/user/.guix-profile/)
@ -61,6 +61,8 @@ endif()
endif() endif()
set(ICONV_LIBRARIES @prefix@/lib/libiconv.a)
SET(ZMQ_INCLUDE_PATH @prefix@/include) SET(ZMQ_INCLUDE_PATH @prefix@/include)
SET(ZMQ_LIB @prefix@/lib/libzmq.a) SET(ZMQ_LIB @prefix@/lib/libzmq.a)
@ -111,7 +113,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(BUILD_64 ON) SET(BUILD_64 ON)
SET(BREW OFF) SET(BREW OFF)
SET(PORT 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_OSX_DEPLOYMENT_TARGET "10.14")
SET(CMAKE_CXX_STANDARD 14) SET(CMAKE_CXX_STANDARD 14)
SET(LLVM_ENABLE_PIC OFF) SET(LLVM_ENABLE_PIC OFF)

View file

@ -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 If you haven't considered your security model yet, please read [the relevant
section](#choosing-your-security-model) before proceeding to perform a build. 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-<foo>-<bar>-extracted-SDK-with-libcxx-headers
tar -C /path/to/parent/dir/of/extracted/SDK -xaf /path/to/Xcode-<foo>-<bar>-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 ## Building
*The author highly recommends at least reading over the [common usage patterns *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 ## 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 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 outside of the worktrees to avoid duplicate downloads and unnecessary builds. To
help with this situation, the `guix-build` script honours the `SOURCES_PATH`, 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: depends tree so that you can do something like:
```sh ```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 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 The path that this environment variable points to **must be a directory**, and
**NOT a symlink to a directory**. **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**_ * _**JOBS**_
Override the number of jobs to run simultaneously, you might want to do so on Override the number of jobs to run simultaneously, you might want to do so on

View file

@ -109,7 +109,7 @@ Hint: To blow everything away, you may want to use:
$ ./contrib/guix/guix-clean $ ./contrib/guix/guix-clean
Specifically, this will remove all files without an entry in the index, 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 packages cache, the garbage collector roots for Guix environments, and the
output directory. output directory.
EOF EOF
@ -121,25 +121,6 @@ else
mkdir -p "$DISTSRC_BASE" mkdir -p "$DISTSRC_BASE"
fi 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 # 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 # Precious directories are those which should not be cleaned between successive
# guix builds # 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" precious_dir_names="${depends_precious_dir_names} OUTDIR_BASE PROFILES_BASE"
# Usage: contains IFS-SEPARATED-LIST ITEM # Usage: contains IFS-SEPARATED-LIST ITEM
@ -332,7 +313,7 @@ Hint: To blow everything away, you may want to use:
$ ./contrib/guix/guix-clean $ ./contrib/guix/guix-clean
Specifically, this will remove all files without an entry in the index, 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 packages cache, the garbage collector roots for Guix environments, and the
output directory. output directory.
EOF EOF
@ -441,7 +422,6 @@ EOF
--expose="$(git rev-parse --git-common-dir)" \ --expose="$(git rev-parse --git-common-dir)" \
${SOURCES_PATH:+--share="$SOURCES_PATH"} \ ${SOURCES_PATH:+--share="$SOURCES_PATH"} \
${BASE_CACHE:+--share="$BASE_CACHE"} \ ${BASE_CACHE:+--share="$BASE_CACHE"} \
${SDK_PATH:+--share="$SDK_PATH"} \
--cores="$JOBS" \ --cores="$JOBS" \
--keep-failed \ --keep-failed \
--fallback \ --fallback \
@ -457,7 +437,6 @@ EOF
${V:+V=1} \ ${V:+V=1} \
${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \ ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \
${BASE_CACHE:+BASE_CACHE="$BASE_CACHE"} \ ${BASE_CACHE:+BASE_CACHE="$BASE_CACHE"} \
${SDK_PATH:+SDK_PATH="$SDK_PATH"} \
DISTSRC="$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$host")" \ DISTSRC="$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$host")" \
OUTDIR="$(OUTDIR_BASE=/outdir-base && outdir_for_host "$host")" \ OUTDIR="$(OUTDIR_BASE=/outdir-base && outdir_for_host "$host")" \
DIST_ARCHIVE_BASE=/outdir-base/dist-archive \ DIST_ARCHIVE_BASE=/outdir-base/dist-archive \

View file

@ -32,10 +32,6 @@ add_subdirectory(openpgp)
qt_add_resources(RESOURCES assets.qrc assets_tor.qrc) qt_add_resources(RESOURCES assets.qrc assets_tor.qrc)
if (DEPENDS)
find_library(ICONV_LIBRARIES iconv)
endif()
# Compile source files (.h/.cpp) # Compile source files (.h/.cpp)
file(GLOB SOURCE_FILES file(GLOB SOURCE_FILES
"*.h" "*.h"