From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: liming.gao@intel.com) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by groups.io with SMTP; Thu, 06 Jun 2019 07:06:53 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 07:06:52 -0700 X-ExtLoop1: 1 Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga006.jf.intel.com with ESMTP; 06 Jun 2019 07:06:52 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 6 Jun 2019 07:06:51 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.137]) by shsmsx102.ccr.corp.intel.com ([169.254.2.134]) with mapi id 14.03.0415.000; Thu, 6 Jun 2019 22:06:50 +0800 From: "Liming Gao" To: Roman Agafonov , "devel@edk2.groups.io" CC: "Feng, Bob C" , "Zhu, Yonghong" , "Gao, Liming" Subject: Re: [PATCH v1 1/1] BaseTools: don't use WHOLEARCHIVE linker flag for VS2017 toolchain Thread-Topic: [PATCH v1 1/1] BaseTools: don't use WHOLEARCHIVE linker flag for VS2017 toolchain Thread-Index: AQHVGuv4d0wQOBhGyUqkX7qQMDJqw6aLpZbg//+SMACAAf3jIIAA0r2AgACemiA= Date: Thu, 6 Jun 2019 14:06:49 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E46CF42@SHSMSX104.ccr.corp.intel.com> References: <20190604154059.30380-1-roman.agafonov@aquantia.com> <20190604154059.30380-2-roman.agafonov@aquantia.com>,<4A89E2EF3DFEDB4C8BFDE51014F606A14E46BAAE@SHSMSX104.ccr.corp.intel.com> ,<4A89E2EF3DFEDB4C8BFDE51014F606A14E46C5EF@SHSMSX104.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2FlM2QzZTgtZGUwMi00MGI5LWE4YTgtYzI2OWNiYjlhNDY1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiWnVSQzJzRjlKcEtWMDMwSnYwd1VyTnVROGZOZmQxRFhKMGtoUDhPOGk4dFFlU1hUZkVwWFZsdzZtU1FMYkJENCJ9 dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Roman: Below is my data. There is no big difference for their image size. My VS201= 7 version 15.9, VS2015 version 14.0. And, /GL is the global optimization co= mpiler option. /LTCG is the linker option for the whole-program optimizatio= n. /WHOLEARCHIVE will force to link all obj files. It is helpful to detect = the duplicated functions or the missing functions. But, /LTCG can do the gl= obal optimization to remove unused ones. Then, the final image should be th= e similar./WHOLEARCHIVE has some issue in VS2015. So, it is not enabled in = VS2015.=20 edk2 git version 20d2e5a125 edk2-platform git version 892766538f, now OptionRomPkg is in edk2-platforms Directory of D:\AllPkg\Build\OptionRomPkg\RELEASE_VS2015x86\X64 06/06/2019 09:44 PM . 06/06/2019 09:44 PM .. 06/06/2019 09:44 PM 20,512 AtapiPassThruDxe.efi 06/06/2019 09:44 PM 20,992 AtapiPassThruDxe.rom 06/06/2019 09:44 PM 23,040 Ax88772.efi 06/06/2019 09:44 PM 26,464 Ax88772b.efi 06/06/2019 09:44 PM 10,208 BltLibSample.efi 06/06/2019 09:44 PM 21,376 CirrusLogic5430Dxe.efi 06/06/2019 09:44 PM 11,264 CirrusLogic5430Dxe.rom 06/06/2019 09:44 PM 21,664 FtdiUsbSerialDxe.efi 06/06/2019 09:44 PM MdePkg 06/06/2019 09:44 PM OptionRomPkg 06/06/2019 09:44 PM 6,685 TOOLS_DEF.X64 06/06/2019 09:44 PM 34,688 UndiRuntimeDxe.efi Directory of D:\AllPkg\Build\OptionRomPkg\RELEASE_VS2017\X64 06/06/2019 09:41 PM . 06/06/2019 09:41 PM .. 06/06/2019 09:41 PM 20,864 AtapiPassThruDxe.efi 06/06/2019 09:41 PM 20,992 AtapiPassThruDxe.rom 06/06/2019 09:41 PM 23,360 Ax88772.efi 06/06/2019 09:41 PM 26,944 Ax88772b.efi 06/06/2019 09:41 PM 10,528 BltLibSample.efi 06/06/2019 09:41 PM 21,792 CirrusLogic5430Dxe.efi 06/06/2019 09:41 PM 11,264 CirrusLogic5430Dxe.rom 06/06/2019 09:41 PM 22,080 FtdiUsbSerialDxe.efi 06/06/2019 09:41 PM MdePkg 06/06/2019 09:41 PM OptionRomPkg 06/06/2019 09:41 PM 7,129 TOOLS_DEF.X64 06/06/2019 09:41 PM 35,104 UndiRuntimeDxe.efi Thanks Liming > -----Original Message----- > From: Roman Agafonov [mailto:Roman.Agafonov@aquantia.com] > Sent: Thursday, June 6, 2019 8:20 PM > To: Gao, Liming ; devel@edk2.groups.io > Cc: Feng, Bob C ; Zhu, Yonghong > Subject: Re: [PATCH v1 1/1] BaseTools: don't use WHOLEARCHIVE linker flag= for VS2017 toolchain >=20 > Hi Liming, >=20 > I don't have any custom options except a few ones to disable compiler war= nings. AFAIK /GL is a compiler, not linker option, and it is used > by EDK Visual Studio toolchains by default. >=20 > Of course, the results may vary from project to project. There difference= may not be that big in all cases. Please try building some other > package and compare the results. For example, this is what I get for Opti= onRomPkg compiled with two different toolchains. As you can see, > the difference in size is abnormal. >=20 > pcfist@pcfist-pc:/mnt/c/src/UEFI/UDK2018/Build/OptionRomPkg$ ls -psh1 REL= EASE_VS2017/X64 RELEASE_VS2015x86/X64 > RELEASE_VS2015x86/X64: > total 212K > 20K AtapiPassThruDxe.efi > 24K AtapiPassThruDxe.rom > 28K Ax88772b.efi > 24K Ax88772.efi > 12K BltLibSample.efi > 24K CirrusLogic5430Dxe.efi > 12K CirrusLogic5430Dxe.rom > 24K FtdiUsbSerialDxe.efi > 0 MdePkg/ > 0 OptionRomPkg/ > 8.0K TOOLS_DEF.X64 > 36K UndiRuntimeDxe.efi >=20 > RELEASE_VS2017/X64: > total 424K > 56K AtapiPassThruDxe.efi > 56K AtapiPassThruDxe.rom > 60K Ax88772b.efi > 24K Ax88772.efi > 12K BltLibSample.efi > 56K CirrusLogic5430Dxe.efi > 28K CirrusLogic5430Dxe.rom > 56K FtdiUsbSerialDxe.efi > 0 MdePkg/ > 0 OptionRomPkg/ > 8.0K TOOLS_DEF.X64 > 68K UndiRuntimeDxe.efi >=20 > When comparing the .map files using difftool, I see a lot of unused funct= ions from edk2 libraries (such as UefiDevicePathLib etc.) being > included in the resulting executable, thus increasing its size. This is e= xactly what /WHOLEARCHIVE flag is intended for. My point here is > whether this behavior is really desired, and given the fact that WHOLEARC= HIVE had been removed from VS2015 toolchain previously, I > don't see a reason to use it with VS2017 too. >=20 > Best regards, > Roman >=20 >=20 > From: Gao, Liming > Sent: Wednesday, June 5, 2019 6:47 PM > To: Roman Agafonov; devel@edk2.groups.io > Cc: Feng, Bob C; Zhu, Yonghong > Subject: RE: [PATCH v1 1/1] BaseTools: don't use WHOLEARCHIVE linker flag= for VS2017 toolchain >=20 > I build edk2 OVMF with VS2015 and VS2017. Their image size are almost sam= e. Have you the additional options to disable the > optimization? In fact, /GL option will remove the unused function and log= ic. >=20 > > -----Original Message----- > > From: Roman Agafonov [mailto:Roman.Agafonov@aquantia.com] > > Sent: Wednesday, June 5, 2019 1:21 AM > > To: Gao, Liming ; devel@edk2.groups.io > > Cc: Feng, Bob C ; Zhu, Yonghong > > Subject: Re: [PATCH v1 1/1] BaseTools: don't use WHOLEARCHIVE linker fl= ag for VS2017 toolchain > > > > Hi Liming, > > > > Sure. Here is what I get after building our NIC driver binary with VS20= 15x86 and VS2017 toolchains: > > > > pcfist@pcfist-pc:/mnt/c/src/uefi/udk2018$ du -h Build/xgbe_atl/RELEASE_= VS2015x86/X64/xgbe_atl.efi > > Build/xgbe_atl/RELEASE_VS2017/X64/xgbe_atl.efi > > 36K =A0 =A0 Build/xgbe_atl/RELEASE_VS2015x86/X64/xgbe_atl.efi > > 68K =A0 =A0 Build/xgbe_atl/RELEASE_VS2017/X64/xgbe_atl.efi > > > > Best regards, > > Roman > > > > From: Gao, Liming > > Sent: Tuesday, June 4, 2019 6:54 PM > > To: Roman Agafonov; devel@edk2.groups.io > > Cc: Feng, Bob C; Zhu, Yonghong > > Subject: RE: [PATCH v1 1/1] BaseTools: don't use WHOLEARCHIVE linker fl= ag for VS2017 toolchain > > > > Can you show the size data with VS2017 and VS2015 for the same code? > > > > Thanks > > Liming > > > -----Original Message----- > > > From: Roman Agafonov [mailto:Roman.Agafonov@aquantia.com] > > > Sent: Tuesday, June 4, 2019 11:41 PM > > > To: devel@edk2.groups.io > > > Cc: Feng, Bob C ; Gao, Liming ; Zhu, Yonghong > > > Subject: [PATCH v1 1/1] BaseTools: don't use WHOLEARCHIVE linker flag= for VS2017 toolchain > > > > > > I have noticed the resulting binaries are about twice as large when > > > using VS2017 toolchain compared to the ones built with VS2015. It app= ears > > > this is caused by /WHOLEARCHIVE linker flag used by this toolchain. T= his > > > flag was previously removed from VS2015 toolchain due to compatibilit= y > > > issues. I believe it should not be used with VS2017 as well. > > > > > > Cc: Bob Feng > > > Cc: Liming Gao > > > Cc: Yonghong Zhu > > > Signed-off-by: Roman Agafonov > > > --- > > >=A0 BaseTools/Conf/tools_def.template | 2 +- > > >=A0 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools= _def.template > > > index 26a2cf604f74..482a526f3052 100755 > > > --- a/BaseTools/Conf/tools_def.template > > > +++ b/BaseTools/Conf/tools_def.template > > > @@ -1545,7 +1545,7 @@ NOOPT_VS2015x86_X64_DLINK_FLAGS=A0=A0=A0 =3D /N= OLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF > > >=A0 *_VS2017_*_APP_FLAGS=A0=A0=A0=A0=A0=A0 =3D /nologo /E /TC > > >=A0 *_VS2017_*_PP_FLAGS=A0=A0=A0=A0=A0=A0=A0 =3D /nologo /E /TC /FIAut= oGen.h > > >=A0 *_VS2017_*_VFRPP_FLAGS=A0=A0=A0=A0 =3D /nologo /E /TC /DVFRCOMPILE= /FI$(MODULE_NAME)StrDefs.h > > > -*_VS2017_*_DLINK2_FLAGS=A0=A0=A0 =3D /WHOLEARCHIVE > > > +*_VS2017_*_DLINK2_FLAGS=A0=A0=A0 =3D > > >=A0 *_VS2017_*_ASM16_PATH=A0=A0=A0=A0=A0 =3D DEF(VS2017_BIN_IA32)\ml.e= xe > > > > > >=A0 ################## > > > -- > > > 2.9.0.windows.1