[ccache] Ccache's use of preprocessed source
Lubos Lunak
l.lunak at centrum.cz
Fri Nov 29 09:26:25 MST 2013
Hello,
in short, I'd like to ask about the feasibility of CCACHE_CPP2=1 becoming the
default and the possibility of preventing ccache from running cpp at all.
From the "cache hides compiler warnings about comments" thread:
> By the way, a workaround is to set CCACHE_CPP2 when compiling.
I think it is incorrect to call CCACHE_CPP2 a workaround. Current compilers
are no longer the old-school separate preprocessor-compiler-assembler tools,
nowadays these steps are done by just one tool and they even somewhat depend
on each other. So preprocessing source and giving that to a compiler has a
number of drawbacks:
- The -Wdocumentation feature, discussed in the recent thread, not working.
- Clang and recent GCC quote sources in their errors/warnings. If source is
preprocessed, it'll have comments removed and macros expanded, meaning the
errors/warnings will show something that "is not there".
- I don't know about GCC, but Clang supresses some warnings if they come from
a macro expansion. I think the idea is similar to supressing warnings from
system headers, but given that a macro from a system header can get expanded
even in the main source, the most obnoxious (or most often occurring?)
warnings are simply suppressed completely in macro expansions. With ccache
this does not work and there are spurious warnings.
(Note that e.g. -save-temps has the same drawbacks, but who uses that for
normal work.)
So I think actually CCACHE_CPP2 set is the normal way and _not_ having it set
can be considered to be a performance hack.
Some time back
(http://www.mail-archive.com/ccache@lists.samba.org/msg00817.html) I measured
CCACHE_CPP2 adding 8% overhead, today I tried it on a different machine
compiling LLVM/Clang and I could get only 3% (no idea if that's a real
improvement somewhere over the year or if it's just a noise). I don't have
any numbers for GCC, but from what I have heard GCC's preprocessor has gotten
noticeably faster in the last years.
So, to my questions:
- does somebody have any CCACHE_CPP2 numbers for GCC?
- would it be possible to alter the documentation to actually recommend
CCACHE_CPP2, or at least not dismiss it as something that's unlikely to be
needed?
- (based on performance numbers I guess) would it be possible to switch the
default for CCACHE_CPP2?
- how difficult would it be to add a possibility of preventing ccache's use of
cpp completely, thus relying only on the direct mode? This could be useful in
case the overhead of CCACHE_CPP2 is considered too big, and possibly even in
the general case (direct hits should be usually much more common and why have
the overhead of running cpp for a minority of hits). I could give this a
shot, but I don't know if there isn't some design problem making this
difficult/impossible.
--
Lubos Lunak
More information about the ccache
mailing list