From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=210.71.195.43; helo=out01.hibox.biz; envelope-from=tim.lewis@insyde.com; receiver=edk2-devel@lists.01.org Received: from out01.hibox.biz (out03.hibox.biz [210.71.195.43]) (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 CE62720961828 for ; Fri, 18 May 2018 15:43:10 -0700 (PDT) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2C1AgAgVf9a/ws0GKxdGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYJNdkIffSiMV44TMQFdjj+FC4FkCxgBCggBhDoEAgKCECI4FAECAQE?= =?us-ascii?q?BAQEBAmwcDIUoAQEBBAEBBgIjKQgQCw0DAgYDDQQEAQEoBxkOARENAwEFCAIEE?= =?us-ascii?q?wsFgxWBG2QPq2oaAogrggoFigk/gQ+DDIMRAQSBNw5OhR4CjQSLSAcCAoFpg3+?= =?us-ascii?q?FD4Neh3SFCSuJNIcYgSUzIYFScFCCQz+KUYVeHzCBDQgMAYwWgkUBAQ?= X-IronPort-AV: E=Sophos;i="5.49,416,1520870400"; d="scan'208,217";a="21933026" Received: from unknown (HELO hb3-BKT201.hibox.biz) ([172.24.52.11]) by out01.hibox.biz with ESMTP; 19 May 2018 06:43:06 +0800 Received: from unknown (HELO hb3-BKT101.hibox.biz) ([172.24.51.11]) by hb3-BKT201.hibox.biz with ESMTP; 19 May 2018 06:43:06 +0800 Received: from unknown (HELO hb3-IN05.hibox.biz) ([172.24.12.15]) by hb3-BKT101.hibox.biz with ESMTP; 19 May 2018 06:43:06 +0800 X-Remote-IP: 73.116.1.175 X-Remote-Host: c-73-116-1-175.hsd1.ca.comcast.net X-SBRS: -10.0 X-MID: 13742644 X-Auth-ID: tim.lewis@insyde.com X-EnvelopeFrom: tim.lewis@insyde.com hiBox-Sender: 1 Received: from c-73-116-1-175.hsd1.ca.comcast.net (HELO DESKTOPAVHFBJF) ([73.116.1.175]) by hb3-IN05.hibox.biz with ESMTP/TLS/AES256-SHA; 19 May 2018 06:43:05 +0800 From: "Tim Lewis" To: Cc: References: <03b101d3eef6$a5f4dd90$f1de98b0$@insyde.com> <01146E3B-6B4F-4C58-B753-63BFD5ADF3E4@apple.com> In-Reply-To: <01146E3B-6B4F-4C58-B753-63BFD5ADF3E4@apple.com> Date: Fri, 18 May 2018 15:43:00 -0700 Message-ID: <040701d3eef9$95563a80$c002af80$@insyde.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-index: AQLYlypRxoOC2tdDZ/fv0SXMRf713QFGZ9mwoiKQfGA= X-Content-Filtered-By: Mailman/MimeDel 2.1.26 Subject: Re: Does __attribute__ ((selectany)) make sense now for GCC? X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 May 2018 22:43:11 -0000 Content-language: en-us Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Andrew - I know for Visual Studio it does the same thing for data that /Gy does for code. That is, if the data is unreferenced, then it doesn't get brought it. Maybe link-time code generation has the same effect. That's what I'm curious about. Tim From: afish@apple.com Sent: Friday, May 18, 2018 3:39 PM To: Tim Lewis Cc: edk2-devel@lists.01.org Subject: Re: [edk2] Does __attribute__ ((selectany)) make sense now for GCC? Tim, Looks like that is only available on Windows versions of GCC, and is more about compatible behavior. selectany The selectany attribute causes an initialized global variable to have link-once semantics. When multiple definitions of the variable are encountered by the linker, the first is selected and the remainder are discarded. Following usage by the Microsoft compiler, the linker is told not to warn about size or content differences of the multiple definitions. Although the primary usage of this attribute is for POD types, the attribute can also be applied to global C++ objects that are initialized by a constructor. In this case, the static initialization and destruction code for the object is emitted in each translation defining the object, but the calls to the constructor and destructor are protected by a link-once guard variable. The selectany attribute is only available on Microsoft Windows targets. You can use __declspec (selectany) as a synonym for __attribute__ ((selectany)) for compatibility with other compilers. What I've noticed with clang/LLVM is the unreferenced globals get removed when you enable link time optimizations. I'd actually ask the opposite question. Does __declspec(selectany) impact dead code removal on current versions of VC++? Thanks, Andrew Fish On May 18, 2018, at 3:22 PM, Tim Lewis > wrote: In Visual Studio we have __declspec(selectany) to limit the impact of unused data. I see that GCC for Windows has __attribute__ ((selectany)). Should we me using this for GLOBAL_REMOVE_IF_UNREFERENCED in MdePkg\Include\Base.h? Tim _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel