From patchwork Fri Jun 10 15:47:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 99932 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 B2F12B702E for ; Sat, 11 Jun 2011 01:47:53 +1000 (EST) Received: (qmail 29887 invoked by alias); 10 Jun 2011 15:47:52 -0000 Received: (qmail 29873 invoked by uid 22791); 10 Jun 2011 15:47:51 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Jun 2011 15:47:37 +0000 Received: from hpaq2.eem.corp.google.com (hpaq2.eem.corp.google.com [172.25.149.2]) by smtp-out.google.com with ESMTP id p5AFlZEG008401 for ; Fri, 10 Jun 2011 08:47:35 -0700 Received: from gxk22 (gxk22.prod.google.com [10.202.11.22]) by hpaq2.eem.corp.google.com with ESMTP id p5AFkq7A008003 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Fri, 10 Jun 2011 08:47:34 -0700 Received: by gxk22 with SMTP id 22so2458855gxk.2 for ; Fri, 10 Jun 2011 08:47:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.160.4 with SMTP id i4mr2874664ybe.241.1307720854086; Fri, 10 Jun 2011 08:47:34 -0700 (PDT) Received: by 10.151.142.15 with HTTP; Fri, 10 Jun 2011 08:47:34 -0700 (PDT) In-Reply-To: <20110609184955.794601DA1CD@topo.tor.corp.google.com> References: <20110609184955.794601DA1CD@topo.tor.corp.google.com> Date: Fri, 10 Jun 2011 08:47:34 -0700 Message-ID: Subject: Re: [pph] Do not emit PCH if generating PPH (issue4591061) From: Diego Novillo To: reply@codereview.appspotmail.com, Gabriel Charette , Lawrence Crowl , gcc-patches@gcc.gnu.org X-System-Of-Record: true 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 On Thu, Jun 9, 2011 at 11:49, Diego Novillo wrote: > > We were trying to generate PCH and PPH information at the same time. > We never noticed because PPH is generated after PCH, so we were just > clobbering over the previous dump. > > Found it by accident while debugging a GC ICE.  This should make > testing slightly faster. > > Committed to the branch. This version had problems and it was still abusing the PCH options from specs. The problem is that when compiling header files separately, the compiler assumes that we want to generate PCH files. In the long term, I think we will want to replace PCH with PPH, but until then I'm adding a new flag -fpph-gen to distinguish the PCH from the PPH generation. So, when compiling a header file, if you want a PPH image, you need to: $ gcc -fpph-gen foo.h This generate foo.pph instead of foo.gch. The new patch also adds documentation on the three user-facing flags used for pph. Tested on x86_64. Diego. Index: gcc/c-family/c-opts.c diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index e52583e..8fe566e 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -368,13 +368,11 @@ c_common_handle_option (size_t scode, const char *arg, int value, break; case OPT__output_pch_: - { - char *dot = strrchr (arg, '.'); - if (dot != NULL && strcmp (dot, ".pph") == 0) - pph_out_file = arg; - else - pch_file = arg; - } + pch_file = arg; + break; + + case OPT__output_pph_: + pph_out_file = arg; break; case OPT_A: Index: gcc/c-family/c.opt diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 67708b8..bdc0fc9 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -139,6 +139,9 @@ C ObjC C++ ObjC++ Joined Alias(o) -output-pch= C ObjC C++ ObjC++ Joined Separate +-output-pph= +C++ Joined Separate + -pedantic C ObjC C++ ObjC++ Alias(pedantic) @@ -933,8 +936,12 @@ fpph-dump-tree C++ Var(flag_pph_dump_tree) -fpph-dump-tree Dump global namespace tree around PPH reads/writes. +fpph-gen +C++ +-fpph-gen Generate a PPH image from the input file + fpph-hdr= -C++ ObjC++ Joined MissingArgError(missing filename after %qs) +C++ Joined MissingArgError(missing filename after %qs) -fpph-hdr= A mapping from .h to .pph fpph-logfile= @@ -942,7 +949,7 @@ C++ Joined RejectNegative Var(flag_pph_logfile) -fpph-logfile= Emit PPH debug information to fpph-map= -C++ ObjC++ Joined MissingArgError(missing filename after %qs) +C++ Joined MissingArgError(missing filename after %qs) -fpph-map= A file of mappings from #include to PPH file fpph-tracer= Index: gcc/cp/lang-specs.h diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h index a73aba3..ef03a39 100644 --- a/gcc/cp/lang-specs.h +++ b/gcc/cp/lang-specs.h @@ -48,8 +48,9 @@ along with GCC; see the file COPYING3. If not see cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}\ %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ %(cc1_options) %2\ - %{!fsyntax-only:%{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\ - %W{o*:--output-pch=%*}}%V}}}}", + %{!fpph-gen:%{!fsyntax-only:%{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\ + %W{o*:--output-pch=%*}}}} \ + %{fpph-gen:%{!o*:--output-pph=%b.pph}%W{o*:--output-pph=%*}}%V}}}", CPLUSPLUS_CPP_SPEC, 0, 0}, {"@c++", "%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)}\ Index: gcc/doc/invoke.texi diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 6207800..524471a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -195,6 +195,7 @@ in the following sections. -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol -fno-default-inline -fvisibility-inlines-hidden @gol -fvisibility-ms-compat @gol +-fpph-hdr -fpph-map -fpph-gen @gol -Wabi -Wconversion-null -Wctor-dtor-privacy @gol -Wnoexcept -Wnon-virtual-dtor -Wreorder @gol -Weffc++ -Wstrict-null-sentinel @gol @@ -2171,6 +2172,42 @@ option exists only for testing, and should not be used by end-users; it will result in inferior code and has no benefits. This option may be removed in a future release of G++. +@item -fpph-gen +@opindex fpph-gen +Generate a Pre-Parsed Header (PPH) file instead of a PCH file. This option +is only valid when compiling header files separately. Instead of generating +a PCH files, G++ will save the parsed declarations in a header file to +a PPH file. By default, the PPH image for a header file named @file{foo.h} +is @file{foo.pph}. + +NOTE: This option is temporary. It is only meant to serve the initial +implementation of this feature. The final user interface will likely +use a different mechanism for PPH. + +@item -fpph-map=@var{file.map} +@opindex fpph-map +Use PPH mapping file @file{file.map} to determine what headers should be +processed from their PPH images. This file contains a list of file name +pairs in the form ``@var{file.h} @var{file.pph}''. When the pre-processor +finds the directive @code{#include "file.h"}, and there exists a mapping +between @var{file.h} and @var{file.pph} in @file{file.map}, then the +compiler will instantiate the PPH image @var{file.pph}. The text +in @var{file.h} will be ignored. + +NOTE: This option is temporary. It is only meant to serve the initial +implementation of this feature. The final user interface will likely +use a different mechanism for PPH. + +@item -fpph-hdr=@var{file.h} +@opindex fpph-hdr +This is a short-hand notation to map a single header @file{file.h} to +its image @file{file.pph}. Multiple occurrences of this flag will +introduce multiple mappings. + +NOTE: This option is temporary. It is only meant to serve the initial +implementation of this feature. The final user interface will likely +use a different mechanism for PPH. + @item -nostdinc++ @opindex nostdinc++ Do not search for header files in the standard directories specific to Index: gcc/testsuite/lib/dg-pph.exp diff --git a/gcc/testsuite/lib/dg-pph.exp b/gcc/testsuite/lib/dg-pph.exp index 2058959..c773aa0 100644 --- a/gcc/testsuite/lib/dg-pph.exp +++ b/gcc/testsuite/lib/dg-pph.exp @@ -33,7 +33,7 @@ proc dg-pph-hdr { subdir test options mapflag suffix } { verbose -log "\nTesting $nshort, $options" set dg-do-what-default preparse - dg-test -keep-output $test "$options $mapflag -I." "" + dg-test -keep-output $test "-fpph-gen $options $mapflag -I." "" } @@ -51,7 +51,7 @@ proc dg-pph-neg { subdir test options mapflag suffix } { verbose -log "\nTesting $nshort, $options" set dg-do-what-default compile - dg-test -keep-output $test "$options $mapflag -I." "" + dg-test -keep-output $test "-fpph-gen $options $mapflag -I." "" if { ![file_on_host exists "$bname.s"] } { file_on_host delete "$bname.s" }