This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
driver/9517: makefile dependencies deleted on error, option -MMD
- From: Ralf dot Friedl at online dot de
- To: gcc-gnats at gcc dot gnu dot org
- Date: 30 Jan 2003 21:45:18 -0000
- Subject: driver/9517: makefile dependencies deleted on error, option -MMD
- Reply-to: Ralf dot Friedl at online dot de
>Number: 9517
>Category: driver
>Synopsis: makefile dependencies deleted on error, option -MMD
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Thu Jan 30 21:46:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Ralf.Friedl@online.de
>Release: gcc-3.2
>Organization:
>Environment:
>Description:
The Option -MMD can be used to create dependency files for inclusion in 'make'.
If 'make' is used with these files, the following problem occurs:
If compilation fails, the dependency file is removed, but the object file is not removed.
If the compilation fails because of errors in included files, the demendancy information is lost.
When in the included file is changed (to fix the error), 'make' will no longer know about the dependancies and not recompile the object file.
As the object files are still present, it is possible that an executable is created from the old objects without indication to the user.
>How-To-Repeat:
Create foo.c, foo.h
Makefile:
CPPFLAGS = -MMD
foo: foo.o
include $(wildcard *.d)
Run 'make', this create foo.o and foo.d.
Change foo.h to contain an error.
Run make, this deletes foo.d but keeps foo.o.
Change foo.h again (fix error)
Run 'make', it does nothing because foo.o exists and is newer than foo.c,
and foo.d does not exists, so the dependency on foo.h is unknown.
>Fix:
delete object file, where compilation fails
or
keep dependancy file
As the dependancy file is created by the preprocessor, it should not be affected by compiler errors.
>Release-Note:
>Audit-Trail:
>Unformatted: