preprocessor/6521: -MG creates dependency with wrong path
Zack Weinberg
zack@codesourcery.com
Wed May 8 00:03:00 GMT 2002
On Wed, May 08, 2002 at 07:36:46AM +0100, Neil Booth wrote:
> Robert Spier wrote:-
>
> > The only sensible patch I can think of is to remove this odd
> > functionality entirely.
> >
> > The below patch unifies handling for system and non-system include
> > files and removes the special case. It only affects -MG, and brings
> > it in line with the documentation:
> >
> > -MG When used with -M or -MM, -MG says to treat missing
> > header files as generated files and assume they live
> > in the same directory as the source file. It sup?
> > presses preprocessed output, as a missing header file
> > is ordinarily an error.
>
> On further reflection, I don't think this makes any sense.
> Files included with <> do not search the current directory,
> so assuming the file lies there is obviously bogus.
Odds are anyone including generated files with <> is using -I. or
similar.
> The sensible thing to do, IMO, is to step down the <> include path
> until the resulting path, when appending the file name, exists, and
> to fail if all such paths don't exist.
I'm not entirely sure I understand this.
I've never really liked -MG; it is too inflexible. With <> it does
something fairly silly, as Robert points out; but with "" it does
something equally silly, which is to assume that splatting whatever
string the user provided into the dependency list will work. (It does
_not_ assume they live in the same directory as the source file;
consider split source and build trees. The current behavior is
more likely to work in practice than the documented one, but...
The behavior under discussion predates cpplib, incidentally.
It seems to me that we should leave -MG alone, since there are
undoubtedly Makefiles out there depending on every last quirk of its
semantics (remember all the fallout the last time we decided to
improve the semantics of the -M switches?). We should instead come up
with a new way to do it that lets the user say where the generated
file is expected to turn up... perhaps -Mx <path> puts all the
dependencies on generated files in <path>. (Where 'x' is some
appropriate letter; I am too tired to think of a good one right now.)
Come to think of it, -MG and -MP clash. We should mark entries added
to the list by -MG and not generate phony targets for them under -MP,
or Make will pitch a fit about multiple rules for the same target.
zw
More information about the Gcc-bugs
mailing list