aboutsummaryrefslogtreecommitdiff
path: root/depends
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-12-09 21:20:29 +0800
committerfanquake <fanquake@gmail.com>2021-12-09 21:22:58 +0800
commit7629efcc2c3a8a8a7c17b1300cd466ec6c8c1f3f (patch)
treeb33f4dbda6c372775b3f2bdcc4f961fb974150f7 /depends
parentae017b81604761b57e22c28913c4ce81bf2e31ce (diff)
parent19f3896c9a6a710bdd49b65a4a4947d90eb8a692 (diff)
downloadbitcoin-7629efcc2c3a8a8a7c17b1300cd466ec6c8c1f3f.tar.xz
Merge bitcoin/bitcoin#23603: build: Fix x86_64 <-> arm64 cross-compiling for macOS
19f3896c9a6a710bdd49b65a4a4947d90eb8a692 build: Fix x86_64 <-> arm64 cross-compiling for macOS (Hennadii Stepanov) Pull request description: Currently, on master (111c3e06b35b7867f2e0f740e988f648ac6c325d), dependencies are built for the build system architecture, not the provided host. On Intel-based macOS Big Sur 11.6.1 (20G224): ``` % make -C depends HOST=arm64-apple-darwin20 % lipo -info depends/arm64-apple-darwin20/lib/libsqlite3.a Non-fat file: depends/arm64-apple-darwin20/lib/libsqlite3.a is architecture: x86_64 ``` On M1-based macOS Monterey 12.0.1 (21A559) the `boost` package building fails with multiple errors like that: ``` % make -C depends boost HOST=x86_64-apple-darwin19 ... error: option 'cf-protection=return' cannot be specified on this target error: option 'cf-protection=branch' cannot be specified on this target 2 errors generated. ``` This PR allows to cross-compile as follows: - on Intel-based macOS Big Sur 11.6.1 (20G224): ``` % make -C depends HOST=arm64-apple-darwin20 % lipo -info depends/arm64-apple-darwin20/lib/libsqlite3.a Non-fat file: depends/arm64-apple-darwin20/lib/libsqlite3.a is architecture: arm64 % CONFIG_SITE=$PWD/depends/arm64-apple-darwin20/share/config.site ./configure % make % lipo -info src/qt/bitcoin-qt Non-fat file: src/qt/bitcoin-qt is architecture: arm64 ``` - on M1-based macOS Monterey 12.0.1 (21A559): ``` % make -C depends HOST=x86_64-apple-darwin19 % CONFIG_SITE=$PWD/depends/x86_64-apple-darwin19/share/config.site ./configure % make % lipo -info src/qt/bitcoin-qt Non-fat file: src/qt/bitcoin-qt is architecture: x86_64 ``` No behavior change for other builder-host pairs. This is an alternative to bitcoin/bitcoin#22506. ACKs for top commit: fanquake: ACK 19f3896c9a6a710bdd49b65a4a4947d90eb8a692 - this is definitely cleaner than the approach in #22506. I've tested the x86_64 -> arm64 and arm64 -> x86_64 cross-compiles. Going to go-ahead and merge this given it's scoped to building for darwin targets, on darwin. Not sure if this is something we'll actually see used very often. Tree-SHA512: 67a7fed1db79bc43d41aabb5a676f90417a879e5dcffec1384c288b56ee32ba06ae3819abdc7aca85b81af6e782bcfff5c83a67a455560249fa095a807fc1187
Diffstat (limited to 'depends')
-rw-r--r--depends/builders/darwin.mk5
1 files changed, 5 insertions, 0 deletions
diff --git a/depends/builders/darwin.mk b/depends/builders/darwin.mk
index 001c928424..6e68c88928 100644
--- a/depends/builders/darwin.mk
+++ b/depends/builders/darwin.mk
@@ -21,3 +21,8 @@ darwin_NM:=$(shell xcrun -f nm)
darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool)
darwin_native_binutils=
darwin_native_toolchain=
+
+x86_64_darwin_CFLAGS = -arch x86_64
+x86_64_darwin_CXXFLAGS = $(x86_64_darwin_CFLAGS)
+aarch64_darwin_CFLAGS = -arch arm64
+aarch64_darwin_CXXFLAGS = $(aarch64_darwin_CFLAGS)