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: use -isysroot over --sysroot on macOS #21793

Merged
merged 1 commit into from
May 1, 2021

Conversation

fanquake
Copy link
Member

Not only does this seem to be the more correct behaviour when targeting Darwin, but if you use -isysroot, Clangs Darwin driver will infer the deployment target from the SDK and use other SDK info when parsing arguments to the linker. In the case of -platform_version, which is added if the linker is new enough, the version tuple is constructed from the SDKInfo, and SDKInfo, as far as I can tell, only exists when -isysroot has been passed, see parseSDKSettings

As a result, the SDK version field in the LC_BUILD_VERSION command is filled out. i.e when building master:

      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 10.14
      sdk n/a
   ntools 1
     tool 3
  version 650.9

vs this PR:

      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 10.14
      sdk 11.3
   ntools 1
     tool 3
  version 650.9

This, from what I understand, will fix the issue we are having with Qt deciding wether or not to enable features like "Dark mode" on macOS, see #21771, however I have not tested that. Thus this is an alternative to #21782.

Our usage of --sysroot was added in #17118.

-isysroot <dir>         Set the system root directory (usually /)

@promag
Copy link
Contributor

promag commented Apr 28, 2021

Tested ACK 6777543 on macOS 11.2.3 (Big Sur) arm-apple-darwin20.3.0.

@fanquake fanquake force-pushed the macos_use_isysroot branch from 6777543 to 1f3932e Compare April 28, 2021 10:24
Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

Approach ACK 1f3932e.

Tested for builds with depends:

  • macOS Big Sur 11.3 (20E232)
% otool -l src/qt/bitcoin-qt | grep -A 7 -B 1 BUILD_VERSION                                                           
Load command 9
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 10.14
      sdk 11.3
   ntools 1
     tool 3
  version 650.9
  • macOS Mojave 10.14.6 (18G9028)
$ otool -l src/qt/bitcoin-qt | grep -A 7 -B 1 BUILD_VERSION
Load command 9
       cmd LC_BUILD_VERSION
   cmdsize 32
  platform macos
       sdk 10.14
     minos 10.14
    ntools 1
      tool ld
   version 450.3

The dark mode works in both cases above.

nit: This change could be a scripted-diff.

Our docs should be updated as well.

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

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

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK 1f3932e

nit: Why not being consistent about absence/presence a space after -isysroot? Clang docs suggests the former.

Additionally to my previous tests, tested cross-compiling on Linux Mint 20.1 (x86_64):

  • this PR
$ depends/x86_64-apple-darwin18/native/bin/x86_64-apple-darwin18-otool -l src/qt/bitcoin-qt | grep -A 7 -B 1 BUILD_VERSION
Load command 9
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 10.14
      sdk 505.0
   ntools 1
     tool 3
  version 530.0
$ depends/x86_64-apple-darwin18/native/bin/x86_64-apple-darwin18-otool -l src/qt/bitcoin-qt | grep -A 7 -B 1 BUILD_VERSION
Load command 9
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 10.14
      sdk 10.15.6
   ntools 1
     tool 3
  version 609.0

The dark mode works in both cases above.

Clangs Darwin driver will infer the deployment target from the SDK and use other SDK info when parsing arguments to the linker.

It seems works in that way since llvm clang v8.0.0.

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

ACK 1f3932e

Tested this PR by performing the following for each supported macOS version (11, 10.15, 10.14) and checking SDK values and if dark mode works:

  • Native Depends Build
  • Native Depends Build with Toolchain Bump
  • Cross Compile from Linux
  • Cross Compile with Toolchain Bump

I have the branch with this PR + Toolchain Bump here: https://github.com/jarolrod/bitcoin/tree/21793_and_19817

@fanquake fanquake force-pushed the macos_use_isysroot branch from 1f3932e to cf971c9 Compare April 29, 2021 09:43
@fanquake
Copy link
Member Author

Why not being consistent about absence/presence a space after -isysroot? Clang docs suggests the former.
Our docs should be updated as well.

Addressed both.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

re-ACK cf971c9, only rebased and addressed comments since my previous review.

Guix build:

$ find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
fcb1b98f431d6467ea2fd77ba7d05b24012d84959845945fa2bed4aaeab92fad  guix-build-cf971c9ea0e8/output/dist-archive/bitcoin-cf971c9ea0e8.tar.gz
0982cc7b542cf0e6e03a48d30008945ffb2083625d72a907dd02a675c9cb1309  guix-build-cf971c9ea0e8/output/x86_64-apple-darwin18/bitcoin-cf971c9ea0e8-osx-unsigned.dmg
5d3087fb46f458eb34f28e07aa39db67c8b48420de319dc6aaea7e7bade78247  guix-build-cf971c9ea0e8/output/x86_64-apple-darwin18/bitcoin-cf971c9ea0e8-osx-unsigned.tar.gz
a4bdee56b3bf2bff2ae3e4061a173e5e9b2f4d264161dceb4ef6496c87ed4f89  guix-build-cf971c9ea0e8/output/x86_64-apple-darwin18/bitcoin-cf971c9ea0e8-osx64.tar.gz

Gitian build:

Generating report
cfc2a1ac9187bf7438ec1e45e057ffdf6811b9b0503107a2d3e8727f81083001  bitcoin-cf971c9ea0e8-osx-unsigned.dmg
b01df9e37555c31608f2e6df6bccdceb53064dd067733d31e1edcbdacdaa57dd  bitcoin-cf971c9ea0e8-osx-unsigned.tar.gz
f3b3a9cf79e8b6671a88e97de2b886fb853445919cd333ba9e4fd0ebf193ee99  bitcoin-cf971c9ea0e8-osx64.tar.gz
fcb1b98f431d6467ea2fd77ba7d05b24012d84959845945fa2bed4aaeab92fad  src/bitcoin-cf971c9ea0e8.tar.gz
8c436ea239b03f75aad8f5062dd751c72acbe03ec48bf4a5503d49ffd69b0edb  bitcoin-core-osx-22-res.yml
Done.

UPDATE: another gitian build (with guaranteed clear cache):

Generating report
cfc2a1ac9187bf7438ec1e45e057ffdf6811b9b0503107a2d3e8727f81083001  bitcoin-cf971c9ea0e8-osx-unsigned.dmg
b01df9e37555c31608f2e6df6bccdceb53064dd067733d31e1edcbdacdaa57dd  bitcoin-cf971c9ea0e8-osx-unsigned.tar.gz
f3b3a9cf79e8b6671a88e97de2b886fb853445919cd333ba9e4fd0ebf193ee99  bitcoin-cf971c9ea0e8-osx64.tar.gz
fcb1b98f431d6467ea2fd77ba7d05b24012d84959845945fa2bed4aaeab92fad  src/bitcoin-cf971c9ea0e8.tar.gz
2cd1011b1c37a6fd403884e66175376313285a3bd9119995fe04df975080b98a  bitcoin-core-osx-22-res.yml
Done.

@fanquake
Copy link
Member Author

Guix builds:

bash-5.1# find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
fcb1b98f431d6467ea2fd77ba7d05b24012d84959845945fa2bed4aaeab92fad  guix-build-cf971c9ea0e8/output/dist-archive/bitcoin-cf971c9ea0e8.tar.gz
0982cc7b542cf0e6e03a48d30008945ffb2083625d72a907dd02a675c9cb1309  guix-build-cf971c9ea0e8/output/x86_64-apple-darwin18/bitcoin-cf971c9ea0e8-osx-unsigned.dmg
5d3087fb46f458eb34f28e07aa39db67c8b48420de319dc6aaea7e7bade78247  guix-build-cf971c9ea0e8/output/x86_64-apple-darwin18/bitcoin-cf971c9ea0e8-osx-unsigned.tar.gz
a4bdee56b3bf2bff2ae3e4061a173e5e9b2f4d264161dceb4ef6496c87ed4f89  guix-build-cf971c9ea0e8/output/x86_64-apple-darwin18/bitcoin-cf971c9ea0e8-osx64.tar.gz

Gitian builds (Done twice, second with a cleared cache):

# macOS:
71fd96f0d87488a473c577bac1248085c48c4d925a6c3be09a5ea0adce6b54ae  bitcoin-cf971c9ea0e8-osx-unsigned.dmg
994a5175ce8dcba226976a708dd43cc459f891e11857c783f54b3e8c9f1570c4  bitcoin-cf971c9ea0e8-osx-unsigned.tar.gz
ae732d49acc56a44ddee1aa228d6c177df1473a824f65b780d15fd8613cc9801  bitcoin-cf971c9ea0e8-osx64.tar.gz
fcb1b98f431d6467ea2fd77ba7d05b24012d84959845945fa2bed4aaeab92fad  src/bitcoin-cf971c9ea0e8.tar.gz
13c6f297c299f45a9a7ea6f7f5284afdd155d58c6e9cbc12a47064e1e4d22b2a  bitcoin-core-osx-22-res.yml

@Sjors
Copy link
Member

Sjors commented Apr 29, 2021

tACK cf971c9

I built depends on macOS 11.3 Big Sur (XCode 12.5, Intel CPU) with the whole kitchen-sink make MULTIPROCESS=1 DEBUG=1 and then built and ran QT. It seems to work, including switching between dark and light mode.

otool -l src/qt/bitcoin-qt | grep -A 7 -B 1 BUILD_VERSION finds sdk 11.3

Also cross-compiled on Linux. otool finds sdk 505.0. There's some UI glitches when toggling between dark and light mode, but I guess that's what bitcoin-core/gui#275 is trying to fix.

(I used the previous push 1f3932e on macOS, and cf971c9 on Linux)

@fanquake fanquake merged commit bb11a98 into bitcoin:master May 1, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 1, 2021
cf971c9 build: use -isysroot over --sysroot on macOS (fanquake)

Pull request description:

  Not only does this seem to be the more correct behaviour when targeting Darwin, but if you use `-isysroot`, Clangs Darwin driver will [infer the deployment target](https://github.com/llvm/llvm-project/blob/3e037f8f0e26acab8cc784ea4c7d05da79f7c22e/clang/lib/Driver/ToolChains/Darwin.cpp#L1652) from the SDK and use other SDK info when parsing arguments to the linker. In the case of [`-platform_version`](https://github.com/llvm/llvm-project/blob/3e037f8f0e26acab8cc784ea4c7d05da79f7c22e/clang/lib/Driver/ToolChains/Darwin.cpp#L2656), which is added if the linker is [new enough](https://github.com/llvm/llvm-project/blob/3e037f8f0e26acab8cc784ea4c7d05da79f7c22e/clang/lib/Driver/ToolChains/Darwin.cpp#L342), the version tuple is constructed from the SDKInfo, and SDKInfo, as far as I can tell, only exists when `-isysroot` has been passed, see [parseSDKSettings](https://github.com/llvm/llvm-project/blob/3e037f8f0e26acab8cc784ea4c7d05da79f7c22e/clang/lib/Driver/ToolChains/Darwin.cpp#L1785)

  As a result, the SDK version field in the `LC_BUILD_VERSION` command is filled out. i.e when building master:
  ```bash
        cmd LC_BUILD_VERSION
    cmdsize 32
   platform 1
      minos 10.14
        sdk n/a
     ntools 1
       tool 3
    version 650.9
  ```
  vs this PR:
  ```bash
        cmd LC_BUILD_VERSION
    cmdsize 32
   platform 1
      minos 10.14
        sdk 11.3
     ntools 1
       tool 3
    version 650.9
  ```

  This, from what I understand, will fix the issue we are having with Qt deciding wether or not to enable features like "Dark mode" on macOS, see bitcoin#21771, however I have not tested that. Thus this is an alternative to bitcoin#21782.

  Our usage of `--sysroot` was added in bitcoin#17118.

  ```bash
  -isysroot <dir>         Set the system root directory (usually /)
  ```

ACKs for top commit:
  Sjors:
    tACK cf971c9
  hebasto:
    re-ACK cf971c9, only rebased and addressed comments since my [previous](bitcoin#21793 (review)) review.

Tree-SHA512: f01138179fb85083b5505bbaa48810451098ffa4da5d3c9b673785448790aa76f2e64b2aab6e698f6ee378a21f70626445a3fabee7c61dbfc44e96f3e3964656
@DrahtBot
Copy link
Contributor

DrahtBot commented May 4, 2021

Gitian builds

File commit 13f24d1
(master)
commit 21f6843
(master and this pull)
*-aarch64-linux-gnu-debug.tar.gz 2ae1d164869a2b1b... d5af25134e83242e...
*-aarch64-linux-gnu.tar.gz a88ff95f65f98d9a... c468e25bf44e2c1b...
*-arm-linux-gnueabihf-debug.tar.gz a5064041a36a4d6a... c5fae3b0c49d4111...
*-arm-linux-gnueabihf.tar.gz b7e2e194e4888f81... 5a6974747364fa0d...
*-osx-unsigned.dmg 554bd917c8c1f194... 14459cab24244cfa...
*-osx64.tar.gz 81c038d85238bcee... 576a5064d2d85522...
*-powerpc64-linux-gnu-debug.tar.gz c1ddccbadb3c407a... bfd60aebcfdaf9ef...
*-powerpc64-linux-gnu.tar.gz ec3d9de57d82293f... c240773578db4d43...
*-powerpc64le-linux-gnu-debug.tar.gz a288fdab7434581f... c6921805e9c8fd7b...
*-powerpc64le-linux-gnu.tar.gz 8e470ee15e20108f... 29a2c39643d1a9ce...
*-riscv64-linux-gnu-debug.tar.gz 564faccb866388e7... 5df0c320aca49add...
*-riscv64-linux-gnu.tar.gz 6a4efd483783486a... dfd6ed19902b3dde...
*-win64-debug.zip e1f8a015afa3d74d... 452248f82af41366...
*-win64-setup-unsigned.exe 225a8cf86123a054... 91d883f3299e6815...
*-win64.zip 9336468dd991303d... 0a3e1ad12f8a869d...
*-x86_64-linux-gnu-debug.tar.gz eb4abea6ee4328ce... 6e43982133599f5e...
*-x86_64-linux-gnu.tar.gz cffd18cbbdddb2c0... b8452d92766a19d5...
*.tar.gz 8a08cdc873a22249... 72a93eae0a7145d1...
bitcoin-core-linux-22-res.yml ac3298355af64e47... dcfa8114be2483a8...
bitcoin-core-osx-22-res.yml 82cf158d3424910b... a220ab06de00957b...
bitcoin-core-win-22-res.yml b9daa890a73d2f54... fec02b1a7bc34b49...
linux-build.log 5ce895ebc01e0a95... 44c785113babbfb2...
osx-build.log 232cb244fdb91c65... 38b78bcc1009ebfa...
win-build.log 0b3af0d4e3e8fb27... f4fe251cc0bb1033...
bitcoin-core-linux-22-res.yml.diff e2c40ed4a3d0abb0...
bitcoin-core-osx-22-res.yml.diff 7ccbb11414286382...
bitcoin-core-win-22-res.yml.diff e78f0a8cfe632226...
linux-build.log.diff 9242c3e0fcfd8f00...
osx-build.log.diff 0ada5b6473f1be6a...
win-build.log.diff 2b2f17e09e5d7524...

fanquake added a commit to fanquake/bitcoin that referenced this pull request May 5, 2021
Sanity checking that this info is present, and the version we expect is
worthwhile, as it can determine runtime behaviour. See bitcoin#21771 and bitcoin#21793.
@fanquake fanquake deleted the macos_use_isysroot branch May 6, 2021 12:44
kwvg added a commit to kwvg/dash that referenced this pull request Jul 20, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 20, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 20, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jul 20, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 1, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 24, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 24, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 24, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 24, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 25, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 25, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 26, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 26, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 26, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 27, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 30, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 1, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 1, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 2, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 3, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 3, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 3, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Sep 4, 2021
DeckerSU added a commit to DeckerSU/KomodoOcean that referenced this pull request Nov 16, 2021
TheComputerGenie pushed a commit to TheComputerGenie/KomodoOcean that referenced this pull request Jan 5, 2022
gades pushed a commit to cosanta/cosanta-core that referenced this pull request May 4, 2022
gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 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.

7 participants