public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] d: Generate phony targets for content imported files (PR93038)
@ 2020-03-30 11:01 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2020-03-30 11:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fbe60463bb80d859d4842f0113a6b24fe9cc9bd4

commit fbe60463bb80d859d4842f0113a6b24fe9cc9bd4
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Mar 22 13:11:10 2020 +0100

    d: Generate phony targets for content imported files (PR93038)
    
    This is in addition to the last change which started including them in
    the make dependency list.
    
    gcc/d/ChangeLog:
    
    2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>
    
            PR d/93038
            * d-lang.cc (deps_write): Generate phony targets for content imported
            files.
    
    gcc/testsuite/ChangeLog:
    
    2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>
    
            PR d/93038
            * gdc.dg/pr93038b.d: New test.

Diff:
---
 gcc/d/ChangeLog                 |  6 ++++++
 gcc/d/d-lang.cc                 | 39 ++++++++++++++++++---------------------
 gcc/testsuite/ChangeLog         |  5 +++++
 gcc/testsuite/gdc.dg/pr93038b.d |  8 ++++++++
 4 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 916319f6bf7..606f7f30eb0 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,9 @@
+2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/93038
+	* d-lang.cc (deps_write): Generate phony targets for content imported
+	files.
+
 2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	PR d/93038
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 514799d8e89..6848c5e9a1c 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -157,26 +157,21 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72)
   Modules modlist;
   modlist.push (module);
 
-  Modules phonylist;
-
-  const char *str;
-  unsigned size;
+  vec <const char *> phonylist = vNULL;
   unsigned column = 0;
 
   /* Write out make target module name.  */
   if (d_option.deps_target)
     {
-      size = d_option.deps_target->offset;
-      str = d_option.deps_target->extractString ();
+      buffer->writestring (d_option.deps_target->extractString ());
+      column = d_option.deps_target->offset;
     }
   else
     {
-      str = module->objfile->name->str;
-      size = strlen (str);
+      buffer->writestring (module->objfile->name->str);
+      column = buffer->offset;
     }
 
-  buffer->writestring (str);
-  column = size;
   buffer->writestring (":");
   column++;
 
@@ -185,21 +180,25 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72)
     {
       Module *depmod = modlist.pop ();
 
-      str = depmod->srcfile->name->str;
+      const char *modstr = depmod->srcfile->name->str;
 
       /* Skip modules that have already been looked at.  */
-      if (seen_modules.add (str))
+      if (seen_modules.add (modstr))
 	continue;
 
-      dependencies.safe_push (str);
+      dependencies.safe_push (modstr);
 
       /* Add to list of phony targets if is not being compile.  */
       if (d_option.deps_phony && !depmod->isRoot ())
-	phonylist.push (depmod);
+	phonylist.safe_push (modstr);
 
       /* Add imported files to dependency list.  */
       for (size_t i = 0; i < depmod->contentImportedFiles.dim; i++)
-	dependencies.safe_push (depmod->contentImportedFiles[i]);
+	{
+	  const char *impstr = depmod->contentImportedFiles[i];
+	  dependencies.safe_push (impstr);
+	  phonylist.safe_push (impstr);
+	}
 
       /* Search all imports of the module.  */
       for (size_t i = 0; i < depmod->aimports.dim; i++)
@@ -238,8 +237,8 @@ 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);
+      const char *str = dependencies[i];
+      unsigned size = strlen (str);
       column += size;
 
       if (colmax && column > colmax)
@@ -259,12 +258,10 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72)
   buffer->writenl ();
 
   /* Write out all phony targets.  */
-  for (size_t i = 0; i < phonylist.dim; i++)
+  for (size_t i = 0; i < phonylist.length (); i++)
     {
-      Module *m = phonylist[i];
-
       buffer->writenl ();
-      buffer->writestring (m->srcfile->name->str);
+      buffer->writestring (phonylist[i]);
       buffer->writestring (":\n");
     }
 }
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bd38b940a2d..892fcb654af 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-22  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/93038
+	* gdc.dg/pr93038b.d: New test.
+
 2020-03-22  Iain Sandoe  <iain@sandoe.co.uk>
 
 	* g++.dg/abi/lambda-vis.C: Amend assembler match
diff --git a/gcc/testsuite/gdc.dg/pr93038b.d b/gcc/testsuite/gdc.dg/pr93038b.d
new file mode 100644
index 00000000000..04177a7e01a
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr93038b.d
@@ -0,0 +1,8 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93038
+// { dg-options "-J $srcdir/gdc.dg/fileimports -MMD -MP" }
+// { dg-do compile }
+// { dg-final { scan-file pr93038b.deps "pr93038b.o: \[^\n\]*/pr93038b.d \[ \\\\\n\]*\[^\n\]*/fileimports/pr93038.txt\n\n\[^\n\]*/fileimports/pr93038.txt:" } }
+// { dg-final { file delete pr93038b.deps } }
+module pr93038b;
+
+const VERSION = import("pr93038.txt");


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-30 11:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 11:01 [gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] d: Generate phony targets for content imported files (PR93038) Martin Liska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).