From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 6C3DA21AF39CE for ; Thu, 25 May 2017 11:06:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C74F97249D; Thu, 25 May 2017 18:06:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C74F97249D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C74F97249D Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-147.phx2.redhat.com [10.3.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FCDA17DE6; Thu, 25 May 2017 18:06:48 +0000 (UTC) To: "Kinney, Michael D" , Ard Biesheuvel , "Andrew Fish (afish@apple.com)" Cc: "Wu, Hao A" , "edk2-devel@lists.01.org" , "Fan, Jeff" References: <1495581673-10788-1-git-send-email-michael.d.kinney@intel.com> <60f3303b-c333-101d-b6e5-806ab85075a9@redhat.com> From: Laszlo Ersek Message-ID: <435e1d65-7710-f548-c591-558307e266bc@redhat.com> Date: Thu, 25 May 2017 20:06:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 May 2017 18:06:50 +0000 (UTC) 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 18:06:50 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 05/25/17 19:38, Kinney, Michael D wrote: > Laszlo, > > I think the equivalent flag for GCC builds is --whole-archive. > > I tried adding that flag to DLINK_FLAGS in GCC5, and I get the > following error building OVMF from edk2/master with > -D SOURCE_DEBUG_ENABLE set. > > DxeLoad.obj (symbol from plugin): In function `InstallIplPermanentMemoryPpis': > (.text+0x0): multiple definition of `mMemoryDiscoveredNotifyList' > SecPeiDebugAgentLib.obj (symbol from plugin):(.text+0x0): first defined here > collect2: error: ld returned 1 exit status Great find! That's the error message we should get. Unfortunately, after reading the "ld" manual on "--whole-archive", it seems that the complete object files will actually be copied into the resultant binary, even if several of their symbols will remain unused. I think that's quite sub-optimal. (I haven't verified this though.) What we'd like to get is (a) the full verification at link time, and (b) inclusion of *only* those symbols that are actually necessary. In your testing, when you build OVMF with and without "--whole-archive", do you see a difference in, say, the DXEFV footprint, when the build completes? (If so, then I wonder if we should add "--whole-archive" only to the NOOPT build... Not sure.) > Visual Studio 2015 Update 2 has also added a new linker flag called > /WHOLEARCHIVE. I am working on evaluating that flag to see if it > catches the same issue. Thanks! Laszlo >> -----Original Message----- >> From: Laszlo Ersek [mailto:lersek@redhat.com] >> Sent: Thursday, May 25, 2017 9:09 AM >> To: Kinney, Michael D ; Ard Biesheuvel >> ; Andrew Fish (afish@apple.com) >> Cc: Wu, Hao A ; edk2-devel@lists.01.org; Fan, Jeff >> >> Subject: Re: [edk2] [Patch] SourceLevelDebugPkg/SecPeiDebugAgentLib: Fix duplicate >> symbol >> >> On 05/25/17 03:47, Kinney, Michael D wrote: >>> Andrew, >>> >>> I think I have found an alternate fix for this XCODE5 specific >>> build failure. Since there appears to be a difference in the >>> linker behavior between MSFT/GCC/XCODE tool chains, I reviewed >>> the 'ld' command line options used in XCODE5 tool chain in >>> tools_def.txt. >>> >>> There is a flag set call '-all_load'. The description of this >>> flag is 'Loads all members of static archive libraries.'. >>> >>> I tried removing this flag from the XCODE5 specific SLINK_FLAGS >>> and DLINK_FLAGS statements in tools_def.txt, and the duplicate >>> symbol build failure is no longer present. I am able to build >>> and boot OVMF with XCODE5 with -D SOURCE_DEBUG_ENABLE flag set. >>> >>> This seems to make XCODE5 linker behavior match the MSFT and GCC >>> linker behavior. >>> >>> Do you know why '-all_load' is used in XCODE5 and what impacts >>> there may be from removing it? >> >> Please don't remove -all_load from there; instead we should figure out >> if the same can be brought to MSFT and GCC. >> >> The error message that XCODE5 emitted caught a real bug (undefined >> behavior according to ISO C, see my previous email), and so we should >> keep that detection enabled (we should even extend it to other >> toolchains, if that's possible). >> >> As for docs, I found this: >> >> http://www.manpages.info/macosx/ld.1.html >> >>> -all_load >>> Loads all members of static archive libraries. This option does >>> not apply to dynamic shared libraries. >> >> >> Thanks >> Laszlo