I'm trying to use ccache to speed up my rebuilds and I noticed this in the log:
[2015-04-17T10:41:45.845545 27682] Compiler option -M is unsupported
[2015-04-17T10:41:45.845584 27682] Failed; falling back to running the real compiler
In my experience you need something like the -M flag in order to have make or its equivalent trigger rebuilds correctly. It seems weird that ccache would be tripped up by an option that must be in almost every project's build. Am I missing something? Is there a more preferred option?
This is w/ ccache-3.2.1.
Edit: I tried with -MM as well, no luck.
It is correct that ccache currently doesn't support the compiler options -M
and -MM
(and it never has supported them).
Some reasons for why the options in question are unupported:
It would most likely be possible to implement support by letting ccache run the compiler command twice: one without -M
/-MM
to retrieve the preprocessed source code (with which the result should be associated) and one with -M
/-MM
to retrieve the result (make rules).
However, I (speaking as the ccache maintainer for the last six years) have not heard anybody missing support for -M
/-MM
until now, so my impression is that -M
/-MM
actually aren't used much.
Am I missing something? Is there a more preferred option?
Yes, I would say that the standard way is to use -MD
/-MMD
(which are supported by ccache) instead of -M
/-MM
. -MD
/-MMD
are superior because they produce both the .o
and the .d
file in one go, whereas -M
/-MM
only produce the .d
file, so the compiler must in that case be invoked twice by the Makefile for each source code file. See for instance http://www.microhowto.info/howto/automatically_generate_makefile_dependencies.html for how to use -MD
/-MMD
.