peeyush
peeyush

Reputation: 2921

disadvantages of ccache

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 ?

Upvotes: 6

Views: 4202

Answers (3)

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).

Addenda

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.

Upvotes: 9

sehe
sehe

Reputation: 393134

I once had issues with SCons compiling through ccache (symlink method).

Environment Settings

It turned out ccache requires the $HOME variable to be set in the environment, whereas SCons doesn't set it by default (SCons has the policy to isolate builds from the environment as much as possible by default).

I'm not entirely sure whether this would count as a problem with ccache or merely interoperating with SCons. Besides this quirk, I never had any trouble with ccache.

SSD wear

I have adopted the habit of linking ~/.ccache to tmpfs to avoid wearing my SSDs unnecessarily. Obviously, this is not a problem with ccache, because without it, things would be worse still. (Just something to keep in mind)

Upvotes: 3

Offirmo
Offirmo

Reputation: 19840

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.

Upvotes: 4

Related Questions