Commit 4a01f7b1 by Iain Buclaw

d: Fix missing dependencies in depfile for imported files (PR93038)

A new field for tracking imported files was added to the front-end, this
makes use of it by writing all such files in the make dependency list.

gcc/d/ChangeLog:

2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>

	PR d/93038
	* d-lang.cc (deps_write): Add content imported files to the make
	dependency list.

gcc/testsuite/ChangeLog:

2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>

	PR d/93038
	* gdc.dg/fileimports/pr93038.txt: New test.
	* gdc.dg/pr93038.d: New test.
parent 424e3908
2020-03-22 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/93038
* d-lang.cc (deps_write): Add content imported files to the make
dependency list.
2020-03-21 Iain Buclaw <ibuclaw@gdcproject.org> 2020-03-21 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/94240 PR d/94240
......
...@@ -151,7 +151,8 @@ deps_add_target (const char *target, bool quoted) ...@@ -151,7 +151,8 @@ deps_add_target (const char *target, bool quoted)
static void static void
deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72) deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72)
{ {
hash_set <const char *> dependencies; hash_set <const char *> seen_modules;
vec <const char *> dependencies = vNULL;
Modules modlist; Modules modlist;
modlist.push (module); modlist.push (module);
...@@ -179,38 +180,28 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72) ...@@ -179,38 +180,28 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72)
buffer->writestring (":"); buffer->writestring (":");
column++; column++;
/* Write out all make dependencies. */ /* Search all modules for file dependencies. */
while (modlist.dim > 0) while (modlist.dim > 0)
{ {
Module *depmod = modlist.pop (); Module *depmod = modlist.pop ();
str = depmod->srcfile->name->str; str = depmod->srcfile->name->str;
size = strlen (str);
/* Skip dependencies that have already been written. */ /* Skip modules that have already been looked at. */
if (dependencies.add (str)) if (seen_modules.add (str))
continue; continue;
column += size; dependencies.safe_push (str);
if (colmax && column > colmax)
{
buffer->writestring (" \\\n ");
column = size + 1;
}
else
{
buffer->writestring (" ");
column++;
}
buffer->writestring (str);
/* Add to list of phony targets if is not being compile. */ /* Add to list of phony targets if is not being compile. */
if (d_option.deps_phony && !depmod->isRoot ()) if (d_option.deps_phony && !depmod->isRoot ())
phonylist.push (depmod); phonylist.push (depmod);
/* Search all imports of the written dependency. */ /* Add imported files to dependency list. */
for (size_t i = 0; i < depmod->contentImportedFiles.dim; i++)
dependencies.safe_push (depmod->contentImportedFiles[i]);
/* Search all imports of the module. */
for (size_t i = 0; i < depmod->aimports.dim; i++) for (size_t i = 0; i < depmod->aimports.dim; i++)
{ {
Module *m = depmod->aimports[i]; Module *m = depmod->aimports[i];
...@@ -244,6 +235,27 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72) ...@@ -244,6 +235,27 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72)
} }
} }
/* Write out all make dependencies. */
for (size_t i = 0; i < dependencies.length (); i++)
{
str = dependencies[i];
size = strlen (str);
column += size;
if (colmax && column > colmax)
{
buffer->writestring (" \\\n ");
column = size + 1;
}
else
{
buffer->writestring (" ");
column++;
}
buffer->writestring (str);
}
buffer->writenl (); buffer->writenl ();
/* Write out all phony targets. */ /* Write out all phony targets. */
......
2020-03-22 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/93038
* gdc.dg/fileimports/pr93038.txt: New test.
* gdc.dg/pr93038.d: New test.
2020-03-21 Patrick Palka <ppalka@redhat.com> 2020-03-21 Patrick Palka <ppalka@redhat.com>
PR c++/94066 PR c++/94066
......
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93038
// { dg-options "-J $srcdir/gdc.dg/fileimports -MMD" }
// { dg-do compile }
// { dg-final { scan-file pr93038.deps "pr93038.o: \[^\n\]*/pr93038.d \[ \\\\\n\]*\[^\n\]*/fileimports/pr93038.txt" } }
// { dg-final { file delete pr93038.deps } }
module pr93038;
const VERSION = import("pr93038.txt");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment