From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20913 invoked by alias); 27 Mar 2010 17:32:18 -0000 Received: (qmail 20898 invoked by uid 22791); 27 Mar 2010 17:32:17 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from ksp.mff.cuni.cz (HELO atrey.karlin.mff.cuni.cz) (195.113.26.206) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 27 Mar 2010 17:32:13 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 4018) id 77D84F1705; Sat, 27 Mar 2010 18:32:11 +0100 (CET) Date: Sat, 27 Mar 2010 17:53:00 -0000 From: Jan Hubicka To: John David Anglin Cc: gcc-patches@gcc.gnu.org, rguenth@gcc.gnu.org Subject: Re: [PATCH] Fix visibility of constructors/destructors with -fwhole-program Message-ID: <20100327173211.GC19570@atrey.karlin.mff.cuni.cz> References: <20100327142544.59A9F4FA3@hiauly1.hia.nrc.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100327142544.59A9F4FA3@hiauly1.hia.nrc.ca> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes 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/msg01295.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? Hmm, I see it was applied already, but this imply that attribute used on functions now imply externally_visible, while on variables it does not. I am not sure what would be best behaviour of used WRT whole-program. I guess the symbol should be still brought static, but the mangling (i.e. .1234) should not be applied so asm statements from other source files (within same LTO unit) can refer to it. I guess it is resonable to want something like the following work: t1.c: __attribute__ ((used)) int q; __attribute__ ((used)) void t() { } t2.c: main() { int q; asm("call t; movl $q,%0":"=r"(q)); return q; } and expect this to link properly -fwhole-program or not and I guess also to make -fwhole-program privatize both q and t unless externally_visible is given. At present (before this patch) we seem to get 't' right (i.e. it is static and with original name), but we do not output q. If this seems like intended behaviour, I guess I can fix this as well as make this hppa fix to attach externally visible attribute (or simply force externally visible flag on the cgraph node that should have same effect) Honza