[ccache] -MD switch broken in gcc3 w/ccache

Davlet Panech davlet_panech at yahoo.ca
Fri Feb 20 00:45:36 GMT 2004


In gcc 3.x the -MD switch doesn't work when used with
ccache. For example,

  gcc -MD -c -o obj/file.o src/main.c

creates a file named "obj/file.d", while

  ccache gcc -MD -c -o obj/file.o src/main.c

creates "./main.d" containing the wrong target name.

This is because the preprocessor has no way of
generating the correct .d filename and make rule
target without the -o flag.

I guess the simplest way to fix it is to fail() if
-MD/-MMD are present on the command line, but I'd like
to suggest a better solution:

* If necessary, run a test to determine whether the
compiler we are about to call understands -MF ("rename
the .d file") and -MQ/-MT ("rename the target in the
.d file").
* Cache the results of the test in the cache_dir along
with the compiler pathname/st_size/st_mtime, so that
we can reuse them later
* If -MF/-MQ/-MT are supported, add them to the
preprocessor command line at the end of process_args()

Would that break anything? Is there a simpler

I wrote a patch that does this; would the maintainers
be interested in including it in the distribution
(after I clean it up and test it)?


Post your free ad now! http://personals.yahoo.ca

More information about the ccache mailing list