From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7415 invoked by alias); 27 Mar 2010 14:25:52 -0000 Received: (qmail 7403 invoked by uid 22791); 27 Mar 2010 14:25:51 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from hiauly1.hia.nrc.ca (HELO hiauly1.hia.nrc.ca) (132.246.100.193) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 27 Mar 2010 14:25:48 +0000 Received: by hiauly1.hia.nrc.ca (Postfix, from userid 1000) id 59A9F4FA3; Sat, 27 Mar 2010 10:25:43 -0400 (EDT) Subject: Re: [PATCH] Fix visibility of constructors/destructors with -fwhole-program To: dave@hiauly1.hia.nrc.ca (John David Anglin) Date: Sat, 27 Mar 2010 15:44:00 -0000 From: "John David Anglin" Cc: gcc-patches@gcc.gnu.org, rguenth@gcc.gnu.org In-Reply-To: from "John David Anglin" at Jan 2, 2010 12:13:46 pm MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20100327142544.59A9F4FA3@hiauly1.hia.nrc.ca> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-03/txt/msg01291.txt.bz2 > This patch fixes PR middle-end/41674. With -fwhole-program, the > constructor _GLOBAL__I_65535_0_main has its public flag turned off > by function_and_variable_visibility and thereby made local. However, > these symbols need to be global for collect2 to arrange to call them. > > Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11. Here is take 2. The first version was deemed overkill and Richard suggested using DECL_PRESERVE_P. Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11 with no regressions. Ok for trunk? Dave -- J. David Anglin dave.anglin@nrc-cnrc.gc.ca National Research Council of Canada (613) 990-0752 (FAX: 952-6602) 2010-01-02 John David Anglin PR middle-end/41674 * cgraphunit.c (cgraph_build_static_cdtor): If target doesn't have cdtors, set DECL_PRESERVE_P. * ipa.c (cgraph_externally_visible_p): Return true if declaration should be preseved. Index: cgraphunit.c =================================================================== --- cgraphunit.c (revision 157617) +++ cgraphunit.c (working copy) @@ -1946,7 +1946,11 @@ DECL_ARTIFICIAL (decl) = 1; DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1; DECL_SAVED_TREE (decl) = body; - TREE_PUBLIC (decl) = ! targetm.have_ctors_dtors; + if (!targetm.have_ctors_dtors) + { + TREE_PUBLIC (decl) = 1; + DECL_PRESERVE_P (decl) = 1; + } DECL_UNINLINABLE (decl) = 1; DECL_INITIAL (decl) = make_node (BLOCK); Index: ipa.c =================================================================== --- ipa.c (revision 157617) +++ ipa.c (working copy) @@ -317,6 +317,8 @@ return false; if (!whole_program) return true; + if (DECL_PRESERVE_P (node->decl)) + return true; /* COMDAT functions must be shared only if they have address taken, otherwise we can produce our own private implementation with -fwhole-program. */