From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28329 invoked by alias); 17 May 2010 21:33:21 -0000 Received: (qmail 28320 invoked by uid 22791); 17 May 2010 21:33:20 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD 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; Mon, 17 May 2010 21:33:10 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 4018) id 4D7C7F0D0E; Mon, 17 May 2010 23:33:04 +0200 (CEST) Date: Mon, 17 May 2010 21:33:00 -0000 From: Jan Hubicka To: Joe Buck Cc: Toon Moene , Dave Korn , "gcc@gcc.gnu.org" Subject: Re: Does `-fwhole-program' make sense when compiling shared libraries? Message-ID: <20100517213304.GF26900@atrey.karlin.mff.cuni.cz> References: <4BF1861F.5020406@gmail.com> <4BF1838B.2090603@moene.org> <20100517182340.GQ26047@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100517182340.GQ26047@synopsys.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2010-05/txt/msg00312.txt.bz2 > On Mon, May 17, 2010 at 10:57:31AM -0700, Toon Moene wrote: > > On 05/17/2010 08:08 PM, Dave Korn wrote: > > > > > > Hi! > > > > > > PR42904 is a bug where, when compiling a windows DLL using -fwhole-program, > > > the compiler optimises away the entire library body, because there's no > > > dependency chain related to 'main' to anchor it. > > Not a bug, but perhaps the beginning of a reasonable enhancement project. This is what __attribute__ ((externally_visible)) is intended for. If you want to build shared library with whole program, you need to explicitely mark all the entry points. Alternatively with LTO we might take the existing hidden linkage hints for same effect, but this is not implemented (yet). Honza > > > Aren't "shared library" and "whole program" mutually exclusive concepts ? > > > > The mere fact that you are building a library means that it cannot be > > the whole program, and because a shared library cannot be determined to > > have being used by any fixed program, by definition cannot be "the whole > > program". > > > > Or so I'd think. > > The concept would need to be extended so that the compiler would be told > exactly what interfaces of the shared library are considered free, and > which are considered internal calls. Then a -fwhole-library could make > sense.