build: Fix ccache behavior when cross-compiling for darwin hosts #24620

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:220320-ccache changing 4 files +30 −10
  1. hebasto commented at 12:08 pm on March 20, 2022: member

    For darwin hosts we use the env command to run a compiler in a modified environment which in turn makes ccache effectively no-op. On master (ae005a647ffa1d457c5c7a0528cb29f3b1937b96):

     0$ cat /etc/os-release | grep VERSION=
     1VERSION="22.04 (Jammy Jellyfish)"
     2$ ccache --version | head -1
     3ccache version 4.5.1
     4$ make -C depends HOST=x86_64-apple-darwin
     5$ ./autogen.sh
     6$ CONFIG_SITE=$PWD/depends/x86_64-apple-darwin/share/config.site ./configure 
     7$ make clean
     8$ ccache --zero-stats
     9$ make
    10$ ccache --show-stats -v
    11Summary:
    12  Cache directory:       /home/hebasto/.cache/ccache
    13  Primary config:        /home/hebasto/.config/ccache/ccache.conf
    14  Secondary config:      /etc/ccache.conf
    15  Stats updated:         Sun Mar 20 12:33:01 2022
    16  Hits:                      0 /    0
    17    Direct:                  0 /    0
    18    Preprocessed:            0 /    0
    19  Misses:                    0
    20    Direct:                  0
    21    Preprocessed:            0
    22  Uncacheable:             734
    23Primary storage:
    24  Hits:                      0 /    0
    25  Misses:                    0
    26  Cache size (GB):        1.69 / 5.00 (33.87 %)
    27  Files:                 11790
    28Uncacheable:
    29  Called for linking:       14
    30  Multiple source files:   720
    

    With this PR:

     0$ make -C depends HOST=x86_64-apple-darwin
     1$ ./autogen.sh
     2$ CONFIG_SITE=$PWD/depends/x86_64-apple-darwin/share/config.site ./configure 
     3$ make clean
     4$ make
     5$ make clean
     6$ ccache --zero-stats
     7$ make
     8$ ccache --show-stats 
     9Summary:
    10  Hits:             720 /  720 (100.0 %)
    11    Direct:         720 /  720 (100.0 %)
    12    Preprocessed:     0 /    0
    13  Misses:             0
    14    Direct:           0
    15    Preprocessed:     0
    16  Uncacheable:       14
    17Primary storage:
    18  Hits:            1440 / 1440 (100.0 %)
    19  Misses:             0
    20  Cache size (GB): 1.74 / 5.00 (34.80 %)
    21
    22Use the -v/--verbose option for more details.
    

    Fixes bitcoin/bitcoin#21552.


    Also this PR improves efficiency of the “macOS 10.15” CI task:

  2. hebasto marked this as a draft on Mar 20, 2022
  3. DrahtBot added the label Build system on Mar 20, 2022
  4. hebasto marked this as ready for review on Mar 20, 2022
  5. prusnak commented at 1:25 pm on March 20, 2022: contributor
    Concept ACK
  6. jonatack commented at 12:26 pm on March 21, 2022: contributor
    Concept ACK
  7. fanquake commented at 10:13 am on March 22, 2022: member
    ~0. I’m not convinced this change is a good way to fix this problem. Wont this also mean that the compiler invocation we use to build darwin packages in depends is now different from the one we use to build bitcoind?
  8. fanquake commented at 10:56 am on March 22, 2022: member

    This change also does not Guix build:

     0HOSTS="x86_64-apple-darwin" ./contrib/guix/guix-build
     1...
     2Building libevent...
     3make[1]: Entering directory '/bitcoin/depends/work/build/x86_64-apple-darwin/libevent/2.1.12-stable-a581391610c'
     4  GEN      include/event2/event-config.h
     5make  all-am
     6make[2]: Entering directory '/bitcoin/depends/work/build/x86_64-apple-darwin/libevent/2.1.12-stable-a581391610c'
     7  CC       buffer.lo
     8  CC       bufferevent.lo
     9  CC       bufferevent_filter.lo
    10  CC       bufferevent_pair.lo
    11  CC       bufferevent_ratelim.lo
    12  CC       bufferevent_sock.lo
    13  CC       evmap.lo
    14  CC       event.lo
    15buffer.c:2487:60: error: too many arguments to function call, expected 4, have 6
    16        res = sendfile(source_fd, dest_fd, chain->misalign, &len, NULL, 0);
    17              ~~~~~~~~                                            ^~~~~~~
    18/gnu/store/v770rvqs8q21mbzwb3gkihr2glgn80am-clang-10.0.1/lib/clang/10.0.1/include/stddef.h:89:16: note: expanded from macro 'NULL'
    19#  define NULL ((void*)0)
    20               ^
    21/gnu/store/bxh206gz379wkn8cvb2ghlkvpqgwfd2v-gcc-toolchain-10.3.0/include/sys/sendfile.h:33:1: note: 'sendfile' declared here
    22extern ssize_t sendfile (int __out_fd, int __in_fd, off_t *__offset,
    23^
    241 error generated.
    25  CC       evthread.lo
    26make[2]: *** [Makefile:1866: buffer.lo] Error 1
    27make[2]: *** Waiting for unfinished jobs....
    28make[2]: Leaving directory '/bitcoin/depends/work/build/x86_64-apple-darwin/libevent/2.1.12-stable-a581391610c'
    29make[1]: *** [Makefile:1385: all] Error 2
    30make[1]: Leaving directory '/bitcoin/depends/work/build/x86_64-apple-darwin/libevent/2.1.12-stable-a581391610c'
    31make: *** [funcs.mk:282: /bitcoin/depends/work/build/x86_64-apple-darwin/libevent/2.1.12-stable-a581391610c/./.stamp_built] Error 2
    32make: Leaving directory '/bitcoin/depends'
    
  9. hebasto marked this as a draft on Mar 27, 2022
  10. build: Fix ccache behavior when cross-compiling for darwin hosts 6f4ff381c2
  11. hebasto force-pushed on Mar 28, 2022
  12. hebasto marked this as ready for review on Mar 28, 2022
  13. hebasto commented at 4:02 pm on March 28, 2022: member

    Wont this also mean that the compiler invocation we use to build darwin packages in depends is now different from the one we use to build bitcoind?

    Fixed.

    Guix builds:

     0$ find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
     1f8c0f480ba70b4ba6aac4a93d76f0281043ba8a37ca3b9b116ec3aea6e7851ca  guix-build-6f4ff381c2f9/output/aarch64-linux-gnu/SHA256SUMS.part
     284fc763a787f7116a00d0e1115705142caaea9868e51487f088519bb20ac84cd  guix-build-6f4ff381c2f9/output/aarch64-linux-gnu/bitcoin-6f4ff381c2f9-aarch64-linux-gnu-debug.tar.gz
     3d6f6b6565cc29203aa404861aea6a5bd8e2998d0ae9bb16f65e58c299d06f3ff  guix-build-6f4ff381c2f9/output/aarch64-linux-gnu/bitcoin-6f4ff381c2f9-aarch64-linux-gnu.tar.gz
     41103780ab5798c7319b7ae04e47958d3280ab43970e2a0f561415b3943e302d3  guix-build-6f4ff381c2f9/output/arm-linux-gnueabihf/SHA256SUMS.part
     5793adbaf01daa878e54aee0fec2057121295a66bd17567175a69b7c3eefdcd7c  guix-build-6f4ff381c2f9/output/arm-linux-gnueabihf/bitcoin-6f4ff381c2f9-arm-linux-gnueabihf-debug.tar.gz
     686f3e3fd8ee7e6b27def40cf1252cec271fbb558d1e9518aeb60916b0f3f4202  guix-build-6f4ff381c2f9/output/arm-linux-gnueabihf/bitcoin-6f4ff381c2f9-arm-linux-gnueabihf.tar.gz
     7e9ba180d604c5463dce085a60dc92e5c49cb83b194d7f727548a9e4bef3819e2  guix-build-6f4ff381c2f9/output/arm64-apple-darwin/SHA256SUMS.part
     8774d7bc88abeaf3455bd44c664666965022c49ad0c6fde197f6409eb1889dcca  guix-build-6f4ff381c2f9/output/arm64-apple-darwin/bitcoin-6f4ff381c2f9-arm64-apple-darwin-unsigned.dmg
     9a3c7bfc99fee0c8483e44dd02faf3aaeb14f4b886858d4b3be166ad3750d9b70  guix-build-6f4ff381c2f9/output/arm64-apple-darwin/bitcoin-6f4ff381c2f9-arm64-apple-darwin-unsigned.tar.gz
    1053c2d83e258302740f47c9f83a00bfe995c785dad5b10679162a2da6fe0206c5  guix-build-6f4ff381c2f9/output/arm64-apple-darwin/bitcoin-6f4ff381c2f9-arm64-apple-darwin.tar.gz
    1105c4b27315846e994f94a359862c9b5ac6c4113e1404cb6020142b40d2d25d32  guix-build-6f4ff381c2f9/output/dist-archive/bitcoin-6f4ff381c2f9.tar.gz
    12b6414b295482c705d113c6707e6ceca1c1664d20f271a2b8d391ad3c0d783ee5  guix-build-6f4ff381c2f9/output/powerpc64-linux-gnu/SHA256SUMS.part
    1337300b4c9d2dc9ae751fed8bdaa482607db2225a9e21e8301a5b3be6194fb57d  guix-build-6f4ff381c2f9/output/powerpc64-linux-gnu/bitcoin-6f4ff381c2f9-powerpc64-linux-gnu-debug.tar.gz
    14c334c66631138bb2ebae8f862131de013c2a30ba81dafab5a1abde68a98321c0  guix-build-6f4ff381c2f9/output/powerpc64-linux-gnu/bitcoin-6f4ff381c2f9-powerpc64-linux-gnu.tar.gz
    153a68731fafa61d64a40a4744a739620b9a99d3a793847bb6f5ab4e8871d7f6ac  guix-build-6f4ff381c2f9/output/powerpc64le-linux-gnu/SHA256SUMS.part
    166476a34cb4ab3cd99cedab8b377363592d3d116f3f8ae518a7b9768dc245131b  guix-build-6f4ff381c2f9/output/powerpc64le-linux-gnu/bitcoin-6f4ff381c2f9-powerpc64le-linux-gnu-debug.tar.gz
    170ad92d09521f558a4d804e6d4f736f5201e2f8f429e6f291b0a9fa56601dfe27  guix-build-6f4ff381c2f9/output/powerpc64le-linux-gnu/bitcoin-6f4ff381c2f9-powerpc64le-linux-gnu.tar.gz
    18d374f271f8eee3c3c03522ac1397ab9c13976a93efd24fbb1f9dcf4d4a9e9939  guix-build-6f4ff381c2f9/output/riscv64-linux-gnu/SHA256SUMS.part
    1992141d5c096fd057a9414709002025390003ab3573abb7c4b137743ae9fa1f60  guix-build-6f4ff381c2f9/output/riscv64-linux-gnu/bitcoin-6f4ff381c2f9-riscv64-linux-gnu-debug.tar.gz
    20b49f0423aa330e8eec01b2d8ed36dc7a444e91c38b67f072931f9ad1f6de6160  guix-build-6f4ff381c2f9/output/riscv64-linux-gnu/bitcoin-6f4ff381c2f9-riscv64-linux-gnu.tar.gz
    21990cafb070b25951ed0d2ad9edffb6b92022ed918fb9903a6fe65b9ab7364e82  guix-build-6f4ff381c2f9/output/x86_64-apple-darwin/SHA256SUMS.part
    22ddc3d209f9e27f6ece333618d433c4a670a252e069fc6b17259348b72eedc494  guix-build-6f4ff381c2f9/output/x86_64-apple-darwin/bitcoin-6f4ff381c2f9-x86_64-apple-darwin-unsigned.dmg
    23d736d7246360523a70d982916700122f6766251f045549b34272937f35b8e355  guix-build-6f4ff381c2f9/output/x86_64-apple-darwin/bitcoin-6f4ff381c2f9-x86_64-apple-darwin-unsigned.tar.gz
    24df786b1d05b74edf342513685d0b0d148d0f3bc51ee0bd3835cecffe0a9ce671  guix-build-6f4ff381c2f9/output/x86_64-apple-darwin/bitcoin-6f4ff381c2f9-x86_64-apple-darwin.tar.gz
    254a3967f7c4381cb299833bf63e4d869c1b033d63997df6064c18e9da79e44ba8  guix-build-6f4ff381c2f9/output/x86_64-linux-gnu/SHA256SUMS.part
    26f272fcacbd564016376bc932df4cc5264ce2ddd47335fd22e07611675110ff14  guix-build-6f4ff381c2f9/output/x86_64-linux-gnu/bitcoin-6f4ff381c2f9-x86_64-linux-gnu-debug.tar.gz
    27c7995ffd6072b65b0c69ab5bc344f4a1324e0d2307e4bf4551fb6d72913157c6  guix-build-6f4ff381c2f9/output/x86_64-linux-gnu/bitcoin-6f4ff381c2f9-x86_64-linux-gnu.tar.gz
    280059851989d59d2f068d5c93710b5228866314d87ea7a9f8f4f198b4916abb08  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/SHA256SUMS.part
    29a33f19278ce0476dc6db48bdd0ccfff292d20b7ed32e103758834049f4de0633  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/bitcoin-6f4ff381c2f9-win64-debug.zip
    30e9c00c22e65f0d9a2962d1540ff4e877bb02e72ef65131c19992782a29c01da1  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/bitcoin-6f4ff381c2f9-win64-setup-unsigned.exe
    3179601aec47d44960cd116fbcbb04c1eaaaa9dcb431f14bc23be8c5afb7e3d633  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/bitcoin-6f4ff381c2f9-win64-unsigned.tar.gz
    322fbc90d9921f1a9525f44bee9716955d1092b52d703287c8786e3b5c566be6d8  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/bitcoin-6f4ff381c2f9-win64.zip
    
  14. hebasto commented at 4:04 pm on March 28, 2022: member
    Friendly ping @dongcarl.
  15. DrahtBot commented at 5:36 am on March 31, 2022: contributor

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

    Conflicts

    No conflicts as of last run.

  16. jarolrod commented at 0:13 am on April 7, 2022: member

    guix hashes (x86), mine match @hebasto

     0find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
     1
     2f8c0f480ba70b4ba6aac4a93d76f0281043ba8a37ca3b9b116ec3aea6e7851ca  guix-build-6f4ff381c2f9/output/aarch64-linux-gnu/SHA256SUMS.part
     384fc763a787f7116a00d0e1115705142caaea9868e51487f088519bb20ac84cd  guix-build-6f4ff381c2f9/output/aarch64-linux-gnu/bitcoin-6f4ff381c2f9-aarch64-linux-gnu-debug.tar.gz
     4d6f6b6565cc29203aa404861aea6a5bd8e2998d0ae9bb16f65e58c299d06f3ff  guix-build-6f4ff381c2f9/output/aarch64-linux-gnu/bitcoin-6f4ff381c2f9-aarch64-linux-gnu.tar.gz
     51103780ab5798c7319b7ae04e47958d3280ab43970e2a0f561415b3943e302d3  guix-build-6f4ff381c2f9/output/arm-linux-gnueabihf/SHA256SUMS.part
     6793adbaf01daa878e54aee0fec2057121295a66bd17567175a69b7c3eefdcd7c  guix-build-6f4ff381c2f9/output/arm-linux-gnueabihf/bitcoin-6f4ff381c2f9-arm-linux-gnueabihf-debug.tar.gz
     786f3e3fd8ee7e6b27def40cf1252cec271fbb558d1e9518aeb60916b0f3f4202  guix-build-6f4ff381c2f9/output/arm-linux-gnueabihf/bitcoin-6f4ff381c2f9-arm-linux-gnueabihf.tar.gz
     8e9ba180d604c5463dce085a60dc92e5c49cb83b194d7f727548a9e4bef3819e2  guix-build-6f4ff381c2f9/output/arm64-apple-darwin/SHA256SUMS.part
     9774d7bc88abeaf3455bd44c664666965022c49ad0c6fde197f6409eb1889dcca  guix-build-6f4ff381c2f9/output/arm64-apple-darwin/bitcoin-6f4ff381c2f9-arm64-apple-darwin-unsigned.dmg
    10a3c7bfc99fee0c8483e44dd02faf3aaeb14f4b886858d4b3be166ad3750d9b70  guix-build-6f4ff381c2f9/output/arm64-apple-darwin/bitcoin-6f4ff381c2f9-arm64-apple-darwin-unsigned.tar.gz
    1153c2d83e258302740f47c9f83a00bfe995c785dad5b10679162a2da6fe0206c5  guix-build-6f4ff381c2f9/output/arm64-apple-darwin/bitcoin-6f4ff381c2f9-arm64-apple-darwin.tar.gz
    1205c4b27315846e994f94a359862c9b5ac6c4113e1404cb6020142b40d2d25d32  guix-build-6f4ff381c2f9/output/dist-archive/bitcoin-6f4ff381c2f9.tar.gz
    13b6414b295482c705d113c6707e6ceca1c1664d20f271a2b8d391ad3c0d783ee5  guix-build-6f4ff381c2f9/output/powerpc64-linux-gnu/SHA256SUMS.part
    1437300b4c9d2dc9ae751fed8bdaa482607db2225a9e21e8301a5b3be6194fb57d  guix-build-6f4ff381c2f9/output/powerpc64-linux-gnu/bitcoin-6f4ff381c2f9-powerpc64-linux-gnu-debug.tar.gz
    15c334c66631138bb2ebae8f862131de013c2a30ba81dafab5a1abde68a98321c0  guix-build-6f4ff381c2f9/output/powerpc64-linux-gnu/bitcoin-6f4ff381c2f9-powerpc64-linux-gnu.tar.gz
    163a68731fafa61d64a40a4744a739620b9a99d3a793847bb6f5ab4e8871d7f6ac  guix-build-6f4ff381c2f9/output/powerpc64le-linux-gnu/SHA256SUMS.part
    176476a34cb4ab3cd99cedab8b377363592d3d116f3f8ae518a7b9768dc245131b  guix-build-6f4ff381c2f9/output/powerpc64le-linux-gnu/bitcoin-6f4ff381c2f9-powerpc64le-linux-gnu-debug.tar.gz
    180ad92d09521f558a4d804e6d4f736f5201e2f8f429e6f291b0a9fa56601dfe27  guix-build-6f4ff381c2f9/output/powerpc64le-linux-gnu/bitcoin-6f4ff381c2f9-powerpc64le-linux-gnu.tar.gz
    19d374f271f8eee3c3c03522ac1397ab9c13976a93efd24fbb1f9dcf4d4a9e9939  guix-build-6f4ff381c2f9/output/riscv64-linux-gnu/SHA256SUMS.part
    2092141d5c096fd057a9414709002025390003ab3573abb7c4b137743ae9fa1f60  guix-build-6f4ff381c2f9/output/riscv64-linux-gnu/bitcoin-6f4ff381c2f9-riscv64-linux-gnu-debug.tar.gz
    21b49f0423aa330e8eec01b2d8ed36dc7a444e91c38b67f072931f9ad1f6de6160  guix-build-6f4ff381c2f9/output/riscv64-linux-gnu/bitcoin-6f4ff381c2f9-riscv64-linux-gnu.tar.gz
    22990cafb070b25951ed0d2ad9edffb6b92022ed918fb9903a6fe65b9ab7364e82  guix-build-6f4ff381c2f9/output/x86_64-apple-darwin/SHA256SUMS.part
    23ddc3d209f9e27f6ece333618d433c4a670a252e069fc6b17259348b72eedc494  guix-build-6f4ff381c2f9/output/x86_64-apple-darwin/bitcoin-6f4ff381c2f9-x86_64-apple-darwin-unsigned.dmg
    24d736d7246360523a70d982916700122f6766251f045549b34272937f35b8e355  guix-build-6f4ff381c2f9/output/x86_64-apple-darwin/bitcoin-6f4ff381c2f9-x86_64-apple-darwin-unsigned.tar.gz
    25df786b1d05b74edf342513685d0b0d148d0f3bc51ee0bd3835cecffe0a9ce671  guix-build-6f4ff381c2f9/output/x86_64-apple-darwin/bitcoin-6f4ff381c2f9-x86_64-apple-darwin.tar.gz
    264a3967f7c4381cb299833bf63e4d869c1b033d63997df6064c18e9da79e44ba8  guix-build-6f4ff381c2f9/output/x86_64-linux-gnu/SHA256SUMS.part
    27f272fcacbd564016376bc932df4cc5264ce2ddd47335fd22e07611675110ff14  guix-build-6f4ff381c2f9/output/x86_64-linux-gnu/bitcoin-6f4ff381c2f9-x86_64-linux-gnu-debug.tar.gz
    28c7995ffd6072b65b0c69ab5bc344f4a1324e0d2307e4bf4551fb6d72913157c6  guix-build-6f4ff381c2f9/output/x86_64-linux-gnu/bitcoin-6f4ff381c2f9-x86_64-linux-gnu.tar.gz
    290059851989d59d2f068d5c93710b5228866314d87ea7a9f8f4f198b4916abb08  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/SHA256SUMS.part
    30a33f19278ce0476dc6db48bdd0ccfff292d20b7ed32e103758834049f4de0633  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/bitcoin-6f4ff381c2f9-win64-debug.zip
    31e9c00c22e65f0d9a2962d1540ff4e877bb02e72ef65131c19992782a29c01da1  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/bitcoin-6f4ff381c2f9-win64-setup-unsigned.exe
    3279601aec47d44960cd116fbcbb04c1eaaaa9dcb431f14bc23be8c5afb7e3d633  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/bitcoin-6f4ff381c2f9-win64-unsigned.tar.gz
    332fbc90d9921f1a9525f44bee9716955d1092b52d703287c8786e3b5c566be6d8  guix-build-6f4ff381c2f9/output/x86_64-w64-mingw32/bitcoin-6f4ff381c2f9-win64.zip
    
  17. fanquake commented at 10:42 am on April 17, 2022: member
    ~0. I’m still not convinced this is a good change, or even something that needs to be solved at the cost of introducing more platform specific hacks / complication into our build system. It’s surprising that there is no way for us to fix this for our use case given the multitude of ccache configuration options / settings, and it’s support for additional compiler wrappers. Have we opened an issue upstream to document our use case, and why ccache doesn’t currently work with it?
  18. hebasto closed this on Apr 17, 2022

  19. bitcoin locked this on Apr 17, 2023
  20. hebasto commented at 8:51 am on August 16, 2023: member

    ~0. I’m still not convinced this is a good change, or even something that needs to be solved at the cost of introducing more platform specific hacks / complication into our build system. It’s surprising that there is no way for us to fix this for our use case given the multitude of ccache configuration options / settings, and it’s support for additional compiler wrappers. Have we opened an issue upstream to document our use case, and why ccache doesn’t currently work with it?

    Considering some recent comments:

    should I re-open this PR?

  21. fanquake commented at 8:53 am on August 16, 2023: member

    It’s surprising that there is no way for us to fix this for our use case given the multitude of ccache configuration options / settings, and it’s support for additional compiler wrappers.

    Have we opened an issue upstream to document our use case, and why ccache doesn’t currently work with it?

  22. hebasto commented at 1:27 pm on August 26, 2023: member

    It’s surprising that there is no way for us to fix this for our use case given the multitude of ccache configuration options / settings, and it’s support for additional compiler wrappers.

    From https://github.com/ccache/ccache/issues/1326#issuecomment-1693774827:

    In summary: Use the form env -u VAR ccache clang ... instead.

    That is exactly what this PR does.


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-11-17 15:12 UTC

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