This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to -MD specs
- From: Jason Merrill <jason at redhat dot com>
- To: Neil Booth <neil at daikokuya dot co dot uk>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 06 Sep 2002 15:17:56 +0100
- Subject: PATCH to -MD specs
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.
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.
Neil, thoughts?
2002-09-06 Jason Merrill <jason@redhat.com>
* gcc.c (cpp_unique_options): If -MD or -MMD, also cause the rule
target to be deleted on failure.
(do_spec_1) [case 'W']: End any pending argument from the braces.
*** gcc.c.~1~ Mon Aug 12 19:48:24 2002
--- gcc.c Fri Sep 6 15:12:29 2002
*************** static const char *cpp_unique_options =
*** 671,680 ****
"%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{CC:%{!E:%eGNU C does not support -CC without using -E}}\
%{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*} %{P} %I\
! %{MD:-MD %W{!o: %b.d}%W{o*:%.d%*}}\
! %{MMD:-MMD %W{!o: %b.d}%W{o*:%.d%*}}\
%{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
! %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
%{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i\
--- 671,680 ----
"%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{CC:%{!E:%eGNU C does not support -CC without using -E}}\
%{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*} %{P} %I\
! %{MD:-MD %W{!o:%b.d}%W{o*:%.d%*}}\
! %{MMD:-MMD %W{!o:%b.d}%W{o*:%.d%*}}\
%{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
! %{!E:%{!M:%{!MM:%{MD|MMD:-MQ %W{!o:%b%O}%W{o*:%*}}}}}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
%{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i\
*************** do_spec_1 (spec, inswitch, soft_matched_
*** 4702,4707 ****
--- 4702,4719 ----
p = handle_braces (p + 1);
if (p == 0)
return -1;
+ /* End any pending argument. */
+ if (arg_going)
+ {
+ obstack_1grow (&obstack, 0);
+ string = obstack_finish (&obstack);
+ if (this_is_library_file)
+ string = find_file (string);
+ store_arg (string, delete_this_arg, this_is_output_file);
+ if (this_is_output_file)
+ outfiles[input_file_number] = string;
+ arg_going = 0;
+ }
/* If any args were output, mark the last one for deletion
on failure. */
if (argbuf_index != cur_index)