My project sometimes benefits from ccache, so I have been using ccache for a long time. Now I am adding precompiled headers. Some sources suggest that the two are incompatible and that they should choose between them. But I find in the ccache documentation that it supports PCH at some level: https://ccache.samba.org/manual.html#_precompiled_headers
In fact, when I try to use ccache to create a .o file when using the Clang parameter -include-pch, I see that ccache succeeds when caching .o. The first compilation attempt takes 1.5 s, and the second only takes 0.05 s (because ccache completed its task).
The problem is that if I run the same compilation command with clang++, rather than with /usr/lib/ccache/clang++, it will take 0.5 s ... if I don’t leave the part -include-pch, in which case it takes about 1.5 s, It seems that ccache might cause ignoring my PCH or something like that.
I followed the instructions (at the link above). As indicated there, my ccache.conf looks like this:
sloppiness=pch_defines,time_macros
And I tried all reasonable combinations #include, -include, -include-pchand -fpch-preprocessof which I could think of. Compilation always takes 1.5 s, and then 0.05 s, when it should take 0.5 s, and then 0.05 s.
Can this work be done, or do I need to choose between ccache and PCH?
source
share