From patchwork Fri Jan 27 20:28:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 138283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 8D956B6EE8 for ; Sat, 28 Jan 2012 07:29:15 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1328300956; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=7T+YwbD D1s2TR6BLzdtu7i1V4UE=; b=FSCb7iSK/ioySJlmCOxSp4SdaqiRJLPCUR7uVe4 Jj9Q+iHgDQduyhleQWWb87wg+i2KPZSY7tRLp7CZNdnQ8zI1tf2wycj7ab20ZMsp dPIJZljwkSsCgoc8PZsYB7owVtKTm3itWBUsy/GLri9fVmuQzArN+yTMkUrUrbKo BGb4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=YfHxO2HqA5A91RI4b4x6f9ZeGDE3n4B0CHRlzM5M2hTROAixl7HTDICiCSaIEr 8B3eoTYMp6PURkhiYp+7BTmBlkmhTmIrtV55zXD4lexgob+LWvRzU65ImS+eREFl z5y9Mdg4GXxb1mL98LMxaBrxwLj8Nyti9VKcQMZyfCeSw=; Received: (qmail 15319 invoked by alias); 27 Jan 2012 20:29:13 -0000 Received: (qmail 15305 invoked by uid 22791); 27 Jan 2012 20:29:12 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-yw0-f73.google.com (HELO mail-yw0-f73.google.com) (209.85.213.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Jan 2012 20:28:59 +0000 Received: by yhnn55 with SMTP id n55so198706yhn.2 for ; Fri, 27 Jan 2012 12:28:58 -0800 (PST) Received: by 10.236.136.106 with SMTP id v70mr13031709yhi.0.1327696138823; Fri, 27 Jan 2012 12:28:58 -0800 (PST) Received: by 10.236.136.106 with SMTP id v70mr13031694yhi.0.1327696138752; Fri, 27 Jan 2012 12:28:58 -0800 (PST) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id a9si3852843anh.1.2012.01.27.12.28.58 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 27 Jan 2012 12:28:58 -0800 (PST) Received: from tobiano.tor.corp.google.com (tobiano.tor.corp.google.com [172.29.41.6]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id A56FA10004D; Fri, 27 Jan 2012 12:28:58 -0800 (PST) Received: by tobiano.tor.corp.google.com (Postfix, from userid 54752) id D3241AE1D8; Fri, 27 Jan 2012 15:28:57 -0500 (EST) To: reply@codereview.appspotmail.com, crowl@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Add support for disabling PPH input (issue5593043) Message-Id: <20120127202857.D3241AE1D8@tobiano.tor.corp.google.com> Date: Fri, 27 Jan 2012 15:28:57 -0500 (EST) From: dnovillo@google.com (Diego Novillo) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch adds support for disabling PPH reads. It uses the new support to disable PPH reading when we disable PPH writing. This is to avoid confusion in the PPH registration code that will have some stale content after the output file has been removed. Lawrence suggests that we should just fail hard when we cannot generate a PPH image. We are currently only emitting a warning. I think I will just rip out this support in the near future. For now, it was easier to just disable the reader. For now, I'm leaving it in just in case we have another need for this. 2012-01-27 Diego Novillo c-family/ChangeLog.pph * c-common.h (pph_disable_reader): Declare. * c-opts.c (pph_disable_reader): New. cp/ChangeLog.pph * pph-core.c (pph_include_handler): If PPH has been disabled, process the file as a regular text include. * pph-out.c (pph_disable_output): Also disable the reader. --- This patch is available for review at http://codereview.appspot.com/5593043 diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index f8813c1..315e99e 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -590,6 +590,11 @@ extern const char *pph_out_file; extern bool pph_reader_enabled_p (void); +/* Disable the PPH reader. */ + +extern void +pph_disable_reader (void); + /* Query for a mapping from an INCLUDE to a PPH file. Return the filename, without ownership. If there is no mapping, return null. */ diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 0ad27e2..ab71678 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -140,6 +140,18 @@ pph_reader_enabled_p (void) return include_pph_mapping != NULL; } + +/* Disable PPH reading. After this function is called, all subsequent + #include commands will be processed as textual includes. */ + +void +pph_disable_reader (void) +{ + strstrmap_destroy (include_pph_mapping); + include_pph_mapping = NULL; +} + + /* Add mappings from include directive to PPH files found within file FILENAME. The file is a sequence of lines. Each line contains the directive, followed by a tab, diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index 5f6c27f..760d065 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -784,6 +784,11 @@ pph_include_handler (cpp_reader *reader, fprintf (pph_logfile, "%c\n", angle_brackets ? '>' : '"'); } + /* If PPH has been disabled, process the #include as a regular + text include. */ + if (!pph_enabled_p ()) + return true; + /* If we find a #include_next directive in the primary file, refuse to generate a PPH image for it. #include_next cannot be resolved from the primary source file, so generating an diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c index 31620e3..a1ce886 100644 --- a/gcc/cp/pph-out.c +++ b/gcc/cp/pph-out.c @@ -2854,6 +2854,11 @@ pph_disable_output (void) pph_stream_close_no_flush (pph_out_stream); pph_out_file = NULL; pph_out_stream = NULL; + + /* Also disable the reader. We are not generating a PPH image anymore, + so it makes no sense to keep reading images. FIXME pph, instead + of disabling PPH generation we may want to simply abort compilation. */ + pph_disable_reader (); } #include "gt-cp-pph-out.h"