Skip to content

build: macOS toolchain update#16392

Merged
laanwj merged 3 commits intobitcoin:masterfrom
fanquake:macos-toolchain-update
Feb 5, 2020
Merged

build: macOS toolchain update#16392
laanwj merged 3 commits intobitcoin:masterfrom
fanquake:macos-toolchain-update

Conversation

@fanquake
Copy link
Member

@fanquake fanquake commented Jul 15, 2019

TLDR: This updates our macOS toolchain to use a newer version of Clang, cctools (including new dependency on libtapi), LD64 and the macOS SDK.

I've been testing depends builds (HOST=x86_64-apple-darwin16) inside a Debian Buster Docker container, and running the resultant bitcoind and bitcoin-qt binaries on a macOS 10.14.4 system. The .dmg generated by a make deploy also mounts correctly on the same macOS system.

Clang

Upgraded from 3.7.1 to 6.0.1

cctools

See tpoechtrager/cctools-port and tpoechtrager/apple-libtapi.

macOS SDK

Upgraded from building against the macOS 10.11 SDK to the macOS 10.14 SDK.

TODO

  • Make the 10.14 SDK available to Travis.

Fixes: #16052
Closes: #14797

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 15, 2019

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #17919 (depends: Allow building with system clang by dongcarl)
  • #15441 ([doc] build: warn against spaces in working directory by Sjors)
  • #12557 ([WIP] 64 bit iOS device support by Sjors)

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.

@fanquake fanquake force-pushed the macos-toolchain-update branch from 077b9df to 31f7825 Compare July 15, 2019 09:02
Copy link
Member

@theuni theuni left a comment

Choose a reason for hiding this comment

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

Nice! Concept ack.

+1 for a new prog to replace our dmg hacks. I think that might also mean that we could get rid of CMake.

Will review in depth.

@bitcoin bitcoin deleted a comment from DrahtBot Jul 22, 2019
@practicalswift
Copy link
Contributor

Concept ACK

@DrahtBot
Copy link
Contributor

Needs rebase

@Sjors
Copy link
Member

Sjors commented Jul 25, 2019

Tested building depends on macOS 10.14.6 Mojave. I still had to do this annoying workaround:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

And building protobuf fails: log

If I remove protobuf and native_protobuf it does build. I can then compile QT:

./autogen.sh
./configure --prefix=`pwd`/depends/x86_64-apple-darwin18.7.0 --disable-bip70
make

This works, but I get a flood of warnings at the end: log

Will test on macOS 10.15 Catalina later.

We should backport this to 0.18 given #16387 and ideally do a 0.18.2 tag before Catalina is out (September or October). Our 0.19 release is scheduled for November #15940, so otherwise there's no tag to build from.

Concept ACK on bumping macOS from 10.10 to 10.12, though a small percentage of users would have to stay on the 0.18 branch (the last tag before backport).

The bottleneck for upgrading macOS is hardware, and that's pretty durable. Here are the minimum specs for 10.10:
system 10 10

Minimum specs for 10.12:
system 10 12

Some refurbished machines for sale:
refurbished

Some second hand machines at an even lower price point still work:
macbook pro 2011

Some don't:
macbook pro 2009

@fanquake
Copy link
Member Author

I still had to do this annoying workaround:

Yep, that isn't new with this change, but may go away if we can remove any reliance on having the headers in the now deprecated location. See details in the Command Line Tools section of the Xcode 10 release notes.

If I remove protobuf and native_protobuf it does build. I can then compile QT:

Did you try to build depends before installing the new headers? If you make clean in depends, then try rebuilding as usual it should work. Nothing Protobuf related is being changed in this PR.

@fanquake fanquake force-pushed the macos-toolchain-update branch from 31f7825 to 536034b Compare July 26, 2019 01:01
@jonasschnelli
Copy link
Contributor

Concept ACK.
Unsure about the timing, if its already the time to drop 10.10 & 10.11 since 10.11 was released on Oct 2015.
According to statista, in April 2019, 10.10 and 10.11 makes about 16% of mac installations.
(https://www.statista.com/statistics/944559/worldwide-macos-version-market-share/)

Aidium publishes their update stats and it looks like, >10% was using 10.11 this week.
https://www.adium.im/sparkle/

It'd say we wait with this.

@Sjors
Copy link
Member

Sjors commented Jul 26, 2019

Did you try to build depends before installing the new headers? If you make clean in depends

I thought I did, but maybe not. I just tried make clean and now protobuf indeed just buids (on
536034b).

It'd say we wait with this.

If it doesn't break anything else, maybe we can do this bump when we bump QT to 5.12 (LTS)?

@fanquake fanquake force-pushed the macos-toolchain-update branch from 536034b to 7decfd4 Compare July 30, 2019 02:00
@fanquake
Copy link
Member Author

Updated to add some documentation (Linux) for the macOS 10.14 SDK extraction. This doesn't have to be the final docs, but should be useful for someone on a Linux machine wanting to extract the SDK and test this PR.

It'd say we wait with this.

We don't have to bump the minimum to 10.12 right now. We could do 10.11, or potentially leave it at 10.10 assuming there aren't any issues using the new SDK. Regardless, I'd like the rest of the changes (or at least the new Clang) to make it into v0.19.0, so that building for macOS isn't broken on Debian Buster #16052.

@Sjors
Copy link
Member

Sjors commented Aug 1, 2019

From Apple: "All Macintosh computers that can run Mountain Lion, Mavericks, or Yosemite can run El Capitan" (10.11). I suspect many people just don't realize they can upgrade.

I managed to build depends on macOS 10.14.6 (Mojave) with the minimum version set to 10.10

[...] may go away if we can remove any reliance on having the headers in the now deprecated location

That means this PR is not enough to support Catalina, at least not without some other workaround.

Copy link
Member

@theuni theuni left a comment

Choose a reason for hiding this comment

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

For the most part this looks great. I've added a few notes around libtapi which still needs a little work IMO.

I've not tried building yet, I'll work on getting an SDK extracted.

$(MAKE) DESTDIR=$($(package)_staging_dir) install && \
mkdir -p $($(package)_staging_prefix_dir)/lib/ && \
cd $($(package)_extract_dir)/installed_libtapi && \
cp lib/libtapi.so.6 $($(package)_staging_prefix_dir)/lib/ && \
Copy link
Member

Choose a reason for hiding this comment

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

We want this built statically if possible, otherwise this introduces a (rather unnecessary) LDPATH runtime requirement. Does build.sh have static lib support?

@theuni
Copy link
Member

theuni commented Aug 2, 2019

I tested a few of my cleanup suggestions above, and they seem to work fine.
Feel free to pull the top two from here: https://github.com/theuni/bitcoin/commits/16392, or adapt them into your commits however's easiest.

@fanquake fanquake force-pushed the macos-toolchain-update branch from 7decfd4 to 97b3349 Compare August 5, 2019 03:47
@fanquake
Copy link
Member Author

fanquake commented Aug 5, 2019

@theuni I've incorporated some of your suggestions (trimming the LD64 stuff, and the clang hacks) and added you as co-author to the relevant commits.

We are now pointing back to upstream libdmg-hfsplus, with a single patch included in depends.

We are also now pointing back to the upstream cctools-port repo.

libtapi is now being built with our 6.0.1 Clang and I've removed one of the intermediate directories I was creating.

I still need to address:

We want this built statically if possible, otherwise this introduces a (rather unnecessary) LDPATH runtime requirement. Does build.sh have static lib support?

@Sjors
Copy link
Member

Sjors commented Aug 5, 2019

Building depends on macOS 10.14.6 Mojave still works as of 97b3349.

fanquake and others added 3 commits February 3, 2020 19:49
This also removes some now-unnecessary cctools hacks.

Co-Authored-By: Cory Fields <[email protected]>
This also removes the obsolete mlinker-version option

Co-Authored-By: Cory Fields <[email protected]>
@jonasschnelli
Copy link
Contributor

Tested ACK via a depends build with macOS SDK 10.14:
https://bitcoinbuilds.org/?job=e969d43f-2cd8-4890-b5ae-bcc2d0ea4195

@hebasto
Copy link
Member

hebasto commented Feb 3, 2020

FWIW https://bitcoincore.org/depends-sources/sdks/MacOSX10.14.sdk.tar.gz is up

Downloaded file

$ sha256sum MacOSX10.14.sdk.tar.gz 
2530c1d88f1aca98994cf32cfcf6099d880965ef0200b8b2a87279c191d56766  MacOSX10.14.sdk.tar.gz

seems broken.

UPDATE: it was a download error. This one

$ sha256sum MacOSX10.14.sdk.tar.gz 
328aff47e28c17093d59a72712a9b2e62cd8a8b87bbe03f91abb32960b413f0f  MacOSX10.14.sdk.tar.gz

is ok.

@hebasto
Copy link
Member

hebasto commented Feb 3, 2020

Tested ca5055a

Cross compilation on Linux Mint 19.3 with depends and MacOSX10.14.sdk was contaminated by system Qt packages (#18042, #18045, #18051):

$ make HOST=x86_64-apple-darwin16 -C depends
$ ./autogen.sh
$ CONFIG_SITE=$PWD/depends/x86_64-apple-darwin16/share/config.site ./configure
$ make
...
  CXX      qt/qt_libbitcoinqt_a-peertablemodel.o
qt/notificator.cpp:50:21: error: allocation of incomplete type 'QDBusInterface'
    interface = new QDBusInterface("org.freedesktop.Notifications",
                    ^~~~~~~~~~~~~~
...

The patch from #18051 was applied, then compilation passed successfully with loads of linker warnings like this:

  AR       qt/libbitcoinqt.a
  CXXLD    qt/bitcoin-qt
  CXXLD    qt/test/test_bitcoin-qt
ld: warning: direct access in function '__ZN5boost10filesystem6detail9canonicalERKNS0_4pathES4_PNS_6system10error_codeE' from file '/home/hebasto/GitHub/bitcoin/depends/x86_64-apple-darwin16/lib/libboost_filesystem-mt-x64.a(operations.o)' to global weak symbol '__ZZN5boost6system16generic_categoryEvE25generic_category_instance' from file 'libbitcoin_server.a(libbitcoin_server_a-init.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
...

The resulted Bitcoin-Core.dmg was successfully installed on macOS 10.14 then launched .

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 4, 2020

Gitian builds

File commit 365c83e
(master)
commit 27d2f29cdaf55523fec312e3d2e2bdaac03e7e97
(master and this pull)
bitcoin-0.19.99-aarch64-linux-gnu-debug.tar.gz 970e730072cb3102... 8609bbf1aa2b58f9...
bitcoin-0.19.99-aarch64-linux-gnu.tar.gz 935312465c6da174... 8388955a9e05dd7e...
bitcoin-0.19.99-arm-linux-gnueabihf-debug.tar.gz 0ed6a37c55b14a2e... 20db37c7ce005f42...
bitcoin-0.19.99-arm-linux-gnueabihf.tar.gz 028f778eb4927763... 892195271fa0ef4f...
bitcoin-0.19.99-i686-pc-linux-gnu-debug.tar.gz 1db644cdfe7214fb... 6b89a91ee86e506a...
bitcoin-0.19.99-i686-pc-linux-gnu.tar.gz 287253ed7574eaea... c9fddc77aca47dc9...
bitcoin-0.19.99-osx-unsigned.dmg 821863528e68ec86...
bitcoin-0.19.99-osx64.tar.gz 1786b62a871209a2...
bitcoin-0.19.99-riscv64-linux-gnu-debug.tar.gz 22d076616e4c906e... 44e10a5b413dedab...
bitcoin-0.19.99-riscv64-linux-gnu.tar.gz c28b4fa1737df120... 2d2fa6cae56012cc...
bitcoin-0.19.99-win64-debug.zip b9cae2f4ecb811b5... 6cf65d842ba0ecd0...
bitcoin-0.19.99-win64-setup-unsigned.exe 33d162f55ec7a280... 8ae915b5ab910106...
bitcoin-0.19.99-win64.zip 2e9c7f3b6a81a019... 3fbd03c061614891...
bitcoin-0.19.99-x86_64-linux-gnu-debug.tar.gz c6d3a034928bf42f... 65ac2d3021cc8432...
bitcoin-0.19.99-x86_64-linux-gnu.tar.gz 3398c21d3cc2db4a... 13c74d3483fbe588...
bitcoin-0.19.99.tar.gz 53fdfce17dfd576e... 90861a5bf809f2cf...
bitcoin-core-linux-0.20-res.yml 5e3e3dc9d073bfe0... 38e155a1cb06ac2d...
bitcoin-core-osx-0.20-res.yml bb414d323b8702a3...
bitcoin-core-win-0.20-res.yml 713d925b71fce216... 9e38b7994e600f6b...
linux-build.log 0fa8aec26c2484b6... bf6f649b3431eb01...
osx-build.log 1e49555bff5faba3... 0a7dadee8b6a8695...
win-build.log e61928f15b54a519... baa346388eb2b994...
bitcoin-core-linux-0.20-res.yml.diff 99f87cfaad3ddb04...
bitcoin-core-win-0.20-res.yml.diff 621c33c6d581cc43...
linux-build.log.diff 6bbb682595787575...
osx-build.log.diff ee4f9786dbeacc12...
win-build.log.diff 2680bcc8a823d25c...

@fanquake
Copy link
Member Author

fanquake commented Feb 4, 2020

@MarcoFalke Looks like DrahtBot is still missing the new SDK.

@Sjors
Copy link
Member

Sjors commented Feb 4, 2020

re-ACK 7e21044 (rebased from 248526e)

@dongcarl
Copy link
Contributor

dongcarl commented Feb 4, 2020

@fanquake I apologize for my lateness, but here's my outstanding changes so that we can generate and use the SDK with headers as requested: fanquake/bitcoin@macos-toolchain-update...dongcarl:2020-01-macos-sdk-with-headers

Here are the new instructions: https://github.com/dongcarl/bitcoin/blob/adf9968de5dc872e3c51e538f6b99e9423b65bd3/contrib/macdeploy/README.md#step-2-generating-macosx1014sdktargz-from-xcodeapp

@laanwj
Copy link
Member

laanwj commented Feb 5, 2020

Let's try to get this merged soon—if we still want this for 0.20 it's not something that should be done last minute.

@dongcarl
Copy link
Contributor

dongcarl commented Feb 5, 2020

ACK 7e21044


Immediate followup: #18072

@Empact
Copy link
Contributor

Empact commented Feb 5, 2020

Built depends successfully on 10.14.6

Is there anything more to say re the "obsolete mlinker-version option"? Is it obsolete only in that it is no longer required for build?

laanwj added a commit that referenced this pull request Feb 5, 2020
7e21044 build: use macOS 10.14 SDK (fanquake)
ca5055a depends: native_cctools 921, ld64 409.12, libtapi 1000.10.8 (fanquake)
1de8c06 depends: clang 6.0.1 (fanquake)

Pull request description:

  TLDR: This updates our macOS toolchain to use a newer version of Clang, cctools (including new [dependency on libtapi](https://github.com/tpoechtrager/cctools-port/tree/master#dependencies)), LD64 and the macOS SDK.

  I've been testing depends builds (`HOST=x86_64-apple-darwin16`) inside a Debian Buster [Docker container](https://github.com/fanquake/core-review/blob/master/docker/debian.dockerfile), and running the resultant `bitcoind` and `bitcoin-qt` binaries on a macOS `10.14.4` system. The `.dmg` generated by a `make deploy` also mounts correctly on the same macOS system.

  #### Clang
  Upgraded from `3.7.1` to [`6.0.1`](https://releases.llvm.org/6.0.1/docs/ReleaseNotes.html)

  #### cctools
  * cctools `877.8` -> [`921`](https://opensource.apple.com/tarballs/cctools/)
  * LD64 `253.9` -> [`409.12`](https://opensource.apple.com/source/ld64/)
  * TAPI [`1000.10.8`](https://opensource.apple.com/tarballs/tapi/)

  See [tpoechtrager/cctools-port](https://github.com/tpoechtrager/cctools-port/) and [tpoechtrager/apple-libtapi](https://github.com/tpoechtrager/apple-libtapi/).

  #### macOS SDK
  Upgraded from building against the macOS `10.11` SDK to the macOS `10.14` SDK.

  #### TODO
  - [x] Make the `10.14` SDK available to Travis.

  Fixes: #16052
  Closes: #14797

ACKs for top commit:
  Sjors:
    re-ACK 7e21044 (rebased from 248526e)
  dongcarl:
    ACK 7e21044

Tree-SHA512: fd36a33dbfb98c144240f8c69b77343e3f5bc18d8cf7d40fff61f51ad48925ec1872e6daba34c4045b18b4c2c84c22c744ebf4cba11061a0305eed13975ceefe
@laanwj laanwj merged commit 7e21044 into bitcoin:master Feb 5, 2020
@laanwj
Copy link
Member

laanwj commented Feb 5, 2020

@fanquake I apologize for my lateness, but here's my outstanding changes so that we can generate and use the SDK with headers as requested: fanquake/[email protected]:2020-01-macos-sdk-with-headers

Thanks, please add these instructions in a new PR!

@dongcarl
Copy link
Contributor

dongcarl commented Feb 5, 2020

@fanquake I apologize for my lateness, but here's my outstanding changes so that we can generate and use the SDK with headers as requested: fanquake/[email protected]:2020-01-macos-sdk-with-headers

Thanks, please add these instructions in a new PR!

It's here! :-) #18072

@fanquake fanquake deleted the macos-toolchain-update branch February 6, 2020 01:50
laanwj added a commit that referenced this pull request Feb 28, 2020
dc9305b random: don't special case clock usage on macOS (fanquake)

Pull request description:

  `clock_gettime()`, `CLOCK_MONOTONIC` and `CLOCK_REALTIME` are all available for use on
  macOS (now that we require macOS >=10.12 and build against 10.14). Use them rather than the [deprecated](https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/Mach/Mach.html) `mach_timespec_t` time API.

  I mentioned the possibility for this change [in #17270](#17270 (comment)).

  [master](1dbf335):
  ```bash
  2019-12-23T20:49:43Z Feeding 216 bytes of dynamic environment data into RNG
  2019-12-23T20:50:43Z Feeding 216 bytes of dynamic environment data into RNG
  ```

  This PR:
  ```bash
  2019-12-23T20:32:41Z Feeding 232 bytes of dynamic environment data into RNG
  2019-12-23T20:33:42Z Feeding 232 bytes of dynamic environment data into RNG
  ```

  ~~Depends on #16392.~~ Merged.

ACKs for top commit:
  laanwj:
    ACK dc9305b

Tree-SHA512: 18c2f336ea628f9cf7339b817381d230a18893fd9c0351bf99a39ca6f45c5b0a20af9d599d48d6c09515627d5edafa91337c17f9f790264251d2cdcb3763bbd5
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 29, 2020
dc9305b random: don't special case clock usage on macOS (fanquake)

Pull request description:

  `clock_gettime()`, `CLOCK_MONOTONIC` and `CLOCK_REALTIME` are all available for use on
  macOS (now that we require macOS >=10.12 and build against 10.14). Use them rather than the [deprecated](https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/Mach/Mach.html) `mach_timespec_t` time API.

  I mentioned the possibility for this change [in bitcoin#17270](bitcoin#17270 (comment)).

  [master](1dbf335):
  ```bash
  2019-12-23T20:49:43Z Feeding 216 bytes of dynamic environment data into RNG
  2019-12-23T20:50:43Z Feeding 216 bytes of dynamic environment data into RNG
  ```

  This PR:
  ```bash
  2019-12-23T20:32:41Z Feeding 232 bytes of dynamic environment data into RNG
  2019-12-23T20:33:42Z Feeding 232 bytes of dynamic environment data into RNG
  ```

  ~~Depends on bitcoin#16392.~~ Merged.

ACKs for top commit:
  laanwj:
    ACK dc9305b

Tree-SHA512: 18c2f336ea628f9cf7339b817381d230a18893fd9c0351bf99a39ca6f45c5b0a20af9d599d48d6c09515627d5edafa91337c17f9f790264251d2cdcb3763bbd5
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.

depends: Issue cross compiling for macOS on Debian Buster Bump macOS SDK version to 10.13 for gitian builds