ci: ccache does not work for macOS cross-compiling builds #21552

issue hebasto opened this issue on March 30, 2021
  1. hebasto commented at 4:25 AM on March 30, 2021: member

    https://cirrus-ci.com/task/6268895175639040?logs=ci#L3869:

    ccache version 3.7.7
    cache directory                     /tmp/ccache_dir
    primary config                      /tmp/ccache_dir/ccache.conf
    secondary config      (readonly)    /etc/ccache.conf
    stats updated                       Tue Mar 30 01:48:58 2021
    stats zeroed                        Tue Mar 30 01:21:25 2021
    cache hit (direct)                     0
    cache hit (preprocessed)               0
    cache miss                             0
    cache hit rate                      0.00 %
    called for link                       10
    multiple source files                636
    cleanups performed                     0
    files in cache                         0
    cache size                           0.0 kB
    max cache size                     200.0 MB
    

    UPD 2023-08-25. See https://github.com/ccache/ccache/issues/1326.

  2. hebasto added the label Bug on Mar 30, 2021
  3. hebasto added the label Tests on Mar 30, 2021
  4. hebasto added the label macOS on Mar 30, 2021
  5. hebasto commented at 10:23 AM on April 2, 2021: member

    This line

    multiple source files                636
    

    describes a little. According to ccache docs:

    The compiler was called to compile multiple source files in one go. This is not supported by ccache.

  6. hebasto commented at 10:39 AM on April 2, 2021: member

    @dongcarl

    ccache behavior was broken in 300733921863c176535806c40afdc813b99e7459 (#19683).

  7. dongcarl commented at 8:02 PM on April 5, 2021: contributor

    Was this not the case before 300733921863c176535806c40afdc813b99e7459? I'm not entirely sure how that commit makes it so that "the compiler was called to compile multiple source files in one go"

  8. hebasto commented at 11:33 PM on April 5, 2021: member

    I'm not entirely sure how that commit makes it so that "the compiler was called to compile multiple source files in one go"

    I believe this is because ccache do not support invoking a compiler that prefixed with env command.

    FWIW, if I inject ccache between env and clang, it works fine.

  9. dongcarl commented at 12:33 AM on April 9, 2021: contributor

    FWIW, if I inject ccache between env and clang, it works fine.

    What is the ccache stats output if you inject ccache between env and clang?

  10. hebasto commented at 11:07 AM on April 9, 2021: member

    @dongcarl

    With the following patch

    diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk
    index dd71697f0..8a7c3a791 100644
    --- a/depends/hosts/darwin.mk
    +++ b/depends/hosts/darwin.mk
    @@ -98,6 +98,7 @@ $(foreach TOOL,$(cctools_TOOLS),$(eval darwin_$(TOOL) = $$(build_prefix)/bin/$$(
     darwin_CC=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
                   -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
                   -u LIBRARY_PATH \
    +            /usr/bin/ccache \
                 $(clang_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
                   -B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
                   --sysroot=$(OSX_SDK) \
    @@ -106,6 +107,7 @@ darwin_CC=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
     darwin_CXX=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
                    -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
                    -u LIBRARY_PATH \
    +            /usr/bin/ccache \
                  $(clangxx_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
                    -B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
                    --sysroot=$(OSX_SDK) \
    
    • the first run
    $ CONFIG_SITE=$PWD/depends/x86_64-apple-darwin18/share/config.site ./configure --disable-ccache
    $ ccache --zero-stats
    $ make
    $ ccache --show-stats 
    cache directory                     /home/hebasto/.ccache
    primary config                      /home/hebasto/.ccache/ccache.conf
    secondary config      (readonly)    /etc/ccache.conf
    stats updated                       Fri Apr  9 14:03:35 2021
    stats zeroed                        Fri Apr  9 13:59:19 2021
    cache hit (direct)                   521
    cache hit (preprocessed)               1
    cache miss                           647
    cache hit rate                     44.65 %
    called for link                       12
    cleanups performed                     2
    files in cache                     24070
    cache size                          13.0 GB
    max cache size                      15.0 GB
    
    • the second run
    $ make clean
    $ ccache --zero-stats
    $ make
    $ ccache --show-stats 
    cache directory                     /home/hebasto/.ccache
    primary config                      /home/hebasto/.ccache/ccache.conf
    secondary config      (readonly)    /etc/ccache.conf
    stats updated                       Fri Apr  9 14:04:47 2021
    stats zeroed                        Fri Apr  9 14:04:15 2021
    cache hit (direct)                   644
    cache hit (preprocessed)               2
    cache miss                             1
    cache hit rate                     99.85 %
    called for link                       11
    cleanups performed                     0
    files in cache                     24073
    cache size                          13.0 GB
    max cache size                      15.0 GB
    
  11. dongcarl commented at 6:41 PM on May 13, 2021: contributor

    Urgh... That kinda sucks... I think the easiest solution is perhaps to wait until ccache 4.1 is available on all distros and set compiler_type/CCACHE_COMPILERTYPE?

  12. prusnak commented at 7:59 PM on March 18, 2022: contributor

    to wait until ccache 4.1 is available on all distros @dongcarl What do you mean by "all distros"?

  13. dongcarl commented at 8:04 PM on March 18, 2022: contributor

    Sorry, probably better rephrased as "available on stable versions of major distros"... Sometimes I think we might need a configure script for depends lol

  14. prusnak commented at 8:14 PM on March 18, 2022: contributor

    "available on stable versions of major distros"

    • Debian 10 (old stable) has ccache 3.6
    • Debian 11 (stable) has ccache 4.2
    • Ubuntu 20.04 (latest LTS) has ccache 3.7.7
    • Ubuntu 21.04 has ccache 4.2
    • Ubuntu 21.10 has ccache 4.2.1
    • Ubuntu 22.04 (upcoming LTS) has ccache 4.5.1

    src: https://repology.org/project/ccache/versions

  15. hebasto commented at 12:12 PM on March 20, 2022: member

    @dongcarl

    Urgh... That kinda sucks... I think the easiest solution is perhaps to wait until ccache 4.1 is available on all distros and set compiler_type/CCACHE_COMPILERTYPE?

    I've tested this approach on Ubuntu 22.04 with ccache 4.5.1, and it doesn't work.

    OTOH, another approach has been implemented in #24620.

  16. Sjors commented at 8:39 AM on June 16, 2022: member

    Not just when cross-compiling. I made a separate issue #25387, because I'm not sure if it's the same (ccache 4.6.1).

    (nvm: it does work as far as I can tell, but doesn't use it by default)

  17. fanquake commented at 9:06 AM on August 16, 2023: member

    Given it's not in the description, can someone summarize the current state of this issue?

    • What doesn't work?
    • What ccache options have been tried (and don't work)? Taking into account recent ccache releases.
    • Have we opened an issue upstream to either report that ccache is broken (for us), or that we have a usecase which isn't satified by it's current feature/option set, to see if they are open to adding a new feature/option?
    • If there is any (related) upstream discussions/issues, can somebody link to them here?
  18. hebasto commented at 11:16 AM on August 25, 2023: member

    Given it's not in the description, can someone summarize the current state of this issue?

    • What doesn't work?

    • Have we opened an issue upstream to either report that ccache is broken (for us), or that we have a usecase which isn't satified by it's current feature/option set, to see if they are open to adding a new feature/option?

    • If there is any (related) upstream discussions/issues, can somebody link to them here?

    See https://github.com/ccache/ccache/issues/1326.

  19. hebasto commented at 12:15 PM on August 25, 2023: member

    Urgh... That kinda sucks... I think the easiest solution is perhaps to wait until ccache 4.1 is available on all distros and set compiler_type/CCACHE_COMPILERTYPE?

    Tested with ccache 4.8.2. It does not work.

  20. hebasto referenced this in commit ee4dc7d928 on Sep 11, 2023
  21. fanquake referenced this in commit ba76fc8bda on Jul 15, 2024
  22. fanquake referenced this in commit b9673bfd52 on Jul 15, 2024
  23. fanquake referenced this in commit 4ad14a83c6 on Jul 15, 2024
  24. fanquake referenced this in commit feeefcf2a3 on Jul 15, 2024
  25. fanquake referenced this in commit 0d25a263c8 on Jul 15, 2024
  26. fanquake referenced this in commit aff4a88fd5 on Jul 17, 2024
  27. fanquake referenced this in commit 18609bf2ca on Jul 17, 2024
  28. fanquake referenced this in commit 23c0b07656 on Jul 17, 2024
  29. fanquake referenced this in commit 298c8192a7 on Jul 20, 2024
  30. fanquake referenced this in commit bc78b59c51 on Jul 22, 2024
  31. fanquake referenced this in commit ee269f2d96 on Jul 24, 2024
  32. fanquake referenced this in commit bda537f7c4 on Jul 25, 2024
  33. fanquake referenced this in commit 36cc1097c1 on Jul 25, 2024
  34. fanquake closed this on Jul 30, 2024

  35. fanquake referenced this in commit 4c62f4b535 on Jul 30, 2024
  36. hebasto referenced this in commit ad51f09418 on Jul 30, 2024
  37. denavila referenced this in commit 9e0f261de4 on Sep 4, 2024
  38. PastaPastaPasta referenced this in commit c85063f366 on Feb 17, 2025
  39. PastaPastaPasta referenced this in commit 0fc6cdd3ce on Feb 19, 2025
  40. bitcoin locked this on Jul 30, 2025

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: 2026-05-02 18:14 UTC

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