[ccache] ccache with "g++ -MD"

Tal Ben Avidor TalBA at corrigent.com
Wed Apr 25 11:00:04 GMT 2007

Hello CCachers,

I'm trying to use ccache with Windriver Workbench. At first it seemed to
work fine. Compilation is a lot faster, it saves tons of time. Only
later  have we noticed that the dependency tracking isn't working at
After some digging, I'm convinced that the problem is related to "-MD"
parameter which the workbench generated makefile passes to g++.
The dependenciy file xxx.d is created in one place when using g++, and
in another place when using ccache as frontend to g++.

Am I doing something wrong, or is there a workaround for this problem?

The makfile command line is:
g++ $(DEBUGFLAGS_C++-Compiler) -mpowerpc -mcpu=603e -pipe -Wall -Wextra
-Wno-unused $(IDE_INCLUDES) -MD -MP -c -DARCH=$(ARCH) -o "$@" "$<"

Some relevant info from gcc manual page:
-MD	-MD is equivalent to -M -MF file, except that -E is not implied.
The driver determines file
           based on whether an -o option is given.  If it is, the driver
uses its argument but with a suffix
           of .d, otherwise it take the basename of the input file and
applies a .d suffix.

           If -MD is used in conjunction with -E, any -o switch is
understood to specify the dependency out-
           put file (but @pxref{dashMF,,-MF}), but if used without -E,
each -o is understood to specify a
           target object file.

           Since -E is not implied, -MD can be used to generate a
dependency output file as a side-effect of
           the compilation process.


More information about the ccache mailing list