This is the mail archive of the
mailing list for the GCC project.
Re: Automatic dependency complexity
- To: egcs at cygnus dot com
- Subject: Re: Automatic dependency complexity
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 05 Dec 1998 12:12:01 -0700
- Newsgroups: cygnus.egcs
- Organization: Cygnus Solutions
- References: <firstname.lastname@example.org>
- Reply-To: tromey at cygnus dot com
>>>>> ">" == srivasta <email@example.com> writes:
>> Have the -MD and -MMD flags output lines like:
>> foo.o foo.d: a.h
>> This really is the right thing to do.
I know that the GNU make documentation suggests having a separate rule
to create the `.d' files. However, I think this isn't the best way to
go. Instead, I believe that dependencies should be created as a side
effect of compilation.
This is what automake implements. It seems to work quite well in
Doing things this way halves the number of compiler invocations needed
for a build as compared to the way GNU make suggests.
As it turns out, gcc's dependency tracking code isn't really as easy
to use as I'd like it to be (for automake). Currently automake's
rules have to do some rather nasty post-processing on the generated
First, automake wants to put the `.d' files into a subdirectory. That
rules out using `-MD'. Also, in some cases, automake wants to change
the name of the target (e.g., to "foo.o foo.lo: ..."). That suggests
using DEPENDENCIES_OUTPUT -- but that appends to the file that is
created (also, DEPENDENCIES_OUTPUT apparently acts like `-MM' and not
`-M', despite the docs). So instead automake passes `-Wp,-Md,...' to
gcc -- the first ugliness.
Second, automatic dependency tracking following this model is
susceptible to the "deleted header file" problem. If I delete a `.h'
file that is mentioned in one of the dependency lists, `make' will
have no way to recreate it, and will die before the dependencies can
Automake fixes this bug by adding fake targets for each header. So in
the end automake ends up rewriting this:
foo.o: foo.c foo.h
foo.o foo.lo: foo.c foo.h
I'd like to propose changing gcc's interface to dependency tracking so
that automake can use it more naturally. At the same time, changing
the GNU make docs to recommend this (IMNSHO) better way of computing
dependencies would be a good idea. Here are the new options I'm
-MT NAME Set name of target in generated file
Default is computed as it is now
-MF NAME Set name of `.d' file. (Default is as now.)
-MH Add a fake dependency for each header file
Implementation-wise, I think the code that actually generates the `.d'
file should be extracted from cpp and put into its own file. That
would let the java front end use the same code (right now some of it
What do people think of this? It's on my list of stuff I want to
implement eventually, but of course it's hard to say when I'll get to