I am using ccache for experiments, but I am not quite sure that I should use this. Can anyone explain the situation when ccache can result in wrong behavior. Or should we always use ccache ? Anyone who got that ccache is producing wrong object files or changes in header files are not being considered ?
I practically never have any issues while using ccache
. Sometimes (e.g. once a month or even less), I clean entirely its cache with ccache -C
.
I have more issues with complex Makefile-s than with ccache
.
To be short, don't bother, and when you suspect something, just run ccache -C
.
You obviously should avoid ccache
when you are benchmarking the compilation time. (You could pass -time
or -ftime-report
to gcc
or g++
in that case).
I my opinion, ccache
should be at least configurable to disable caching for compilation using GCC plugins, because a GCC plugin could do anything (e.g. querying a database or webservice) which is not cachable. See this message.
You phrased your question well by asking wrong behavior.
The wrong behavior ccache may have is slowing down your compilation if used incorrectly. ccache has to scan the file to recognize past compilations, so an actual compilation through ccache is slower than without it. Only a cache hit is faster.
ccache is useful when you frequently recompile the same code without modifying it. It will not speed up compilation of new or modified code.
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