From patchwork Sun Mar 22 12:26:42 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: 1259642 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=S89JEL/f; 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 48lcG21yHdz9sSr for ; Sun, 22 Mar 2020 23:27:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54AA0387605A; Sun, 22 Mar 2020 12:26:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54AA0387605A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584880019; bh=6katIaNV5la78eArB6Qw9vSH6auFYOr0qIDIYOJhElU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=S89JEL/f0qQi8jTJUgWHEHWEwXhanJBY6/EJ2bFz9Q0sM+uVMiiMsJlLdfXrXq1M0 lvyvqgAPhvtDxk/THGDy3nZfjXcYTciRgqABRzSBuOQ63fSDGwg1S9vD33tf+NQxbU ISptv5OqmKTwulAIeGJaF6gwaAlJP2VD0XGD4tRM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [IPv6:2001:67c:2050:1::465:107]) by sourceware.org (Postfix) with ESMTPS id 09DB9385BF86 for ; Sun, 22 Mar 2020 12:26:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 09DB9385BF86 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 48lcFp2KwVzKp99; Sun, 22 Mar 2020 13:26:54 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id Ce2FomV9MExW; Sun, 22 Mar 2020 13:26:50 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Generate phony targets for content imported files (PR93038) Date: Sun, 22 Mar 2020 13:26:42 +0100 Message-Id: <20200322122642.26987-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Spam-Status: No, score=-30.7 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, This patch is an addition to the last change, which started including content imported files in the make dependency list. Now phony targets are also written out if -MP is given. Bootstrapped and regression tested on x86_64-linux-gnu. Committed to trunk. Regards Iain. --- gcc/d/ChangeLog: 2020-03-22 Iain Buclaw PR d/93038 * d-lang.cc (deps_write): Generate phony targets for content imported files. gcc/testsuite/ChangeLog: 2020-03-22 Iain Buclaw PR d/93038 * gdc.dg/pr93038b.d: New test. --- gcc/d/d-lang.cc | 39 +++++++++++++++------------------ gcc/testsuite/gdc.dg/pr93038b.d | 8 +++++++ 2 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 gcc/testsuite/gdc.dg/pr93038b.d 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 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/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");