What is meant by the ccache statistic "called for link". I thought ccache only wrapped the compiler, not the linker?
[Brian@localhost ~]$ ccache -s
cache directory /home/Brian/.ccache
cache hit (direct) 19813
cache hit (preprocessed) 67
cache miss 11
called for link 498
called for preprocessing 10
unsupported source language 472
no input file 12
files in cache 258568
cache size 33.8 Gbytes
max cache size 100.0 Gbytes
ccache
indeed does not support linking.
It does replace the C compiler (the C compiler driver, more specifically), however (look where and how it's installed and used). Because of that, it needs to "pass through" any commands it receives and does not handle/modify itself to the respective parts of the toolchain.
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:
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 !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With