From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 B26E921A6F108 for ; Mon, 27 Mar 2017 10:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490634414; x=1522170414; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=eMVAMvUhKryMCI/Zdc9LvTNq7togQe6N8EKCIkzo6gU=; b=XluelC3/i+O46v/jt/fAzeS+5YmyPymfSavTyGLKBX2aBB+xOTOsw6OJ uwsYQW9M7VNsNBN50HA1lNURUQxN3w==; Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 10:06:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,232,1486454400"; d="scan'208";a="240811537" Received: from orsmsx105.amr.corp.intel.com ([10.22.225.132]) by fmsmga004.fm.intel.com with ESMTP; 27 Mar 2017 10:06:54 -0700 Received: from orsmsx151.amr.corp.intel.com (10.22.226.38) by ORSMSX105.amr.corp.intel.com (10.22.225.132) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 27 Mar 2017 10:06:53 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.59]) by ORSMSX151.amr.corp.intel.com ([169.254.7.111]) with mapi id 14.03.0319.002; Mon, 27 Mar 2017 10:06:53 -0700 From: "Kinney, Michael D" To: Felix Poludov , "Gao, Liming" , "edk2-devel@lists.01.org" , "Kinney, Michael D" Thread-Topic: [RFC] GLOBAL_REMOVE_IF_UNREFERENCED, multiply defined symbols, and MSFT/GCC tool chains. Thread-Index: AdKkmm2mcThMLZckRnawazzXsHkPjwCDpsPAABg95DAAATdlkAAApmqAAACEyBAAAErC0AABt9zg Date: Mon, 27 Mar 2017 17:06:53 +0000 Message-ID: References: <9333E191E0D52B4999CE63A99BA663A002DEEEDA95@atlms1.us.megatrends.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14D702B8A@shsmsx102.ccr.corp.intel.com> <9333E191E0D52B4999CE63A99BA663A002DEEF126B@atlms1.us.megatrends.com> <9333E191E0D52B4999CE63A99BA663A002DEEF1308@atlms1.us.megatrends.com> <9333E191E0D52B4999CE63A99BA663A002DEEF136D@atlms1.us.megatrends.com> In-Reply-To: <9333E191E0D52B4999CE63A99BA663A002DEEF136D@atlms1.us.megatrends.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDBiZmI2MWQtNTVkMS00MTc3LWFmMDMtZjExZWExZTkxNjZiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjRzdVZoTVF5K0NZOWR4V3lWT0tYVzl0aXI4VXl3Z1ZYMjNlZk9MXC8xSFFFPSJ9 x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Subject: Re: [RFC] GLOBAL_REMOVE_IF_UNREFERENCED, multiply defined symbols, and MSFT/GCC tool chains. 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: Mon, 27 Mar 2017 17:06:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Felix, We need to find all instances of that usage and fix them. We can make sure this issue is fixed for all open source packages and open source platforms before this change is committed to master. I recommend you generate a new version of the patch based on feedback=20 from this thread and ask all package and platform owners to verify that their packages and platforms build with that change. =20 Perhaps give 1-2 weeks for verification so the package and platform owners can resolve any issues found. Other opinions? Thanks, Mike > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Fe= lix Poludov > Sent: Monday, March 27, 2017 9:17 AM > To: Kinney, Michael D ; Gao, Liming > ; edk2-devel@lists.01.org > Subject: Re: [edk2] [RFC] GLOBAL_REMOVE_IF_UNREFERENCED, multiply defined= symbols, and > MSFT/GCC tool chains. >=20 > Mike, >=20 > I completely agree. > As far as code that breaks, the most typical problem I've seen is variabl= e or constant > defined in a header file included by more than one C file. >=20 > Are you going to make these modifications or do you want me to submit a p= atch? >=20 > -----Original Message----- > From: Kinney, Michael D [mailto:michael.d.kinney@intel.com] > Sent: Monday, March 27, 2017 12:07 PM > To: Felix Poludov; Gao, Liming; edk2-devel@lists.01.org; Kinney, Michael = D > Subject: RE: [RFC] GLOBAL_REMOVE_IF_UNREFERENCED, multiply defined symbol= s, and > MSFT/GCC tool chains. >=20 > Felix, >=20 > What is the condition that will fail if /Gw is set and GLOBAL_REMOVE_IF_U= NREFERENCED > is defined to nothing? >=20 > If these are real bugs, then I think we should identify those bugs and fi= x them and > then apply this strong policy for newer VS compilers. >=20 > Mike >=20 > > -----Original Message----- > > From: Felix Poludov [mailto:Felixp@ami.com] > > Sent: Monday, March 27, 2017 8:59 AM > > To: Kinney, Michael D ; Gao, Liming > > ; edk2-devel@lists.01.org > > Subject: RE: [RFC] GLOBAL_REMOVE_IF_UNREFERENCED, multiply defined > > symbols, and MSFT/GCC tool chains. > > > > Mike, > > > > What do you think about defining GLOBAL_REMOVE_IF_UNREFERENCED in the > > tool chain definition file as an empty macro for a newer VS compilers? > > If this is done, as Liming pointed out, some code that compiles today m= ay break. > > If this is not done, variables declared with > > GLOBAL_REMOVE_IF_UNREFERENCED are not subject to the default policy of > > breaking the build if multiple defined symbols are detected when MSFT t= ool chain is > used. > > > > -----Original Message----- > > From: Kinney, Michael D [mailto:michael.d.kinney@intel.com] > > Sent: Monday, March 27, 2017 11:35 AM > > To: Felix Poludov; Gao, Liming; edk2-devel@lists.01.org; Kinney, > > Michael D > > Subject: RE: [RFC] GLOBAL_REMOVE_IF_UNREFERENCED, multiply defined > > symbols, and MSFT/GCC tool chains. > > > > Felix, > > > > I prefer the default policy to break the build if multiple defined > > symbols are detected. > > > > Exceptions should only be allowed to support a specific compiler or a > > specific level of compiler optimizations. > > > > I do like the addition of the /Gw switch to the newer VS compilers. > > Adding the current GLOBAL_REMOVE_IF_UNREFERENCED macro to global > > variable declarations is a manual process that usually requires > > inspection of PE/COFF images to notice that data that should have been = optimized > away is still present. > > > > Adding the #ifndef also looks like a good way to adopt the /Gw switch > > in newer VS Compilers and preserve backwards compatibility with older V= S compilers. > > > > Thanks, > > > > Mike > > > > > > > -----Original Message----- > > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf > > > Of Felix Poludov > > > Sent: Monday, March 27, 2017 7:59 AM > > > To: Gao, Liming ; edk2-devel@lists.01.org > > > Subject: Re: [edk2] [RFC] GLOBAL_REMOVE_IF_UNREFERENCED, multiply > > > defined symbols, and MSFT/GCC tool chains. > > > > > > Liming, > > > > > > Yes surrounding GLOBAL_REMOVE_IF_UNREFERENCED with #ifndef would be a= n > improvement. > > > Can you make this change? > > > > > > On the other note, don't you think that EDKII should have a generic > > > policy regarding multiply defined symbols (whether they are allowed o= r not)? > > > Today, they may or may not work depending on the compiler used. > > > > > > -----Original Message----- > > > From: Gao, Liming [mailto:liming.gao@intel.com] > > > Sent: Monday, March 27, 2017 12:49 AM > > > To: Felix Poludov; edk2-devel@lists.01.org > > > Cc: Gao, Liming > > > Subject: RE: [RFC] GLOBAL_REMOVE_IF_UNREFERENCED, multiply defined > > > symbols, and MSFT/GCC tool chains. > > > > > > Felix: > > > This changes the default MSFT build behavior. It will impact all > > > platforms even if this platform has no requirement to pass GCC build. > > > I suggest to update platform DSC to enable it in MSFT tool chain if > > > this platform > > needs to support MSFT and GCC both. > > > > > > In Base.h: I agree to define GLOBAL_REMOVE_IF_UNREFERENCED only when > > > it is not defined. Then, Platform.dsc can append compiler option /D > > > GLOBAL_REMOVE_IF_UNREFERE to the different value in [BuildOptions] se= ction. > > > > > > #ifndef GLOBAL_REMOVE_IF_UNREFERENCED > > > #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany) #endif > > > > > > Thanks > > > Liming > > > >-----Original Message----- > > > >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf > > > >Of Felix Poludov > > > >Sent: Friday, March 24, 2017 8:53 PM > > > >To: edk2-devel@lists.01.org > > > >Subject: [edk2] [RFC] GLOBAL_REMOVE_IF_UNREFERENCED, multiply > > > >defined symbols, and MSFT/GCC tool chains. > > > > > > > >Trying to add GCC support to projects based on MSFT tool chain, I'm > > > >keep stumbling into multiply defined symbol errors reported by GCC l= inker. > > > >An attempt to understand why the errors are not reported by the > > > >Microsoft linker lead me to GLOBAL_REMOVE_IF_UNREFERENCED macro. > > > >The purpose of the macro is to enable link time optimization of > > > >global variables. > > > >However, the way it's defined for MSFT tool chain > > > >(__declspec(selectany) ) has a side effect of explicitly allowing > > > >multiple instances of a symbol defined with GLOBAL_REMOVE_IF_UNREFER= ENCED. > > > >For a while usage of the macro was the only option to enable global > > > >variable optimization. > > > >Starting from VS2013 compiler supports /Gw flag that enables global > > > >variable optimization without a special declarator. > > > > > > > >I propose to make the following modifications: > > > > > > > >1. Change GLOBAL_REMOVE_IF_UNREFERENCED definition to an empty > > > >macro. > > > > > > > >Or more specifically, update macro definition in Base.h as follows: > > > > > > > >#ifndef GLOBAL_REMOVE_IF_UNREFERENCED > > > > > > > >#define GLOBAL_REMOVE_IF_UNREFERENCED > > > > > > > >#endif > > > > > > > >2. Update VS2013 and VS2015 compiler flags to add /Gw option > > > > > > > >3. Update compiler flags for older MSFT tool chains to define > > > >GLOBAL_REMOVE_IF_UNREFERENCED in a backward compatible manner for > > > >targets that enable optimization. > > > > > > > >/D GLOBAL_REMOVE_IF_UNREFERENCED =3D_declspec(selectany) > > > > > > > > > > > >The advantages of these modifications are: > > > > > > > >- Better detection of on potential errors by breaking the bui= ld when > > > >symbol is defined more than once. > > > > > > > >- Improved consistency between MSFT and GCC tool chains > > > > > > > >- Improved link time optimization with VS2013 and newer MSFT = tool chains. > > > > > > > >For example, mGaugeData in > > > >MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c > > > >is not declared as GLOBAL_REMOVE_IF_UNREFERENCED, so > > > > > > > >today performance library is linked with DXE Core even when > > > >performance measurements are disabled. > > > > > > > >The alternative option is to enable support of multiply defined > > > >symbols on GCC tool chain. > > > >One way to do it is by defining the macro as #define > > > >GLOBAL_REMOVE_IF_UNREFERENCED __attribute__((weak)) > > > > > > > >However, I'm not sure that embracing multiple symbol definitions is > > > >a good idea. > > > >For example, see Ard's arguments in this commit comment > > > >https://github.com/tianocore/edk2/commit/214a3b79417f64bf2faae74af4 > > > >2c > > > >1 > > > >b9d23f50dc8 > > > > > > > >Thanks > > > >Felix > > > > > > > >Please consider the environment before printing this email. > > > > > > > >The information contained in this message may be confidential and > > > >proprietary to American Megatrends, Inc. This communication is > > > >intended to be read only by the individual or entity to whom it is > > > >addressed or by their designee. If the reader of this message is > > > >not the intended recipient, you are on notice that any distribution > > > >of this message, in any form, is strictly prohibited. Please > > > >promptly notify the sender by reply e-mail or by telephone at > > > >770-246-8600, and then delete > > or destroy all copies of the transmission. > > > >_______________________________________________ > > > >edk2-devel mailing list > > > >edk2-devel@lists.01.org > > > >https://lists.01.org/mailman/listinfo/edk2-devel > > > > > > Please consider the environment before printing this email. > > > > > > The information contained in this message may be confidential and > > > proprietary to American Megatrends, Inc. This communication is > > > intended to be read only by the individual or entity to whom it is > > > addressed or by their designee. If the reader of this message is not > > > the intended recipient, you are on notice that any distribution of > > > this message, in any form, is strictly prohibited. Please promptly > > > notify the sender by reply e-mail or by telephone at 770-246-8600, > > > and then delete > > or destroy all copies of the transmission. > > > _______________________________________________ > > > edk2-devel mailing list > > > edk2-devel@lists.01.org > > > https://lists.01.org/mailman/listinfo/edk2-devel > > > > Please consider the environment before printing this email. > > > > The information contained in this message may be confidential and > > proprietary to American Megatrends, Inc. This communication is > > intended to be read only by the individual or entity to whom it is > > addressed or by their designee. If the reader of this message is not > > the intended recipient, you are on notice that any distribution of > > this message, in any form, is strictly prohibited. Please promptly > > notify the sender by reply e-mail or by telephone at 770-246-8600, and = then delete > or destroy all copies of the transmission. >=20 > Please consider the environment before printing this email. >=20 > The information contained in this message may be confidential and proprie= tary to > American Megatrends, Inc. This communication is intended to be read only= by the > individual or entity to whom it is addressed or by their designee. If the= reader of > this message is not the intended recipient, you are on notice that any di= stribution of > this message, in any form, is strictly prohibited. Please promptly notif= y the sender > by reply e-mail or by telephone at 770-246-8600, and then delete or destr= oy all copies > of the transmission. > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel