./configure CC='ccache clang -Qunused-arguments -fcolor-diagnostics'to get rid of the "argument unused during compilation" warnings.
But you still might get loads of warnings that you wouldn't normally get without ccache, such as this example (from the PostgreSQL source code):
extension.c:382:35: warning: equality comparison with extraneous parentheses [-Wparentheses] if (( (((control->directory)[0]) == '/') )) ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ extension.c:382:35: note: use '=' to turn this equality comparison into an assignment(This is the opposite of the warning that tells you to put two pairs of parentheses around an assignment used as a truth value.) Or:
path.c:727:7: warning: explicitly assigning a variable of type 'char *' to itself [-Wself-assign] path = (path); ~~~~ ^ ~~~~The problem is, these come from macro expansions, so wouldn't normally see them, because (I guess) the compiler driver is smart enough not to warn about such things when they come from macro expansions.
The way ccache works is approximately
- preprocess the input file
- look for it in the cache
- if not found, compile the preprocessed file
- preprocess the input file
- look for it in the cache
- if not found, compile the original file
export CCACHE_CPP2=yesThen all these extra warnings disappear.
(The ccache man page is worth a read. There are a few interesting settings to play with.)
I'm currently playing around with a shell script ccache-clang that looks like this:
CCACHE_CPP2=yes exec ccache clang -Qunused-arguments `test -t 2 && echo -fcolor-diagnostics` "$@"