public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Michael Meissner <meissner@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/meissner/heads/ieee)] d: Fix missing dependencies in depfile for imported files (PR93038) Date: Thu, 16 Apr 2020 22:33:39 +0000 (GMT) [thread overview] Message-ID: <20200416223339.1FFE6385DC1C@sourceware.org> (raw) https://gcc.gnu.org/g:4a01f7b1e73e98a86520d8a825ddd3777faa7c33 commit 4a01f7b1e73e98a86520d8a825ddd3777faa7c33 Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Sun Mar 22 00:10:17 2020 +0100 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. Diff: --- gcc/d/ChangeLog | 6 ++++ gcc/d/d-lang.cc | 52 +++++++++++++++++----------- gcc/testsuite/ChangeLog | 6 ++++ gcc/testsuite/gdc.dg/fileimports/pr93038.txt | 1 + gcc/testsuite/gdc.dg/pr93038.d | 8 +++++ 5 files changed, 53 insertions(+), 20 deletions(-) diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index 31c9c4b3a20..916319f6bf7 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): Add content imported files to the make + dependency list. + 2020-03-21 Iain Buclaw <ibuclaw@gdcproject.org> PR d/94240 diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index 3f50b5f1104..514799d8e89 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -151,7 +151,8 @@ deps_add_target (const char *target, bool quoted) static void 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; modlist.push (module); @@ -179,38 +180,28 @@ deps_write (Module *module, OutBuffer *buffer, unsigned colmax = 72) buffer->writestring (":"); column++; - /* Write out all make dependencies. */ + /* Search all modules for file dependencies. */ while (modlist.dim > 0) { Module *depmod = modlist.pop (); str = depmod->srcfile->name->str; - size = strlen (str); - /* Skip dependencies that have already been written. */ - if (dependencies.add (str)) + /* Skip modules that have already been looked at. */ + if (seen_modules.add (str)) continue; - column += size; - - if (colmax && column > colmax) - { - buffer->writestring (" \\\n "); - column = size + 1; - } - else - { - buffer->writestring (" "); - column++; - } - - buffer->writestring (str); + dependencies.safe_push (str); /* Add to list of phony targets if is not being compile. */ if (d_option.deps_phony && !depmod->isRoot ()) 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++) { Module *m = depmod->aimports[i]; @@ -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 (); /* Write out all phony targets. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ff8b693644..c8701caaf6f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +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> PR c++/94066 diff --git a/gcc/testsuite/gdc.dg/fileimports/pr93038.txt b/gcc/testsuite/gdc.dg/fileimports/pr93038.txt new file mode 100644 index 00000000000..9d1dc810c95 --- /dev/null +++ b/gcc/testsuite/gdc.dg/fileimports/pr93038.txt @@ -0,0 +1 @@ +v2.091.0 diff --git a/gcc/testsuite/gdc.dg/pr93038.d b/gcc/testsuite/gdc.dg/pr93038.d new file mode 100644 index 00000000000..4e09690a473 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr93038.d @@ -0,0 +1,8 @@ +// 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");
reply other threads:[~2020-04-16 22:33 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200416223339.1FFE6385DC1C@sourceware.org \ --to=meissner@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).