This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug preprocessor/44526] New: libcpp should avoid circular dependencies
- From: "dfranke at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jun 2010 16:05:43 -0000
- Subject: [Bug preprocessor/44526] New: libcpp should avoid circular dependencies
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Since r160684 gfortran supports generation of Makefile dependencies via libcpp.
In the example below, foo.mod is a target as it is generated from the .f90
file, but also a dependency as it used in the same source file:
$ cat foo.f90
MODULE foo
END MODULE
USE foo
END
$ gfortran-svn -cpp -M foo.f90
foo.o foo.mod: foo.f90 foo.mod
Make complains about (and drops) the circular dependency.
This could be improved if mkdeps.c (deps_add_dep) would verify that there is no
target of the same name and if there is, would drop the dependency. This
assumes that there is no situation where such a circular dependency would be
actually required.
The case that a target is generated with a respective dependency in place does
not happen in Fortran - to USE a module, it must have been seen before, i.e.
the module file must exist.
Suggested patch:
Index: libcpp/mkdeps.c
===================================================================
--- libcpp/mkdeps.c (revision 160677)
+++ libcpp/mkdeps.c (working copy)
@@ -256,8 +256,18 @@ deps_add_default_target (struct deps *d,
void
deps_add_dep (struct deps *d, const char *t)
{
+ unsigned int i;
+
t = munge (apply_vpath (d, t)); /* Also makes permanent copy. */
+ /* Avoid circular dependencies. */
+ for (i = 0; i < d->ntargets; i++)
+ if (strcmp (d->targetv[i], t) == 0)
+ {
+ free ((void *) t);
+ return;
+ }
+
if (d->ndeps == d->deps_size)
{
d->deps_size = d->deps_size * 2 + 8;
--
Summary: libcpp should avoid circular dependencies
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: patch
Severity: enhancement
Priority: P3
Component: preprocessor
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dfranke at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44526