From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in22.apple.com (mail-out22.apple.com [17.171.2.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 22F6E21A0291E for ; Thu, 25 May 2017 13:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1495744632; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=601N7+/mu4NFBFBfibhqpPYF3v3mqza4OUxmDjfk1QU=; b=Qqa+f7s1HF7qLLznn4dHjU+iTM/7qIqa2SxHdzlwNy1OanXakiQalsvO7R0Eir7e nIEw4yGac0qGovXBeyp7O1Bvb3ey50WYUKdvzU37jAoN21XCoFHXB9k7IB52fAE1 b7U/0WgGKbPaRlwHBIQSkOyjnqiFkpVwRObEEMAFI4yTNm6mOeiBfLm8RHRcpcXy pquy1FoOwyOWRs5js4aHgy6bbmuKf2Fq6WgBB7iloTjUt+uzO/C/K92vFlz6BHcP pTzve081lU+9pNcIfoO3ksM3CFpKUNTut6ZKkZ7IIZHgr8NrX7+AFVQTOgr7xsgm YwYxTbGyFH7BpXoHlC9HUQ==; Received: from relay2.apple.com (relay2.apple.com [17.128.113.67]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in22.apple.com (Apple Secure Mail Relay) with SMTP id 36.68.02740.77047295; Thu, 25 May 2017 13:37:12 -0700 (PDT) X-AuditID: 11ab0216-12b3a9a000000ab4-09-592740775714 Received: from nwk-mmpp-sz11.apple.com (nwk-mmpp-sz11.apple.com [17.128.115.155]) by relay2.apple.com (Apple SCV relay) with SMTP id AE.55.07829.77047295; Thu, 25 May 2017 13:37:11 -0700 (PDT) MIME-version: 1.0 Received: from [17.153.17.124] by nwk-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170210 64bit (built Feb 10 2017)) with ESMTPSA id <0OQI00JWMZXWAR70@nwk-mmpp-sz11.apple.com>; Thu, 25 May 2017 13:37:11 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish Message-id: <56801ADE-446F-43C2-9C99-5500E8EE5881@apple.com> Date: Thu, 25 May 2017 13:37:08 -0700 In-reply-to: Cc: Ard Biesheuvel , Mike Kinney , Felix Poludov , "Fan, Jeff" , "edk2-devel@lists.01.org" , "Wu, Hao A" To: Laszlo Ersek References: <1495581673-10788-1-git-send-email-michael.d.kinney@intel.com> <542CF652F8836A4AB8DBFAAD40ED192A4C5E94B8@shsmsx102.ccr.corp.intel.com> X-Mailer: Apple Mail (2.3273) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeLIzCtJLcpLzFFi42IRbCh01q1wUI80mH5T2OL/h92MFnsOHWW2 WPflHKvF1Vu/mCxOrl/CaLHs2A4Wi46Of0wO7B7Tr/xi91i85yWTx51re9g8umf/Y/F4v+8q WwBrFJdNSmpOZllqkb5dAlfGjfatLAUrVzFW/LoxgaWB8cEUxi5GTg4JAROJpTMuM3UxcnEI Caxhknjc2gCXOLz/FSuILSRwiFHi+D1pEJtXQFDix+R7LCA2s0CYxIfuiywQzV+Baj7uZgdJ CAuIS7w7s4kZxGYTUJZYMf8DO0SzjcSSu31QNdESV6+9AlvGIqAqMb9nClg9p4CdxPu3k5lB hjIL/GSUmPQT4goRARWJ2RMeQJ16k0ni1aPZzBCnykrcmn0JrENC4DabRNvPVpYJjEKzkJw7 C8m5ELaWxPdHrUA2B5AtL3HwvCxEWFPi2b1P7BC2tsSTdxdYFzCyrWIUzk3MzNHNzDMy0kss KMhJ1UvOz93ECIqy1UxiOxjv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yX2V1exKLMUZiYZazEXFiQCc J3eOhQIAAA== X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: Re: [Patch] SourceLevelDebugPkg/SecPeiDebugAgentLib: Fix duplicate symbol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 May 2017 20:37:13 -0000 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT > On May 25, 2017, at 1:28 PM, Laszlo Ersek wrote: > > On 05/25/17 22:11, Ard Biesheuvel wrote: >> On 25 May 2017 at 13:06, Kinney, Michael D wrote: >>> Laszlo and Andrew, >>> >>> With the information that has been collected on this thread, I >>> still think this patch in its original form is a good change >>> to resolve the this one specific duplicate symbol issue for all >>> tool chains. 'static' can not be mixed with >>> GLOBAL_REMOVE_IF_UNREFERENCED for MSFT tool chains, so renaming >>> the global variable is the easiest way to remove the duplicate. >>> >> >> GLOBAL_REMOVE_IF_UNREFERENCED itself is problematic imo. I think it >> was Felix who reported on this recently? >> >> STATIC is really the only sensible way to deal with this for symbols >> that are only referenced by a single compilation unit. >> >>> I will continue to work on ways to detect duplicate symbols for >>> all tool chains and will enter a Bugzilla issue to for that >>> feature. >>> >>> In addition, the idea of detecting if a library is exporting more >>> than the library class defines is another good feature to consider >>> and I will enter a Bugzilla issue for that one as well. >>> >>> If we can find ways to both restrict the symbols exported by a >>> library and strip all symbols that are unused, then we can have >>> additional Bugzilla issues to perform that clean up on each >>> library instance that is exporting more than the library class. >>> >> >> A static library is nothing more than an archive containing a >> collection of object files. Sadly, that implies that we cannot >> distinguish between symbols that may only be referenced by other >> objects in the same static library and symbols that are exported to >> the library client. > > Do we know for a fact that, with /OPT:REF, VS does not strip unused > *static* variables and functions? > > I mean, is it certain that *replacing* GLOBAL_REMOVE_IF_UNREFERENCED > with STATIC in this case would lead to a size increase? > > If that's the case, then I'm fine if we go ahead with this patch, I'd > just like to request that Mike please file some of those BZs, and please > reference them from the commit message (as the longer term solution), > before committing the patch. > Clang will warn if you have unused static variables when warnings are cranked up. ~/work/Compiler>cat static.c static unsigned char gTest[] = { 42 }; static int test () { return 1; } int main () { return 0; } ~/work/Compiler>clang -Os static.c -Wall static.c:1:22: warning: unused variable 'gTest' [-Wunused-variable] static unsigned char gTest[] = { 42 }; ^ static.c:3:12: warning: unused function 'test' [-Wunused-function] static int test () ^ 2 warnings generated. Thanks, Andrew Fish > Thanks > Laszlo