Skip to content

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

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 (ae005a64):

$ cat /etc/os-release | grep VERSION=
VERSION="22.04 (Jammy Jellyfish)"
$ ccache --version | head -1
ccache version 4.5.1
$ make -C depends HOST=x86_64-apple-darwin
$ ./autogen.sh
$ CONFIG_SITE=$PWD/depends/x86_64-apple-darwin/share/config.site ./configure 
$ make clean
$ ccache --zero-stats
$ make
$ ccache --show-stats -v
Summary:
  Cache directory:       /home/hebasto/.cache/ccache
  Primary config:        /home/hebasto/.config/ccache/ccache.conf
  Secondary config:      /etc/ccache.conf
  Stats updated:         Sun Mar 20 12:33:01 2022
  Hits:                      0 /    0
    Direct:                  0 /    0
    Preprocessed:            0 /    0
  Misses:                    0
    Direct:                  0
    Preprocessed:            0
  Uncacheable:             734
Primary storage:
  Hits:                      0 /    0
  Misses:                    0
  Cache size (GB):        1.69 / 5.00 (33.87 %)
  Files:                 11790
Uncacheable:
  Called for linking:       14
  Multiple source files:   720

With this PR:

$ make -C depends HOST=x86_64-apple-darwin
$ ./autogen.sh
$ CONFIG_SITE=$PWD/depends/x86_64-apple-darwin/share/config.site ./configure 
$ make clean
$ make
$ make clean
$ ccache --zero-stats
$ make
$ ccache --show-stats 
Summary:
  Hits:             720 /  720 (100.0 %)
    Direct:         720 /  720 (100.0 %)
    Preprocessed:     0 /    0
  Misses:             0
    Direct:           0
    Preprocessed:     0
  Uncacheable:       14
Primary storage:
  Hits:            1440 / 1440 (100.0 %)
  Misses:             0
  Cache size (GB): 1.74 / 5.00 (34.80 %)

Use the -v/--verbose option for more details.

Fixes #21552 (closed).


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

Merge request reports

Loading