Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Fix x86_64 <-> arm64 cross-compiling for macOS #23603

Merged
merged 1 commit into from
Dec 9, 2021

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Nov 26, 2021

Currently, on master (111c3e0), 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 #22506.

@hebasto
Copy link
Member Author

hebasto commented Nov 26, 2021

Guix builds:

$ find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
cd821fb2efbb8ead184ef32559fd6cf8a0bb87fa8bb0bf8d7952de440c32e44e  guix-build-19f3896c9a6a/output/aarch64-linux-gnu/SHA256SUMS.part
13d1ea066972d4c39090183e8a5053a7c32f1faf5fcca00549aefc3ca43d25c4  guix-build-19f3896c9a6a/output/aarch64-linux-gnu/bitcoin-19f3896c9a6a-aarch64-linux-gnu-debug.tar.gz
bf3bc56e29a9bbde1c9dab5fc3573da79ba25c1256720fdaff66bca649e275b1  guix-build-19f3896c9a6a/output/aarch64-linux-gnu/bitcoin-19f3896c9a6a-aarch64-linux-gnu.tar.gz
49b03284cd373b6e18b6fcc79a419ff8b769f5c63f1c1bbf2328e2ee6aa3fe9e  guix-build-19f3896c9a6a/output/arm-linux-gnueabihf/SHA256SUMS.part
970215788561cbbf50b7e285548db76bbcc00660615305d5a0f4abcc643799b6  guix-build-19f3896c9a6a/output/arm-linux-gnueabihf/bitcoin-19f3896c9a6a-arm-linux-gnueabihf-debug.tar.gz
9bf1cff65d07e41230fc676d5eb3a22a68dec56294cfb1c2dd613e60ef8c2626  guix-build-19f3896c9a6a/output/arm-linux-gnueabihf/bitcoin-19f3896c9a6a-arm-linux-gnueabihf.tar.gz
0c98403967aa48610fbe953df1aa56d30d11da0c9013640d5e9df867348793b4  guix-build-19f3896c9a6a/output/dist-archive/bitcoin-19f3896c9a6a.tar.gz
d598262841072b5663e3a67fe55365e506dce1ee6b6467af1e23cb3aa7ed7c80  guix-build-19f3896c9a6a/output/powerpc64-linux-gnu/SHA256SUMS.part
df9f13656780a2e2f4ba127280cb3f417c4e43c55efb9413e67fe27738b52dc1  guix-build-19f3896c9a6a/output/powerpc64-linux-gnu/bitcoin-19f3896c9a6a-powerpc64-linux-gnu-debug.tar.gz
862b7b05bd622b2b6f4e9425afd08fa2219bb08187dcf454c7e52dd37d142efd  guix-build-19f3896c9a6a/output/powerpc64-linux-gnu/bitcoin-19f3896c9a6a-powerpc64-linux-gnu.tar.gz
45184c8e2ec75712473a6e8d7de1676fcfd051867130230f49f16bdfa74bea98  guix-build-19f3896c9a6a/output/powerpc64le-linux-gnu/SHA256SUMS.part
2b842d75c5965f571cb9bf61b748605485fa3c93fb5a0ddd5c00b6c35c65307b  guix-build-19f3896c9a6a/output/powerpc64le-linux-gnu/bitcoin-19f3896c9a6a-powerpc64le-linux-gnu-debug.tar.gz
52b8aa6ed35338d6a5e38db4d6476b56aaf3298b690d0aed5413a944ca483a5d  guix-build-19f3896c9a6a/output/powerpc64le-linux-gnu/bitcoin-19f3896c9a6a-powerpc64le-linux-gnu.tar.gz
cb591a7ddc87eb9068b9a52b87f6300b6a8ad27bb08cf80ffa2c4f47b3c5dbb7  guix-build-19f3896c9a6a/output/riscv64-linux-gnu/SHA256SUMS.part
c4e4083462ec34d9770e0a8ce823eb5046d5879fc82d87a0d696f62bd6bc578c  guix-build-19f3896c9a6a/output/riscv64-linux-gnu/bitcoin-19f3896c9a6a-riscv64-linux-gnu-debug.tar.gz
297b5c58b56d8e3397bed42dd09d9a386a85568f084df69fbd869d5b86981472  guix-build-19f3896c9a6a/output/riscv64-linux-gnu/bitcoin-19f3896c9a6a-riscv64-linux-gnu.tar.gz
61e4f3e657ac1b42431167c02e816bc874eb27597b15b4f16ee4ce43076e1795  guix-build-19f3896c9a6a/output/x86_64-apple-darwin19/SHA256SUMS.part
3d1117e5e195b3ad48a70af2a9b362b100774562bd43f290d2591fcc7c8d2cff  guix-build-19f3896c9a6a/output/x86_64-apple-darwin19/bitcoin-19f3896c9a6a-osx-unsigned.dmg
8e96a48f5e4d72ebe8823fd7e02dbb70c0de91ca391050152da5724c090d46cd  guix-build-19f3896c9a6a/output/x86_64-apple-darwin19/bitcoin-19f3896c9a6a-osx-unsigned.tar.gz
27cdaf70d1897520aca1f079abc39012ee71c4048886236e50b5906373ddb29e  guix-build-19f3896c9a6a/output/x86_64-apple-darwin19/bitcoin-19f3896c9a6a-osx64.tar.gz
ae36a6ff945092150878bbd509cd4e4f3ff1596d21855aced1be1e4846a8c103  guix-build-19f3896c9a6a/output/x86_64-linux-gnu/SHA256SUMS.part
c0a415f2ac58e1af4d195ba27652014de147a6039ca26dcdca3027ee315c1347  guix-build-19f3896c9a6a/output/x86_64-linux-gnu/bitcoin-19f3896c9a6a-x86_64-linux-gnu-debug.tar.gz
f96a59ebab15b3936c966553365caf4b198626d8b8a7fbf4dd24e88b0db9dc66  guix-build-19f3896c9a6a/output/x86_64-linux-gnu/bitcoin-19f3896c9a6a-x86_64-linux-gnu.tar.gz
1e23c0cf4cefc80ab1706eccf68aeba3575e510bc69565bd4bc2c29a1a6c5ad6  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/SHA256SUMS.part
30372abc5e1d810a5b52cac195fa13723f4fb0a0bb327ac18a123ca5c21fbd44  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/bitcoin-19f3896c9a6a-win-unsigned.tar.gz
ba7b57dbfe7b61d349d1eeb46a923fc53ac5897b7cc2f1a770765ffa186e0572  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/bitcoin-19f3896c9a6a-win64-debug.zip
4be16b33b432d34e40a018d196e86210e393df476691fc23c9f1ec69b7dc7b0b  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/bitcoin-19f3896c9a6a-win64-setup-unsigned.exe
45628090057e319751ccc940b880c93c6bc8510bf93f863b0f6435106e589ec7  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/bitcoin-19f3896c9a6a-win64.zip

@jarolrod
Copy link
Member

Interesting, concept ACK

GUIX hashes, mine match @hebasto:

cd821fb2efbb8ead184ef32559fd6cf8a0bb87fa8bb0bf8d7952de440c32e44e  guix-build-19f3896c9a6a/output/aarch64-linux-gnu/SHA256SUMS.part
13d1ea066972d4c39090183e8a5053a7c32f1faf5fcca00549aefc3ca43d25c4  guix-build-19f3896c9a6a/output/aarch64-linux-gnu/bitcoin-19f3896c9a6a-aarch64-linux-gnu-debug.tar.gz
bf3bc56e29a9bbde1c9dab5fc3573da79ba25c1256720fdaff66bca649e275b1  guix-build-19f3896c9a6a/output/aarch64-linux-gnu/bitcoin-19f3896c9a6a-aarch64-linux-gnu.tar.gz
49b03284cd373b6e18b6fcc79a419ff8b769f5c63f1c1bbf2328e2ee6aa3fe9e  guix-build-19f3896c9a6a/output/arm-linux-gnueabihf/SHA256SUMS.part
970215788561cbbf50b7e285548db76bbcc00660615305d5a0f4abcc643799b6  guix-build-19f3896c9a6a/output/arm-linux-gnueabihf/bitcoin-19f3896c9a6a-arm-linux-gnueabihf-debug.tar.gz
9bf1cff65d07e41230fc676d5eb3a22a68dec56294cfb1c2dd613e60ef8c2626  guix-build-19f3896c9a6a/output/arm-linux-gnueabihf/bitcoin-19f3896c9a6a-arm-linux-gnueabihf.tar.gz
0c98403967aa48610fbe953df1aa56d30d11da0c9013640d5e9df867348793b4  guix-build-19f3896c9a6a/output/dist-archive/bitcoin-19f3896c9a6a.tar.gz
d598262841072b5663e3a67fe55365e506dce1ee6b6467af1e23cb3aa7ed7c80  guix-build-19f3896c9a6a/output/powerpc64-linux-gnu/SHA256SUMS.part
df9f13656780a2e2f4ba127280cb3f417c4e43c55efb9413e67fe27738b52dc1  guix-build-19f3896c9a6a/output/powerpc64-linux-gnu/bitcoin-19f3896c9a6a-powerpc64-linux-gnu-debug.tar.gz
862b7b05bd622b2b6f4e9425afd08fa2219bb08187dcf454c7e52dd37d142efd  guix-build-19f3896c9a6a/output/powerpc64-linux-gnu/bitcoin-19f3896c9a6a-powerpc64-linux-gnu.tar.gz
45184c8e2ec75712473a6e8d7de1676fcfd051867130230f49f16bdfa74bea98  guix-build-19f3896c9a6a/output/powerpc64le-linux-gnu/SHA256SUMS.part
2b842d75c5965f571cb9bf61b748605485fa3c93fb5a0ddd5c00b6c35c65307b  guix-build-19f3896c9a6a/output/powerpc64le-linux-gnu/bitcoin-19f3896c9a6a-powerpc64le-linux-gnu-debug.tar.gz
52b8aa6ed35338d6a5e38db4d6476b56aaf3298b690d0aed5413a944ca483a5d  guix-build-19f3896c9a6a/output/powerpc64le-linux-gnu/bitcoin-19f3896c9a6a-powerpc64le-linux-gnu.tar.gz
cb591a7ddc87eb9068b9a52b87f6300b6a8ad27bb08cf80ffa2c4f47b3c5dbb7  guix-build-19f3896c9a6a/output/riscv64-linux-gnu/SHA256SUMS.part
c4e4083462ec34d9770e0a8ce823eb5046d5879fc82d87a0d696f62bd6bc578c  guix-build-19f3896c9a6a/output/riscv64-linux-gnu/bitcoin-19f3896c9a6a-riscv64-linux-gnu-debug.tar.gz
297b5c58b56d8e3397bed42dd09d9a386a85568f084df69fbd869d5b86981472  guix-build-19f3896c9a6a/output/riscv64-linux-gnu/bitcoin-19f3896c9a6a-riscv64-linux-gnu.tar.gz
61e4f3e657ac1b42431167c02e816bc874eb27597b15b4f16ee4ce43076e1795  guix-build-19f3896c9a6a/output/x86_64-apple-darwin19/SHA256SUMS.part
3d1117e5e195b3ad48a70af2a9b362b100774562bd43f290d2591fcc7c8d2cff  guix-build-19f3896c9a6a/output/x86_64-apple-darwin19/bitcoin-19f3896c9a6a-osx-unsigned.dmg
8e96a48f5e4d72ebe8823fd7e02dbb70c0de91ca391050152da5724c090d46cd  guix-build-19f3896c9a6a/output/x86_64-apple-darwin19/bitcoin-19f3896c9a6a-osx-unsigned.tar.gz
27cdaf70d1897520aca1f079abc39012ee71c4048886236e50b5906373ddb29e  guix-build-19f3896c9a6a/output/x86_64-apple-darwin19/bitcoin-19f3896c9a6a-osx64.tar.gz
ae36a6ff945092150878bbd509cd4e4f3ff1596d21855aced1be1e4846a8c103  guix-build-19f3896c9a6a/output/x86_64-linux-gnu/SHA256SUMS.part
c0a415f2ac58e1af4d195ba27652014de147a6039ca26dcdca3027ee315c1347  guix-build-19f3896c9a6a/output/x86_64-linux-gnu/bitcoin-19f3896c9a6a-x86_64-linux-gnu-debug.tar.gz
f96a59ebab15b3936c966553365caf4b198626d8b8a7fbf4dd24e88b0db9dc66  guix-build-19f3896c9a6a/output/x86_64-linux-gnu/bitcoin-19f3896c9a6a-x86_64-linux-gnu.tar.gz
1e23c0cf4cefc80ab1706eccf68aeba3575e510bc69565bd4bc2c29a1a6c5ad6  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/SHA256SUMS.part
30372abc5e1d810a5b52cac195fa13723f4fb0a0bb327ac18a123ca5c21fbd44  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/bitcoin-19f3896c9a6a-win-unsigned.tar.gz
ba7b57dbfe7b61d349d1eeb46a923fc53ac5897b7cc2f1a770765ffa186e0572  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/bitcoin-19f3896c9a6a-win64-debug.zip
4be16b33b432d34e40a018d196e86210e393df476691fc23c9f1ec69b7dc7b0b  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/bitcoin-19f3896c9a6a-win64-setup-unsigned.exe
45628090057e319751ccc940b880c93c6bc8510bf93f863b0f6435106e589ec7  guix-build-19f3896c9a6a/output/x86_64-w64-mingw32/bitcoin-19f3896c9a6a-win64.zip

@DrahtBot
Copy link
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22486 (build: Avoid rebuilding makefiles by dgoncharov)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 19f3896 - 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.

@fanquake fanquake merged commit 7629efc into bitcoin:master Dec 9, 2021
@hebasto hebasto deleted the 211126-cross branch December 9, 2021 13:28
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 10, 2021
…macOS

19f3896 build: Fix x86_64 <-> arm64 cross-compiling for macOS (Hennadii Stepanov)

Pull request description:

  Currently, on master (111c3e0), 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#22506.

ACKs for top commit:
  fanquake:
    ACK 19f3896 - this is definitely cleaner than the approach in bitcoin#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
@hebasto
Copy link
Member Author

hebasto commented Dec 19, 2021

Unfortunately, this PR introduced a regression which is fixed in #23817.

RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
…ing for macOS

ad46528 build: Fix x86_64 <-> arm64 cross-compiling for macOS (Hennadii Stepanov)

Pull request description:

  Currently, on master (e475dd3), 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 ad46528 - 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
fanquake added a commit to bitcoin-core/gui that referenced this pull request Dec 27, 2021
d3b0f82 build: Fix regression introduced in PR23603 (Hennadii Stepanov)

Pull request description:

  It appears 7629efc from bitcoin/bitcoin#23603 introduced a regression in build tool flag evaluation.

  On macOS system:
  - pre-PR23603 master (ae017b8):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe
  ```
  - the current master (3699786):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-arch x86_64
  ```

  It's obvious a flag being set in `depends/hosts/darwin.mk`, i.e., `-pipe`, is lost.

  With this PR:
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe -arch x86_64
  ```

ACKs for top commit:
  fanquake:
    ACK d3b0f82

Tree-SHA512: 643099ce6858475ac9f3a4dfa72a4e493fec6fdd7042ae0f0d5fe44c5cd175e4eda63cb39fc46ac1501cadcd3466507ec88d9089235e005fe43ea7ab47ce37c1
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 28, 2021
d3b0f82 build: Fix regression introduced in PR23603 (Hennadii Stepanov)

Pull request description:

  It appears 7629efc from bitcoin#23603 introduced a regression in build tool flag evaluation.

  On macOS system:
  - pre-PR23603 master (ae017b8):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe
  ```
  - the current master (3699786):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-arch x86_64
  ```

  It's obvious a flag being set in `depends/hosts/darwin.mk`, i.e., `-pipe`, is lost.

  With this PR:
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe -arch x86_64
  ```

ACKs for top commit:
  fanquake:
    ACK d3b0f82

Tree-SHA512: 643099ce6858475ac9f3a4dfa72a4e493fec6fdd7042ae0f0d5fe44c5cd175e4eda63cb39fc46ac1501cadcd3466507ec88d9089235e005fe43ea7ab47ce37c1
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 7, 2022
…macOS

19f3896 build: Fix x86_64 <-> arm64 cross-compiling for macOS (Hennadii Stepanov)

Pull request description:

  Currently, on master (111c3e0), 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#22506.

ACKs for top commit:
  fanquake:
    ACK 19f3896 - this is definitely cleaner than the approach in bitcoin#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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 7, 2022
d3b0f82 build: Fix regression introduced in PR23603 (Hennadii Stepanov)

Pull request description:

  It appears 7629efc from bitcoin#23603 introduced a regression in build tool flag evaluation.

  On macOS system:
  - pre-PR23603 master (ae017b8):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe
  ```
  - the current master (3699786):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-arch x86_64
  ```

  It's obvious a flag being set in `depends/hosts/darwin.mk`, i.e., `-pipe`, is lost.

  With this PR:
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe -arch x86_64
  ```

ACKs for top commit:
  fanquake:
    ACK d3b0f82

Tree-SHA512: 643099ce6858475ac9f3a4dfa72a4e493fec6fdd7042ae0f0d5fe44c5cd175e4eda63cb39fc46ac1501cadcd3466507ec88d9089235e005fe43ea7ab47ce37c1
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 7, 2022
…macOS

19f3896 build: Fix x86_64 <-> arm64 cross-compiling for macOS (Hennadii Stepanov)

Pull request description:

  Currently, on master (111c3e0), 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#22506.

ACKs for top commit:
  fanquake:
    ACK 19f3896 - this is definitely cleaner than the approach in bitcoin#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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 7, 2022
d3b0f82 build: Fix regression introduced in PR23603 (Hennadii Stepanov)

Pull request description:

  It appears 7629efc from bitcoin#23603 introduced a regression in build tool flag evaluation.

  On macOS system:
  - pre-PR23603 master (ae017b8):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe
  ```
  - the current master (3699786):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-arch x86_64
  ```

  It's obvious a flag being set in `depends/hosts/darwin.mk`, i.e., `-pipe`, is lost.

  With this PR:
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe -arch x86_64
  ```

ACKs for top commit:
  fanquake:
    ACK d3b0f82

Tree-SHA512: 643099ce6858475ac9f3a4dfa72a4e493fec6fdd7042ae0f0d5fe44c5cd175e4eda63cb39fc46ac1501cadcd3466507ec88d9089235e005fe43ea7ab47ce37c1
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 7, 2022
…macOS

19f3896 build: Fix x86_64 <-> arm64 cross-compiling for macOS (Hennadii Stepanov)

Pull request description:

  Currently, on master (111c3e0), 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#22506.

ACKs for top commit:
  fanquake:
    ACK 19f3896 - this is definitely cleaner than the approach in bitcoin#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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 7, 2022
d3b0f82 build: Fix regression introduced in PR23603 (Hennadii Stepanov)

Pull request description:

  It appears 7629efc from bitcoin#23603 introduced a regression in build tool flag evaluation.

  On macOS system:
  - pre-PR23603 master (ae017b8):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe
  ```
  - the current master (3699786):
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-arch x86_64
  ```

  It's obvious a flag being set in `depends/hosts/darwin.mk`, i.e., `-pipe`, is lost.

  With this PR:
  ```
  % make -C depends print-darwin_CXXFLAGS
  darwin_CXXFLAGS=-pipe
  % make -C depends print-host_CXXFLAGS
  host_CXXFLAGS=-pipe -arch x86_64
  ```

ACKs for top commit:
  fanquake:
    ACK d3b0f82

Tree-SHA512: 643099ce6858475ac9f3a4dfa72a4e493fec6fdd7042ae0f0d5fe44c5cd175e4eda63cb39fc46ac1501cadcd3466507ec88d9089235e005fe43ea7ab47ce37c1
@bitcoin bitcoin locked and limited conversation to collaborators Dec 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants