Bug 7862 - Interrupting gcc -MD removes .d file but not .o
Summary: Interrupting gcc -MD removes .d file but not .o
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Neil Booth
URL:
Keywords: wrong-code
: 8190 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-09-09 05:26 UTC by Jason Merrill
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Merrill 2002-09-09 05:26:03 UTC
[from customer bug report]
We are using -MD option in gcc to manage the dependency information. The problem
is this, if this is interrupted by a control-c gcc promptly deletes the .d file
but not any .o file that may have been existed prior to compilation. So for
example, the following situation could occur:

1. foo.C depends on foo.H
2. foo.H is changed followed by a gmake
3. foo.H is changed again followed by a gmake
4. gmake is interrupted
5. .d file gets deleted
6. foo.H is changed again but doing a gmake will now do nothing

The problem is that now foo.o may have a bogus object layout.


Expected Results:  if foo.d is deleted, foo.o must be deleted as well; otherwise
a makefile which relies on the contents of foo.d in order to decide when to
rebuild foo.o will get the wrong answer.

Either we should delete both, or neither.

Note that if -o is not used in the compile, neither foo.d nor foo.o are deleted, because %W{!o: %b.d} doesn't actually add %b.d to the failure_delete_queue.

The current behavior was established by

  http://gcc.gnu.org/ml/gcc-patches/2001-02/msg00481.html

Release:
3.0.4, 3.2, trunk

Environment:
all

How-To-Repeat:
Steps to Reproduce:
1. gcc -c foo.c -MD -o foo.o
2. ls -l foo.* (notice that both foo.d and foo.o exist)
3. gcc -c foo.c -MD -o foo.o (interrupt with ^C while cc1 is running)
4. ls -l foo.* (notice that foo.o exists, but foo.d does not)
Comment 1 Jason Merrill 2002-09-09 05:26:03 UTC
Fix:
I proposed a solution in

   http://gcc.gnu.org/ml/gcc-patches/2002-09/msg00388.html

but Neil wasn't happy with it.  I'm waiting for more feedback.
Comment 2 Jason Merrill 2002-09-09 05:30:53 UTC
Responsible-Changed-From-To: unassigned->neil
Responsible-Changed-Why: you wrote the current code
Comment 3 Neil Booth 2002-10-12 10:13:16 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Fixed by not deleting the .d file on interruption.
Comment 4 Neil Booth 2002-10-12 17:10:22 UTC
From: neil@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: preprocessor/7862
Date: 12 Oct 2002 17:10:22 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	neil@gcc.gnu.org	2002-10-12 10:10:21
 
 Modified files:
 	gcc            : ChangeLog gcc.c 
 
 Log message:
 	PR preprocessor/7862
 	PR preprocessor/8190
 	* gcc.c (cpp_unique_options): Don't delete .d files.
 	Remove stray whitespace.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.15688&r2=1.15689
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gcc.c.diff?cvsroot=gcc&r1=1.342&r2=1.343
 

Comment 5 David Edelsohn 2002-10-14 21:55:27 UTC
From: dje@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: preprocessor/7862
Date: 14 Oct 2002 21:55:27 -0000

 CVSROOT:	/cvs/gcc
 Module name:	egcs
 Branch: 	gcc-3_2-branch
 Changes by:	dje@gcc.gnu.org	2002-10-14 14:55:27
 
 Modified files:
 	gcc            : ChangeLog gcc.c 
 
 Log message:
 	2002-10-14  Neil Booth  <neil@daikokuya.co.uk>
 	
 	PR preprocessor/7862
 	PR preprocessor/8190
 	* gcc.c (cpp_unique_options): Don't delete .d files.
 	Remove stray whitespace.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.13152.2.657.2.88&r2=1.13152.2.657.2.89
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/egcs/gcc/gcc.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.296.2.12.4.3&r2=1.296.2.12.4.4