depends: Set CMAKE_SYSTEM_VERSION for CMake builds #30465

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:240716-deps-cmake changing 7 files +16 −7
  1. hebasto commented at 10:20 pm on July 16, 2024: member

    From CMake docs:

    When the CMAKE_SYSTEM_NAME variable is set explicitly to enable cross compiling then the value of CMAKE_SYSTEM_VERSION must also be set explicitly to specify the target system version.

    This PR is split from #30454 and improves the current depends build subsystem.

  2. depends: Rename `cmake_system` -> `cmake_system_name` 3673fcf591
  3. depends: Add host-specific `cmake_system_version` variables 5ff8074361
  4. DrahtBot commented at 10:20 pm on July 16, 2024: contributor

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

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK pablomartin4btc, vasild
    Concept ACK theuni

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30712 (fuzz: Add missing fuzz targets to cmake build by maflcko)
    • #30685 (build: Mark x86_64-linux-gnu release binaries as CET-enabled by hebasto)
    • #30454 (build: Introduce CMake-based build system by hebasto)

    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.

  5. DrahtBot added the label Build system on Jul 16, 2024
  6. hebasto commented at 10:21 pm on July 16, 2024: member

    It is a part of upfront PR’ed commits from #30454, as suggested by @fanquake offline.

    cc @theuni @TheCharlatan @ryanofsky

  7. maflcko added the label DrahtBot Guix build requested on Jul 17, 2024
  8. hebasto commented at 7:42 am on July 17, 2024: member

    My Guix build:

     0x86_64
     1460732347ffc71500f84d1174f6a6011b887681e82fc1704c1187cb1701bf9af  guix-build-5ff8074361e9/output/aarch64-linux-gnu/SHA256SUMS.part
     2b084b5371e3acff1850c8f3234299f99c3635fd497919f28407acaee27322877  guix-build-5ff8074361e9/output/aarch64-linux-gnu/bitcoin-5ff8074361e9-aarch64-linux-gnu-debug.tar.gz
     39f0f40cb3510197338efca2c7423fb7615a34a8b21a90c500c7fa45898875a9d  guix-build-5ff8074361e9/output/aarch64-linux-gnu/bitcoin-5ff8074361e9-aarch64-linux-gnu.tar.gz
     4b571a25f1cf2c5f282342667823cdb5ed632e4b549361a46853414987091b1ce  guix-build-5ff8074361e9/output/arm-linux-gnueabihf/SHA256SUMS.part
     5758328c887a3b1233ff96c6ca867ad1e05cfbde376b17197ef69318307e19b9f  guix-build-5ff8074361e9/output/arm-linux-gnueabihf/bitcoin-5ff8074361e9-arm-linux-gnueabihf-debug.tar.gz
     66628127da8fa423f23af5171f2e03b9afce5f579a08c4416de0cc8302fe841b6  guix-build-5ff8074361e9/output/arm-linux-gnueabihf/bitcoin-5ff8074361e9-arm-linux-gnueabihf.tar.gz
     7ead35c171f2b8a00d7755a8a18811ef3ee0567952b42c8a0de0a5647cd566a34  guix-build-5ff8074361e9/output/arm64-apple-darwin/SHA256SUMS.part
     8b872260bf88b6affc5c53fd0d0fa1aac7edb458902358cf64a6117dd0ecc29e0  guix-build-5ff8074361e9/output/arm64-apple-darwin/bitcoin-5ff8074361e9-arm64-apple-darwin-unsigned.tar.gz
     9443ff94fa3129b7e54ed58291d06fa708e812aa3b07937f9b8b9bcac9d93538c  guix-build-5ff8074361e9/output/arm64-apple-darwin/bitcoin-5ff8074361e9-arm64-apple-darwin-unsigned.zip
    100c84027d40ee433eaf064f5198a6eaf01ade9cd5c75cc6534c8dc1ecedb89bd1  guix-build-5ff8074361e9/output/arm64-apple-darwin/bitcoin-5ff8074361e9-arm64-apple-darwin.tar.gz
    119853a449e72c2e2b641b9f976d50b2d72a4a07876c25ba75812667a37366014a  guix-build-5ff8074361e9/output/dist-archive/bitcoin-5ff8074361e9.tar.gz
    12aee54f6d0e991040a02bd81d98d6034be922492dacd8275e6857a350be1628a1  guix-build-5ff8074361e9/output/powerpc64-linux-gnu/SHA256SUMS.part
    139a9de9a7cd9fdd78552f59ffd812831e508b9c9a98125c8117168ad620f54eb5  guix-build-5ff8074361e9/output/powerpc64-linux-gnu/bitcoin-5ff8074361e9-powerpc64-linux-gnu-debug.tar.gz
    144ce3ba8f2684bdf3c0821448f79b30bdc7cd6f30b6d403eb1a156b3cbaab8f88  guix-build-5ff8074361e9/output/powerpc64-linux-gnu/bitcoin-5ff8074361e9-powerpc64-linux-gnu.tar.gz
    157feb0a0f3a830929dca504284478d0ab77cde22312fc695bdd4052a093084104  guix-build-5ff8074361e9/output/riscv64-linux-gnu/SHA256SUMS.part
    16f62b2b2d9a407bcef69a714fad8141f360da3edf05a431017f88157b2da4b916  guix-build-5ff8074361e9/output/riscv64-linux-gnu/bitcoin-5ff8074361e9-riscv64-linux-gnu-debug.tar.gz
    17385007a5fa879d508e3802c2034920125ec292c8f2385cc9c76eba0081fe5426  guix-build-5ff8074361e9/output/riscv64-linux-gnu/bitcoin-5ff8074361e9-riscv64-linux-gnu.tar.gz
    182d03dd96e90c66c4ae9f75bf799da63132df7738bdac8f1c5b32cc2627d9344a  guix-build-5ff8074361e9/output/x86_64-apple-darwin/SHA256SUMS.part
    196970c1003c5a635155dc2385169e4ac099a188cf448f55abaa82b94c8eaf961b  guix-build-5ff8074361e9/output/x86_64-apple-darwin/bitcoin-5ff8074361e9-x86_64-apple-darwin-unsigned.tar.gz
    20528a2da62a4312663de96166b82c37d361767eacc4c6e492d07282373110d2f1  guix-build-5ff8074361e9/output/x86_64-apple-darwin/bitcoin-5ff8074361e9-x86_64-apple-darwin-unsigned.zip
    211ec8dc814de841757fdc45eb028d9df13f1b6f8e05f01642d76539920e16b400  guix-build-5ff8074361e9/output/x86_64-apple-darwin/bitcoin-5ff8074361e9-x86_64-apple-darwin.tar.gz
    223691ba37e116c794860e7693c8b0f81e171319cc1e15f8cfc37a8336f1631dc1  guix-build-5ff8074361e9/output/x86_64-linux-gnu/SHA256SUMS.part
    23e0811eb91bfe9661e9dd7fb5fb2848729b7295db5237a9cff39e4fc2add46bf2  guix-build-5ff8074361e9/output/x86_64-linux-gnu/bitcoin-5ff8074361e9-x86_64-linux-gnu-debug.tar.gz
    24d9c2e29dd11f700b7ea1477e3c7564baf613ebdc5aa97e7ea6530d5115d5e95b  guix-build-5ff8074361e9/output/x86_64-linux-gnu/bitcoin-5ff8074361e9-x86_64-linux-gnu.tar.gz
    251e0a09cd5edaf1c1613c75fc978170b5166a2e6a2009bec48591f85626a7b908  guix-build-5ff8074361e9/output/x86_64-w64-mingw32/SHA256SUMS.part
    260c2dbb9553e81f0e30778be60e7b17b4727ded5518161e90b539ba5069052474  guix-build-5ff8074361e9/output/x86_64-w64-mingw32/bitcoin-5ff8074361e9-win64-debug.zip
    27f255226d5ecd3cfccfaa2b1f2c2ec98da015e47ddb08ef15339d6ea3fb9eb8ab  guix-build-5ff8074361e9/output/x86_64-w64-mingw32/bitcoin-5ff8074361e9-win64-setup-unsigned.exe
    28755903863b08594bba9ac52bb2a7e2e87ee077d0e8f777e7d9e768147fa9ce03  guix-build-5ff8074361e9/output/x86_64-w64-mingw32/bitcoin-5ff8074361e9-win64-unsigned.tar.gz
    29aa3cceab8c14f99d278ee628193ca9b3ff51343a658dcbc7dd141ebeac8e2ae3  guix-build-5ff8074361e9/output/x86_64-w64-mingw32/bitcoin-5ff8074361e9-win64.zip
    
  9. fanquake commented at 9:21 am on July 17, 2024: member
    What change in behaviour should be expected here?
  10. hebasto commented at 10:19 am on July 17, 2024: member

    What change in behaviour should be expected here?

    For example, when building for macOS, the CMAKE_SYSTEM_VERSION value is used to define DARWIN_MAJOR_VERSION and DARWIN_MINOR_VERSION, which in turn affect the default build options.

  11. in depends/hosts/darwin.mk:87 in 5ff8074361
    81@@ -82,3 +82,6 @@ darwin_debug_CFLAGS=-O1 -g
    82 darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS)
    83 
    84 darwin_cmake_system_name=Darwin
    85+# Darwin version, which corresponds to OSX_MIN_VERSION.
    86+# See https://en.wikipedia.org/wiki/Darwin_(operating_system)
    87+darwin_cmake_system_version=20.1
    


    theuni commented at 1:33 pm on July 17, 2024:
    Where/how does CMake translate this to OSX_MIN_VERSION? Ideally we’d compose these somehow.

    hebasto commented at 2:19 pm on July 17, 2024:

    Where/how does CMake translate this to OSX_MIN_VERSION?

    #30465 (comment):

    … the CMAKE_SYSTEM_VERSION value is used to define DARWIN_MAJOR_VERSION and DARWIN_MINOR_VERSION

    It happens here:

    0# Darwin versions:
    1#   6.x == Mac OSX 10.2 (Jaguar)
    2#   7.x == Mac OSX 10.3 (Panther)
    3#   8.x == Mac OSX 10.4 (Tiger)
    4#   9.x == Mac OSX 10.5 (Leopard)
    5#  10.x == Mac OSX 10.6 (Snow Leopard)
    6#  11.x == Mac OSX 10.7 (Lion)
    7#  12.x == Mac OSX 10.8 (Mountain Lion)
    8string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_SYSTEM_VERSION}")
    9string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\2" DARWIN_MINOR_VERSION "${CMAKE_SYSTEM_VERSION}")
    

    The chosen Darwin version 20.1 is associated with macOS 11.0: https://github.com/bitcoin/bitcoin/blob/37992244e636e52e0c2baff1bc5f36e60d9c956f/depends/hosts/darwin.mk#L1

  12. theuni commented at 1:40 pm on July 17, 2024: member

    Concept ACK, but we need more docs here.

    • I can’t tell (even from looking at the CMake docs) what macOS should be set to and why you’ve chosen this value
    • I can only assume that the Linux value means “minimum kernel version” for the sake of kernel headers, but I don’t see that in the docs either
    • Agree with @fanquake that it’s not clear how this affects our other version vars. Which take precedence?
  13. DrahtBot commented at 1:58 pm on July 17, 2024: contributor

    Guix builds (on x86_64) [untrusted test-only build, possibly unsafe, not for production use]

    File commit 6f9db1ebcab4064065ccd787161bf2b87e03cc1f(master) commit 73d4f33b70e9198d799118dec6bd1ce81967266f(master and this pull)
    SHA256SUMS.part 0d8cdb8c3167d4ff... 8e4a4b356e59fda3...
    *-aarch64-linux-gnu-debug.tar.gz 40810c3e1935a80b... ba8611bde5454684...
    *-aarch64-linux-gnu.tar.gz a4fe14ae14ad890b... 6866758249529fea...
    *-arm-linux-gnueabihf-debug.tar.gz 321a865df293fb6a... 998fe87ec8278b25...
    *-arm-linux-gnueabihf.tar.gz 97b9853189f57dc2... bdc7603d6c6db965...
    *-arm64-apple-darwin-unsigned.tar.gz c3634e5d58dab037... 1888316c7e9c716e...
    *-arm64-apple-darwin-unsigned.zip 45eb299b483de565... 3a43b515e5cf1f19...
    *-arm64-apple-darwin.tar.gz 58c4513ff47d194f... e007a93066e02255...
    *-powerpc64-linux-gnu-debug.tar.gz d954d21fce228c04... 0a443c861ae1db42...
    *-powerpc64-linux-gnu.tar.gz b19e53cd361b804c... b4af9cfcd2bcf8c3...
    *-riscv64-linux-gnu-debug.tar.gz fb68432434179030... 4e58a7b9045e096f...
    *-riscv64-linux-gnu.tar.gz dc48cf50146c184a... 3c96a620bc40928e...
    *-x86_64-apple-darwin-unsigned.tar.gz 229550ad3bebb1f5... 9751e1979e674ca6...
    *-x86_64-apple-darwin-unsigned.zip 6078c435cbadd475... 128caa3bdbf7c4fc...
    *-x86_64-apple-darwin.tar.gz e312cbdc559398da... a8fb27b7f5b39502...
    *-x86_64-linux-gnu-debug.tar.gz d2089a6f223c00a4... f995f09f6e4eb194...
    *-x86_64-linux-gnu.tar.gz 61af1710cb2143b9... c0dee5036e29693c...
    *.tar.gz 131b6f2f5a3d17f2... e5c993c39d9a42fe...
    guix_build.log 4f000735ce4f4184... 5fa6ddfb579b91ea...
    guix_build.log.diff c96729dea80f71b2...
  14. DrahtBot removed the label DrahtBot Guix build requested on Jul 17, 2024
  15. hebasto commented at 2:30 pm on July 17, 2024: member

    Concept ACK, but we need more docs here.

    • I can’t tell (even from looking at the CMake docs) what macOS should be set to and why you’ve chosen this value

    • I can only assume that the Linux value means “minimum kernel version” for the sake of kernel headers, but I don’t see that in the docs either

    • Agree with @fanquake that it’s not clear how this affects our other version vars. Which take precedence?

    I agree that the documentation is not comprehensive.

    As for CMAKE_SYSTEM_VERSION value for Linux, I rely on the fact that its value is picked from uname output for native builds:

     0$ cat CMakeLists.txt 
     1cmake_minimum_required(VERSION 3.22)
     2project(test LANGUAGES NONE)
     3message("${CMAKE_SYSTEM_VERSION}")
     4$ cmake -B build
     56.8.0-38-generic
     6-- Configuring done (0.0s)
     7-- Generating done (0.0s)
     8...
     9$ uname -r
    106.8.0-38-generic
    

    However, I assume that the CMAKE_SYSTEM_VERSION is not used by the current CMake implementation for Linux builds.

  16. hebasto commented at 2:41 pm on July 17, 2024: member

    Here is the previous discussion on this topic: https://github.com/hebasto/bitcoin/pull/3#discussion_r892222352.

    In particular, @ryanofsky noted:

    I think this doc is overgeneralizing. If you look at https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html you can see this variable only has meaning when cross compiling for windows and android

  17. fanquake commented at 2:44 pm on July 17, 2024: member

    you can see this variable only has meaning when cross compiling for windows and android

    Given, for example, that if you cross-compile for macOS, with this PR, you end up with different linker flags, this clearly has effect outside of Windows and Android.

  18. hebasto commented at 2:42 pm on July 26, 2024: member

    Here is an opinion of a CMake maintainer from Professional CMake: A Practical Guide 18th Edition:

    The CMAKE_SYSTEM_VERSION variable has different meanings depending on what CMAKE_SYSTEM_NAME is set to. … if CMAKE_SYSTEM_NAME is set to Android, then CMAKE_SYSTEM_VERSION will typically be interpreted as the default Android API version and must be a positive integer. For other system names, it is not unusual to see CMAKE_SYSTEM_VERSION set to something arbitrary like 1, or to not be set at all. … CMAKE_SYSTEM_PROCESSOR and CMAKE_SYSTEM_VERSION are not particularly meaningful for Apple platforms and usually remain unset.

  19. pablomartin4btc approved
  20. pablomartin4btc commented at 3:11 pm on August 2, 2024: member

    ACK 5ff8074361e9698d6e12e817784295a400b99dab

    As a reference, this was tested in hebasto/bitcoin/pull/125 (not triggering cross-compiling unnecessarily) and macOS cross build CI (hebasto/bitcoin/pull/94) is running with it since.

  21. DrahtBot requested review from theuni on Aug 2, 2024
  22. vasild approved
  23. vasild commented at 3:35 pm on August 13, 2024: contributor

    ACK 5ff8074361 the changes look ok.

    I just wonder, why the change to depends/funcs.mk is not in hebasto/cmake-staging, but is in this PR?

  24. hebasto commented at 10:23 am on August 14, 2024: member

    I just wonder, why the change to depends/funcs.mk is not in hebasto/cmake-staging, but is in this PR?

    All changes to depends/funcs.mk from this PR must be ported to hebasto/cmake-staging.

  25. DrahtBot added the label Needs rebase on Aug 28, 2024
  26. DrahtBot commented at 9:59 am on August 28, 2024: contributor

    🐙 This pull request conflicts with the target branch and needs rebase.

  27. hebasto closed this on Aug 28, 2024

  28. fanquake commented at 10:53 am on August 28, 2024: member

    Concept ACK, but we need more docs here. I can’t tell (even from looking at the CMake docs) what macOS should be set to and why you’ve chosen this value I can only assume that the Linux value means “minimum kernel version” for the sake of kernel headers, but I don’t see that in the docs either Agree with @fanquake that it’s not clear how this affects our other version vars. Which take precedence?

    Where did this get followed up on?


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-09-08 01:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me