From patchwork Sun Oct 3 20:05:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: FX Coudert X-Patchwork-Id: 66604 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 6342CB70AF for ; Mon, 4 Oct 2010 07:06:03 +1100 (EST) Received: (qmail 14396 invoked by alias); 3 Oct 2010 20:05:59 -0000 Received: (qmail 14368 invoked by uid 22791); 3 Oct 2010 20:05:54 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 03 Oct 2010 20:05:47 +0000 Received: by wwb28 with SMTP id 28so5545503wwb.8 for ; Sun, 03 Oct 2010 13:05:44 -0700 (PDT) Received: by 10.216.71.132 with SMTP id r4mr4402062wed.102.1286136344524; Sun, 03 Oct 2010 13:05:44 -0700 (PDT) Received: from [192.168.0.101] (chufi.coudert.name [88.162.139.106]) by mx.google.com with ESMTPS id n40sm2450107weq.29.2010.10.03.13.05.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 03 Oct 2010 13:05:43 -0700 (PDT) Subject: Re: [patch] Add DW_AT_main_subprogram tag to Fortran main program Mime-Version: 1.0 (Apple Message framework v1081) From: FX In-Reply-To: <20101003131611.GA10466@tyan-ft48-01.lab.bos.redhat.com> Date: Sun, 3 Oct 2010 22:05:40 +0200 Cc: gcc-patches@gcc.gnu.org, gfortran List Message-Id: References: <28A1527A-518A-40C8-9DC8-A86FEFC8D067@gmail.com> <20101003131611.GA10466@tyan-ft48-01.lab.bos.redhat.com> To: Jakub Jelinek 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 > + add_AT_flag (subr_die, DW_AT_main_subprogram, 1); > > should be guarded by > if (dwarf_version >= 4 || !dwarf_strict) Updated patch below, against regtested on x86_64-linux. OK to commit? FX 2010-10-03 Francois-Xavier Coudert * dwarf2out.c (add_calling_convention_attribute): Flag main Fortran subroutine with DW_AT_main_subprogram. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 164914) +++ gcc/dwarf2out.c (working copy) @@ -17841,14 +17841,21 @@ add_calling_convention_attribute (dw_die value = ((enum dwarf_calling_convention) targetm.dwarf_calling_convention (TREE_TYPE (decl))); - /* DWARF doesn't provide a way to identify a program's source-level - entry point. DW_AT_calling_convention attributes are only meant - to describe functions' calling conventions. However, lacking a - better way to signal the Fortran main program, we use this for the - time being, following existing custom. */ if (is_fortran () && !strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), "MAIN__")) - value = DW_CC_program; + { + /* DWARF 2 doesn't provide a way to identify a program's source-level + entry point. DW_AT_calling_convention attributes are only meant + to describe functions' calling conventions. However, lacking a + better way to signal the Fortran main program, we used this for + a long time, following existing custom. Now, DWARF 4 has + DW_AT_main_subprogram, which we add below, but some tools still + rely on the old way, which we thus keep. */ + value = DW_CC_program; + + if (dwarf_version >= 4 || !dwarf_strict) + add_AT_flag (subr_die, DW_AT_main_subprogram, 1); + } /* Only add the attribute if the backend requests it, and is not DW_CC_normal. */