From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21696 invoked by alias); 18 May 2010 13:58:25 -0000 Received: (qmail 21663 invoked by uid 22791); 18 May 2010 13:58:23 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM X-Spam-Check-By: sourceware.org Received: from mail-fx0-f47.google.com (HELO mail-fx0-f47.google.com) (209.85.161.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 May 2010 13:58:17 +0000 Received: by fxm8 with SMTP id 8so993362fxm.20 for ; Tue, 18 May 2010 06:58:15 -0700 (PDT) Received: by 10.204.45.207 with SMTP id g15mr9987bkf.210.1274191095248; Tue, 18 May 2010 06:58:15 -0700 (PDT) Received: from [192.168.2.99] (cpc2-cmbg8-0-0-cust61.cmbg.cable.ntl.com [82.6.108.62]) by mx.google.com with ESMTPS id a11sm19207603bkc.3.2010.05.18.06.58.12 (version=SSLv3 cipher=RC4-MD5); Tue, 18 May 2010 06:58:13 -0700 (PDT) Message-ID: <4BF2A194.3010601@gmail.com> Date: Tue, 18 May 2010 13:58:00 -0000 From: Dave Korn User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: "gcc@gcc.gnu.org" Subject: Re: Does `-fwhole-program' make sense when compiling shared libraries? References: <4BF1861F.5020406@gmail.com> <4BF1838B.2090603@moene.org> <4BF18A6B.5030603@gmail.com> In-Reply-To: <4BF18A6B.5030603@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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/msg00317.txt.bz2 [ hmf. This one got lost to an smtp error when I sent it yesterday. It appears there's more or less agreement that at the moment you're supposed to manually annotate all external entry points if you want to use -fwhole-program on a library. On windows, where we often do that anyway, it looks like it would make a great deal of sense to infer externally_visible from dllexport. ] On 17/05/2010 19:26, Dave Korn wrote: > On 17/05/2010 18:57, 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. >> 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. > > Well, indeed that is strictly the case, but a shared library is also a > self-contained bundle of dependencies, and if all the externally visible > functions were treated as roots like 'main', I would have thought > -fwhole-program could usefully do its thing. So I wondered if anyone had > thought about making it work. (I guess the PR should be treated as an > enhancement request.) > > cheers, > DaveK