From patchwork Sat Mar 21 23:15:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1259559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=cdWaDBGo; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48lGjC6hLFz9sPJ for ; Sun, 22 Mar 2020 10:15:57 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DF7C3877024; Sat, 21 Mar 2020 23:15:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DF7C3877024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584832554; bh=gNJLavIk8tkmhTwqAmEFK00J8zVauPoLFiFe/0QC1q0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=cdWaDBGo0dkyLhWSRxYCPd9KNSqJ+f3c4Go0jQDhyipgdtIywhD7GebfZ/P/koV3P to5E+LMoMMKXLtajTm3Kqg4CGAycUAxGSjAi6cHShlWLSliSBrhvl4yGFpojw0B2ct k52yO8BGgK4DaqdLqSWULnGdlTA5Jd6Hm1PSHvxA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) by sourceware.org (Postfix) with ESMTPS id 3B3263877010 for ; Sat, 21 Mar 2020 23:15:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3B3263877010 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 48lGj10D3lzQkKl; Sun, 22 Mar 2020 00:15:49 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id 0FKEKFBsBJso; Sun, 22 Mar 2020 00:15:45 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] d: Fix missing dependencies in depfile for imported files (PR93038) Date: Sun, 22 Mar 2020 00:15:03 +0100 Message-Id: <20200321231503.30854-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Spam-Status: No, score=-31.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, 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, fixing PR 93038. Bootstrapped and tested on x86_64-linux-gnu, and committed to trunk. Regards Iain. --- gcc/d/ChangeLog: 2020-03-22 Iain Buclaw 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 PR d/93038 * gdc.dg/fileimports/pr93038.txt: New test. * gdc.dg/pr93038.d: New test. --- gcc/d/d-lang.cc | 52 ++++++++++++-------- gcc/testsuite/gdc.dg/fileimports/pr93038.txt | 1 + gcc/testsuite/gdc.dg/pr93038.d | 8 +++ 3 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 gcc/testsuite/gdc.dg/fileimports/pr93038.txt create mode 100644 gcc/testsuite/gdc.dg/pr93038.d 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 dependencies; + hash_set seen_modules; + vec 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/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");