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 84E7C21A02918 for ; Thu, 25 May 2017 13:11:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD09F80B56; Thu, 25 May 2017 20:11:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CD09F80B56 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CD09F80B56 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 24CCB6031D; Thu, 25 May 2017 20:10:59 +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> <435e1d65-7710-f548-c591-558307e266bc@redhat.com> From: Laszlo Ersek Message-ID: <11d75cc7-1656-a31d-7dbf-dc7c176a9a88@redhat.com> Date: Thu, 25 May 2017 22:10:59 +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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 25 May 2017 20:11:02 +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 20:11:02 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 05/25/17 21:57, Kinney, Michael D wrote: > Laszlo, > > I have the same concern on final image sizes. I have done some > evaluation: > > GCC5 OVMF X64 DEBUG without -whole-archive > ========================================== > FV Space Information > SECFV [19%Full] 212992 total, 42000 used, 170992 free > FVMAIN_COMPACT [33%Full] 3440640 total, 1162760 used, 2277880 free > DXEFV [38%Full] 10485760 total, 4024024 used, 6461736 free > PEIFV [19%Full] 917504 total, 180648 used, 736856 free > Total used = 5409432 > > GCC5 OVMF X64 DEBUG with -whole-archive > ======================================= > FV Space Information > SECFV [19%Full] 212992 total, 41936 used, 171056 free > FVMAIN_COMPACT [33%Full] 3440640 total, 1158304 used, 2282336 free > DXEFV [38%Full] 10485760 total, 4029656 used, 6456104 free > PEIFV [19%Full] 917504 total, 181352 used, 736152 free > Total used = 5411248 > > Total used difference = 1816 bytes larger with -whole-archive > > I was also able to do a MSFT VS2015 build with /WHOLEARCHIVE set > and it also catches the same duplicate symbol error now. > > error C2220: warning treated as error - no 'executable' file generated > warning C4744: 'mMemoryDiscoveredNotifyList' has different type in 'd:\work\github\tianocore\edk2\mdemodulepkg\core\dxeiplpeim\dxeload.c' and 'd:\work\github\tianocore\edk2\sourceleveldebugpkg\library\debugagent\secpeidebugagent\secpeidebugagentlib.c': 'struct (12 bytes)' and 'array (12 bytes)' > DxeIpl.lib(DxeLoad.obj) : error LNK2005: _mMemoryDiscoveredNotifyList already defined in SecPeiDebugAgentLib.lib(SecPeiDebugAgentLib.obj) > d:\work\github\tianocore\edk2\Build\OvmfIa32\DEBUG_VS2015x86\IA32\MdeModulePkg\Core\DxeIplPeim\DxeIpl\DEBUG\DxeIpl.dll : fatal error LNK1169: one or more multiply defined symbols found > > VS2015 OVMF X64 DEBUG without /WHOLEARCHIVE > =========================================== > FV Space Information > SECFV [22%Full] 212992 total, 48560 used, 164432 free > FVMAIN_COMPACT [33%Full] 3440640 total, 1147464 used, 2293176 free > DXEFV [39%Full] 10485760 total, 4163888 used, 6321872 free > PEIFV [22%Full] 917504 total, 204840 used, 712664 free > Total used = 5564752 > > > VS2015 OVMF X64 DEBUG with /WHOLEARCHIVE > =========================================== > FV Space Information > SECFV [23%Full] 212992 total, 50384 used, 162608 free > FVMAIN_COMPACT [33%Full] 3440640 total, 1147424 used, 2293216 free > DXEFV [42%Full] 10485760 total, 4422992 used, 6062768 free > PEIFV [27%Full] 917504 total, 255528 used, 661976 free > Total used = 5875338 > > Total used difference = 310586 bytes larger with /WHOLEARCHIVE > > For tool chains that do have size impacts, one option is to > have a "test" build that enables the linker flags to detect > duplicate symbols. For example the following could be added > to a DSC file. May want to disable GenFds stage when doing > this type of build. > > [BuildOptions] > !ifdef $(DETECT_DUPLICATE_SYMBOLS) > MSFT:*_VS2015_*_DLINK_FLAGS = /WHOLEARCHIVE > !endif Thank you (again) for the research! Looks like the gcc size impact is friendly enough to keep --whole-archive enabled at all times (possibly due to the --gc-sections flag mentioned by Ard, which we already have enabled). The VS2015 impact is really large however. I was hoping we could add these flags to "BaseTools/Conf/tools_def.template", regardless of platform DSC. (If the flag is non-default, and/or it's platform-dependent, then it will almost never be used, most likely.) But the VS2015 size increase really precludes /WHOLEARCHIVE (for the MSFT family) from "tools_def.template". Would it be acceptable to add --whole-archive to "tools_def.template" only for GCC? After all, at the moment only XCODE*/XCLANG have "-all_load". Thanks, Laszlo