Reading the release notes was not very clear to me either:
The statistics counter “called for link” is now correctly updated when
linking with a single object file.
But it means you are doing compilation & linking in a single operation so there is no way ccache can supply the result transparently.
Demo with a basic hello.c program. First lets clear everything:
$ ccache -Czs
Cleared cache
Statistics cleared
cache directory /home/jdg/.ccache
cache hit (direct) 0
cache hit (preprocessed) 0
cache miss 0
files in cache 0
Doing a compile and link in one step (twice, just to be sure):
$ ccache g++ hello.c
$ ccache g++ hello.c
$ ccache -s
cache hit (direct) 0
cache hit (preprocessed) 0
cache miss 0
called for link 2
files in cache 0
Nothing is cached, because ccache just can't
Doing it in two separate steps (also twice):
$ ccache g++ -c hello.c ; g++ hello.o
$ ccache g++ -c hello.c ; g++ hello.o
$ ccache -s
cache hit (direct) 1
cache hit (preprocessed) 0
cache miss 1
called for link 4
no input file 2
files in cache 2
Now it worked:
- First compilation made a cache miss, and stored the results (two
files: manifest plus .o)
- Second made a cache hit
- g++ was called for link 4 times total, including 2 times with no source but only .o
And the called for preprocessing stuff ? Simple, you just used your compiler to expand all the include/define stuff (eg. when looking for dependency)
$ g++ -E hello.c
$ g++ -M hello.c
$ ccache -s
cache hit (direct) 1
cache hit (preprocessed) 0
cache miss 1
called for link 4
called for preprocessing 2
unsupported compiler option 1
no input file 2
files in cache 2
Hope this helps !