From patchwork Sat Sep 2 11:01:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 809057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461339-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xByZIuLg"; dkim-atps=neutral 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 3xktTR3WcDz9ryv for ; Sat, 2 Sep 2017 21:01:29 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=iv12f067QUxigUeL BYL99M4kOM2HZapBjyi6BFCrHyNr84AYRsn496ojvr4B5ClCsfPtXqciPyseoIzl sNFF9xUZ0TRsZP3cbPD63Qk03So06YlKeTh6k7Lqy+vSxMbssn3MHG+nIzUw/vaR 9gX6Y+sAnPh/dhZ6X2Noi993pmA= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=2Ft957OC8TJA9PG+9DTG6/ q/OXQ=; b=xByZIuLgnuYPMDQvIE9MSCxrQIWd2vfx+57x09Zx9u/P5etipeUe6A kWDdCE38IxepHz6glSFHi+3GbUo7g9omw7InjE/GDdfFEsIaFlgG9XrGgrp8i7Mz rUPYoiUKMFbdW5tI806WPF5dYQfx+dPeIpERdJjXlKXzXEL4jMdjM= Received: (qmail 9517 invoked by alias); 2 Sep 2017 11:01:22 -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 9505 invoked by uid 89); 2 Sep 2017 11:01:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:ebotcaz, U*ebotcazou X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 02 Sep 2017 11:01:15 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 5D9AC82272 for ; Sat, 2 Sep 2017 13:01:12 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IryuAp5mLSe5 for ; Sat, 2 Sep 2017 13:01:12 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 2EDD982267 for ; Sat, 2 Sep 2017 13:01:12 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [C++] Fix PR bootstrap/81926 Date: Sat, 02 Sep 2017 13:01:11 +0200 Message-ID: <4078981.6jQ9KEkrUD@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Hi, this is the bootstrap failure reported for the 7 branch on SPARC64/Solaris: Comparing stages 2 and 3 Bootstrap comparison failure! gcc/go/parse.o differs make[2]: *** [compare] Error 1 On Solaris, the bootstrap is usually an old-style bootstrap, meaning that the debug info is generated during stage2 & stage3 so the comparison also involves the debug info, unlike on Linux. This can be emulated on Linux by configuring --with-build-config=no and indeed you get the comparison failure there too: Target: x86_64-suse-linux Configured with: /home/eric/svn/gcc-7.2.0/configure --build=x86_64-suse-linux --prefix=/home/eric/install/gcc-7.2.0 --enable-languages=c,c++,go --enable- __cxa_atexit --disable-nls --with-build-config=no Thread model: posix gcc version 7.2.0 (GCC) make[3]: Leaving directory '/home/eric/build/gcc-7.2.0' Comparing stages 2 and 3 Bootstrap comparison failure! gcc/go/parse.o differs Makefile:24421: recipe for target 'compare' failed make[2]: *** [compare] Error 1 The difference is: 35 .debug_info 0016367a 0000000000000000 0000000000000000 0001faf8 2**0 CONTENTS, RELOC, READONLY, DEBUGGING 35 .debug_info 00163670 0000000000000000 0000000000000000 0001faf8 2**0 CONTENTS, RELOC, READONLY, DEBUGGING .byte 0 ! end of children of DIE 0x161dbc .byte 0 ! end of children of DIE 0x161d9c .byte 0 ! end of children of DIE 0x161d5b - .byte 0xf2,0x1 ! uleb128 0xf2; (DIE (0x161dd2) DW_TAG_ptr_to_member_type) - .uaword 0x10445d ! DW_AT_containing_type - .uaword 0x14806e ! DW_AT_type - .byte 0xa5,0x1 ! uleb128 0xa5; (DIE (0x161ddc) DW_TAG_subprogram) + .byte 0xa5,0x1 ! uleb128 0xa5; (DIE (0x161dd2) DW_TAG_subprogram) .uaword 0x146733 ! DW_AT_abstract_origin It's a garbage collection issue similar to https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00541.html but for build_offset_type instead of build_complex_type. It's called from the get_debug_type langhook in C++: tree cp_get_debug_type (const_tree type) { if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type)) return build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type), TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type))); return NULL_TREE; } Since the OFFSET_TYPEs created there are not attached to any GC root, they are swept by every collection, meaning that the contents of the debug info depends on the actual collection points. The proposed fix is to build OFFSET_TYPEs manually instead. As witnessed by the change to g++.dg/debug/dwarf2/ref-3.C, this generates more DIEs in the debug info, but DW_TAG_ptr_to_member_type DIEs only contain 10 bytes. Bootstrapped on x86-64/Linux & SPARC64/Solaris, OK for mainline and 7 branch? 2017-09-02 Eric Botcazou PR bootstrap/81926 * cp-objcp-common.c: Include stor-layout.h. (cp_get_debug_type): Build OFFSET_TYPEs manually. 2017-09-02 Eric Botcazou * g++.dg/debug/dwarf2/ref-3.C: Adjust DW_TAG_ptr_to_member_type count. Index: cp/cp-objcp-common.c =================================================================== --- cp/cp-objcp-common.c (revision 251553) +++ cp/cp-objcp-common.c (working copy) @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. #include "coretypes.h" #include "cp-tree.h" #include "cp-objcp-common.h" +#include "stor-layout.h" #include "dwarf2.h" /* Special routine to get the alias set for C++. */ @@ -138,8 +139,20 @@ tree cp_get_debug_type (const_tree type) { if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type)) - return build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type), - TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type))); + { + /* We cannot call build_offset_type here because the function uses the + type canonicalization hashtable, which is GC-ed, so its behavior + depends on the actual collection points. Since we are building these + types on the fly for the debug info, they are not attached to any + GC root and will always be swept, so we would make the contents of + the debug info depend on the collection points. */ + tree t = make_node (OFFSET_TYPE); + TYPE_OFFSET_BASETYPE (t) + = TYPE_MAIN_VARIANT (TYPE_PTRMEMFUNC_OBJECT_TYPE (type)); + TREE_TYPE (t) = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type)); + layout_type (t); + return t; + } return NULL_TREE; } Index: testsuite/g++.dg/debug/dwarf2/ref-3.C =================================================================== --- testsuite/g++.dg/debug/dwarf2/ref-3.C (revision 251553) +++ testsuite/g++.dg/debug/dwarf2/ref-3.C (working copy) @@ -3,7 +3,7 @@ // { dg-final { scan-assembler-times " DW_AT_reference" 5 { xfail *-*-aix* } } } // { dg-final { scan-assembler-times " DW_AT_rvalue_reference" 5 { xfail *-*-aix* } } } // { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_subroutine_type" 6 { xfail *-*-aix* } } } -// { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_ptr_to_member_type" 7 { xfail *-*-aix* } } } +// { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_ptr_to_member_type" 13 { xfail *-*-aix* } } } // { dg-final { scan-assembler-times " DW_AT_use_location" 1 { xfail *-*-aix* } } } struct S