This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH to -MD specs


On Fri, 6 Sep 2002 16:34:58 +0100, Neil Booth <neil@daikokuya.co.uk> wrote:

> Jason Merrill wrote:-
>
>> Currently, if you compile something with 
>> 
>>   gcc -MD -c foo.c -o foo.o
>> 
>> and hit ^C while cc1 is running, gcc will delete the .d file, but not the
>> .o file (if it already exists).  A subsequent make would see the
>> preexisting foo.o, but not any dependencies, and decide that foo.o is up to
>> date.  Oops.
>> 
>> This patch causes us to delete the output file as well, if we are compiling
>> with -MD.  It also moves the handling of the default rule target into the
>> specs, as I don't see any other way to add that string to the command line
>> so I can wrap a %W{} around it.
>
> Ugh, these specs are spiralling out of control.

No argument there.

> Adding an -MQ like this changes the behaviour if
>
> 1) -MQ or -MT is specified, or
> 2) SUNPRO_DEPENDENCIES or DEPENDENCIES_OUTPUT is used
>
> right?  2) is probably not so important, but 1) is I think.

Both of these are already problems with the implicit -MQ added for a -o.

1) can be avoided by wrapping the -MQ in %{!MQ:%{!MT: }}.

>> This patch also removes stray spaces in the -MD/-MMD rules, and fixes
>> do_spec_1 so that a trailing space is not necessary to terminate the %b.d
>> argument so that %W can see it.  I assume there's some reason that
>> handle_braces doesn't already terminate a pending argument; if not, we
>> could do it there instead.
>
> I'll take your word for it 8-)

Please don't; I'm just stating my assumption, hoping that someone will
either confirm or deny it.

> What's the reason you can't just make it
>
> %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:%W{-MQ %*}}}}}}\
>
> This doesn't change semantics, at least.  Does it miss a case?

Yes, the case where there's no -o.

Another alternative would be to stop using %W for the .d files; deleting
them on failure is certainly wrong for *DEPENDENCIES*, and probably wrong
for the normal case, too; since we write out the file in a burst at the end
of compilation, interrupting compilation is unlikely to cause corrupted
output.  Tweaks to mkdeps.c could make it even less likely; if we spit
everything out with a single write, there should be no chance of
corruption.  What do you think?

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]