From patchwork Thu Feb 19 18:33:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 441722 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 951081400A0 for ; Fri, 20 Feb 2015 05:33:32 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=cyiA8cesMjhwIbkTP XSVCOnDTuFxJCOUFaBphXW6G+XbpAUDExo38kEkZ3AQUl84Tzbnw4MHeAoOkVgAc xHWCzPEz5Cj81cCeqfX0B5NldaBNfq4YvN2TGRnu8BOfvp7MkBh5h551beMR/hob CGxzx3HetiYKMieSZgMkxKSTOE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=CRMdrPMwPxopO7W9uh2V7yr 20rI=; b=Nf9NnU4fA5aVcZPckQHJYn730p0X7ke3byP+8p8qn87sL/NU4YZNwHC QpDQVOojLhaJTyhcNhLNrZNSxzsz0xBFq9E3gr992r2KAS6Ui/HH3eaWTIpI1jm9 NFi3DKFAHTmM8WiSKa3H4OVxxd9XHRF7EDof4H2sZYpKXRmXDkIA= Received: (qmail 1612 invoked by alias); 19 Feb 2015 18:33:25 -0000 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 Received: (qmail 1596 invoked by uid 89); 19 Feb 2015 18:33:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 19 Feb 2015 18:33:23 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1JIXMmj023488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 19 Feb 2015 13:33:22 -0500 Received: from reynosa.quesejoda.com (vpn-61-7.rdu2.redhat.com [10.10.61.7]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1JIXKqi029780; Thu, 19 Feb 2015 13:33:21 -0500 Message-ID: <54E62C70.8020208@redhat.com> Date: Thu, 19 Feb 2015 10:33:20 -0800 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Jakub Jelinek CC: jason merrill , gcc-patches Subject: Re: [patch] PR debug/46102 Disable -feliminate-dwarf2-dups when reading a PCH References: <54E6129C.5060706@redhat.com> <54E61314.9070805@redhat.com> <20150219165052.GK1746@tucnak.redhat.com> In-Reply-To: <20150219165052.GK1746@tucnak.redhat.com> On 02/19/2015 08:50 AM, Jakub Jelinek wrote: > On Thu, Feb 19, 2015 at 08:45:08AM -0800, Aldy Hernandez wrote: >> [And this time, actually CCing the list :)]. >> >> Gentlemen! >> >> Reading in the compiler state for pch (gt_pch_restore) obliterates the >> DIE table, and consequently the DW_TAG_GNU_[BE]INCL* DIEs that may have >> been in it. This causes inconsistencies when reading in _any_ >> pre-compiled header into a source file that uses >> -feliminate-dwarf2-dups, and consequently already has some >> DW_TAG_GNU_[BE]INCL* DIEs. >> >> Normally the DIE table should be empty this early on, especially since >> mainline generates dwarf at the end of the compilation unit, but the DIE >> table may have DW_TAG_GNU_[BE]INCL* DIEs that were created early by >> dwarf2out_start_source_file/etc or it may have the DW_TAG_compile_unit. >> >> I suppose we could merge incoming DIEs with existing DIEs and complicate >> our lives, but considering we will probably have to tackle this in the >> debug-early work, I propose we disable this combination for now (and >> possibly permanently, unless we really care about it). >> >> OK for mainline pending tests? > > Wouldn't it be better to disable PCH reading if -feliminate-dwarf2-dups > is used? I mean, fail to read the PCH silently (or with warning for -Wpch > or what the warning is about why PCH couldn't be read or was ignored), Sure, that sounds reasonable. Patch attached. > perhaps error out if you try to generate PCH with -feliminate-dwarf2-dups? Well, any PCH file we generate will have some sort of early DIE in it (at the very least the compilation unit DIE) and we will read these in at PCH read-in time, obliterating whatever was already there. But most importantly, with the attached patch we will not use these DW_TAG_GNU_[BE]INCL* DIEs, since the reader will avoid reading the pch file. So, I don't think erroring out at output time is necessary. How does this look? commit d90a408ad21aa0868cc13de24ea38e210ef78a68 Author: Aldy Hernandez Date: Thu Feb 19 07:35:59 2015 -0800 PR debug/46102 * c-pch.c (c_common_valid_pch): Mark PCH file with -feliminate-dwarf2-dups as invalid. diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c index 0ede92a..55163c9 100644 --- a/gcc/c-family/c-pch.c +++ b/gcc/c-family/c-pch.c @@ -224,6 +224,19 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) const char *pch_ident; struct c_pch_validity v; + /* We may have outputted a few DIEs corresponding to + DW_TAG_GNU_[BE]INCL. Reading the compiler state later will read + in these DIEs, and obliterate any DW_TAG_GNU_[BE]INCL the reader + may have generated itself. Do not read the PCH if this may + happen. */ + if (flag_eliminate_dwarf2_dups) + { + if (cpp_get_options (pfile)->warn_invalid_pch) + cpp_error (pfile, CPP_DL_WARNING, + "%s: cannot be used with -feliminate-dwarf2-dups", name); + return 2; + } + /* Perform a quick test of whether this is a valid precompiled header for the current language. */