From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in6.apple.com (mail-out6.apple.com [17.151.62.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 305DB21BC6ADB for ; Mon, 27 Mar 2017 08:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1490629157; 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=SHVykiecvewzsuTJN+e0jj3A0hiyV0xk0l8DGTsI9Pc=; b=pEjJOlZ2079oQ/ZlEW3nncwq2mkwkeubAFyMmNUdPmrRVEGBAtHURStYlH/AcyM0 c4VpHleq+8Po3jjq1NmRyT8kI7xX0HHcd19KVngx3i5U6vIEnAiKeJRK600uUrf5 zw1R/Yi8r8j8PELO2msFBF60slOIvKEbTARugcGAHiLwFiOMSRINJZ9+4Y37uk3K tp7CZ5C8SdvQ/vOeTMxYeqlUszxK8mLLv14/EWDkqSIAg77JbcqmHr6jW2BqwGFp LcnGafjbL3SR3b+nOdDpFdz9q8l8d24h+CmzaJQVWg9KoF73f7DYBhaHYvi4Lmi7 QQOce6pgTEV1wrYLA7iW3A==; Received: from relay3.apple.com (relay3.apple.com [17.128.113.83]) by mail-in6.apple.com (Apple Secure Mail Relay) with SMTP id DD.49.29635.52239D85; Mon, 27 Mar 2017 08:39:17 -0700 (PDT) X-AuditID: 11973e15-3419d9a0000073c3-2c-58d93225c157 Received: from nwk-mmpp-sz09.apple.com (nwk-mmpp-sz09.apple.com [17.128.115.80]) by relay3.apple.com (Apple SCV relay) with SMTP id E9.94.03951.52239D85; Mon, 27 Mar 2017 08:39:17 -0700 (PDT) MIME-version: 1.0 Received: from [17.153.68.190] (unknown [17.153.68.190]) by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170210 64bit (built Feb 10 2017)) with ESMTPSA id <0ONH009ALCTGPE10@nwk-mmpp-sz09.apple.com>; Mon, 27 Mar 2017 08:39:17 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Mon, 27 Mar 2017 08:39:16 -0700 Cc: Felix Poludov , "Gao, Liming" , "edk2-devel@lists.01.org" Message-id: References: <9333E191E0D52B4999CE63A99BA663A002DEEEDA95@atlms1.us.megatrends.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14D702B8A@shsmsx102.ccr.corp.intel.com> <9333E191E0D52B4999CE63A99BA663A002DEEF126B@atlms1.us.megatrends.com> To: Mike Kinney X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsUi2FAYrKtqdDPCYP5XY4s9h44yW6z7co7V YsW9DewWHR3/mBxYPKZf+cXusXjPSyaP7tn/WAKYo7hsUlJzMstSi/TtErgyVj1oZi+4Y1Gx 4OUN5gbG03pdjJwcEgImEt927GUEsYUE9jJKzJ5XDhO/fruRrYuRCyh+kFHiyLoFTCAJXgFB iR+T77F0MXJwMAvISxw8LwsSZhbQkvj+qJUFon4ik8SirpNsIAlhAXGJd2c2MUPYeRKb998H s9kElCVWzP/ADjKHUyBM4tpFTZAwi4CqxP6FR5khxtdLfL+qD2LyCthILOiLgZi+nkniQ88W sE4RAR2J7pXRIKaEgKzE7F9eICUSAnvYJGatbWObwCg8C8nNsxBunoXk5gWMzKsYhXITM3N0 M/PM9BILCnJS9ZLzczcxgsJ9up3oDsYzq6wOMQpwMCrx8Grw34wQYk0sK67MPcQozcGiJM77 wv9qhJBAemJJanZqakFqUXxRaU5q8SFGJg5OqQbGBCerUHG+pocddtdvJzdzO6SuexMRNM9r UrjEgtl8T+6Luv3/dvDFsdhD9zeLJKY8e71E/cKG7aI+155uPuGR1Hn9WWmwfPnZg1YFb3N5 Az91BX3KcvN/y1+jZVP3td3xhDTDlnqGwj+vr2sv/Hdsdfkvx6CCj5NWRP83ynr42zVlz9XE a8d4lViKMxINtZiLihMBUV3YdlgCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBIsWRmVeSWpSXmKPExsUi2FAcoKtqdDPC4Np/fYs9h44yW6z7co7V YsW9DewWHR3/mBxYPKZf+cXusXjPSyaP7tn/WAKYo7hsUlJzMstSi/TtErgyVj1oZi+4Y1Gx 4OUN5gbG03pdjJwcEgImEtdvN7J1MXJxCAkcZJQ4sm4BE0iCV0BQ4sfkeyxdjBwczALyEgfP y4KEmQW0JL4/amWBqJ/IJLGo6yQbSEJYQFzi3ZlNzBB2nsTm/ffBbDYBZYkV8z+wg8zhFAiT uHZREyTMIqAqsX/hUWaI8fUS36/qg5i8AjYSC/piIKavZ5L40LMFrFNEQEeie2U0iCkhICsx +5fXBEaBWUjOnIVw5iwkZy5gZF7FKFCUmpNYaayXWFCQk6qXnJ+7iREcoIXBOxj/LLM6xCjA wajEw3uB52aEEGtiWXFl7iFGCQ5mJRHeb9xAId6UxMqq1KL8+KLSnNTiQ4xVQMdPZJYSTc4H Rk9eSbyhiYmBibGxmbGxuYk5VYSVxHm7vlyKEBJITyxJzU5NLUgtglnOxMEp1cAYcieX6STv 0wd+K6ReCG3UqP5dzmwq73JlnukHZ/XIxcbf/bvzJFNezncySv1eFnnr5KM5bRH1ap9nuhyX KI4xsRd9qcqRs8eX0d1KcZZEw6f9J1Te2S2r36p0Y1koo2bd8/JCzi2O1mu5vGZePf5wgx/b s8/TqvdI3XsV8qS/sSo+98G8UF4lluKMREMt5qLiRABY1F09qwIAAA== 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 15:39:18 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Mar 27, 2017, at 8:35 AM, Kinney, Michael D wrote: > > Felix, > > I prefer the default policy to break the build if multiple defined symbols are detected. > +1 Thanks, Andrew Fish > 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 VS 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 an 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 or 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] section. >> >> #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 linker. >>> 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_UNREFERENCED. >>> 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 =_declspec(selectany) >>> >>> >>> The advantages of these modifications are: >>> >>> - Better detection of on potential errors by breaking the build 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/214a3b79417f64bf2faae74af42c1 >>> 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 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel