[ccache] Generated dep file newer than object file

Andrew Gallagher andrewjcg at gmail.com
Sun May 1 15:02:08 MDT 2011


When using the '-MD' to gcc, a dep file is produced along side the
object file.  In ccache, this dep file is copied after the object file
is copied, resulting a newer mtime for the dep file than the object
file.  I believe this is an issue for makefiles with rules like:

foo.o: foo.c
  gcc -c -MD ...

foo.o: foo.d


When running 'make' twice consecutively, it's expected that the second
time doesn't do anything since everything is up to date (this is the
behavior when not using ccache).  However, since ccache generates the
dep file which (sometimes) has a newer mtime than the object file,
'make' determines that 'foo.o' needs to be rebuilt, due to the second
rule above.

I think the fix is pretty simple (I've been adding an
"update_mtime(output_obj);" if a dep file is produce).  What would be
the best way to send diffs/patches for bug fixes like this?

Thanks,
Andrew


More information about the ccache mailing list