[ccache] [PATCH] Support for Clang precompiled headers

Lubos Lunak l.lunak at suse.cz
Fri Jul 13 03:48:16 MDT 2012

On Thursday 12 of July 2012, Joel Rosdahl wrote:
> On 6 July 2012 19:09, Lubos Lunak <l.lunak at suse.cz> wrote:
> > the attached patches modify ccache to also support Clang PCH in addition
> > to GCC PCH.
> Thanks!
> Regarding 0002-hash-clang-s-.pch-file-explicitly.patch: Why is the third
> assignment of pch_file done outside the "if (stat(pchpath, &st) == 0)"
> block? This means that pch_file and included_pch_file can be set even when
> there is no .pch file, so remember_include_file will fail to stat the file
> and then turn off the direct mode. The test suite also fails after the
> patch, but passes if the pch_file assignment is moved into the block.

 Right. I guess that was an oversight when I moved the "Multiple precompiled 
headers used" error to one place. Fixed version attached.

> The patches look good otherwise.
> > PS: Since I've noticed in the archives the recent mail about issues with
> > ccache and warnings about unused arguments: The proper way to use ccache
> > with Clang is to set CCACHE_CPP2, which not only avoids these warnings,
> > but in general Clang works suboptimally if passed preprocessed output
> > (warning/error messages quoting sources are affected, some warnings are
> > not supressed in headers).
> Do you have any idea about the performance impact of using CCACHE_CPP2 for
> clang?

 Debug build of LibreOffice, warm disk caches, empty ccache, make -j4 in 
xmloff module:


494.64user 34.99system 2:15.60elapsed 390%CPU (0avgtext+0avgdata 
0inputs+3752560outputs (507major+13592550minor)pagefaults 0swaps

not set:

457.17user 28.94system 2:06.15elapsed 385%CPU (0avgtext+0avgdata 
0inputs+3758600outputs (444major+12098612minor)pagefaults 0swaps

 So in this case CCACHE_CPP2 adds about 8% overhead. It might make a 
difference for somebody, but I myself would prefer to get better error 
messages from Clang (and I actually use ccache only for a buildbot, so I 
don't find this worth the effort).

 If somebody would feel like playing with this, note that Clang 3.2 will 
have -E -Wp,-rewrite-includes, which only processes #include directives and 
nothing more (I wrote the feature to solve a similar problem when using Clang 
with Icecream for distributed builds, and I assume this is the only thing 
ccache in fact wants from -E too). So using this in ccache for Clang should 
presumably reduce this overhead.

 Lubos Lunak
 l.lunak at suse.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-hash-clang-s-.pch-file-explicitly.patch
Type: text/x-diff
Size: 3111 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/ccache/attachments/20120713/ce5e9200/attachment.patch>

More information about the ccache mailing list