public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pedro Falcato" <pedro.falcato@gmail.com>
To: devel@edk2.groups.io, pen-chunx.lu@intel.com
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	 Zhiguang Liu <zhiguang.liu@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support GLOBAL_REMOVE_IF_UNREFERENCED in GCC5/11
Date: Fri, 28 Apr 2023 05:46:53 +0100	[thread overview]
Message-ID: <CAKbZUD1w7Rh69ygtZmoQ9RGm-_G37DRqYh8xt5BH5goMYTNq=A@mail.gmail.com> (raw)
In-Reply-To: <20230428024637.34637-1-pen-chunx.lu@intel.com>

On Fri, Apr 28, 2023 at 3:47 AM JoeX Lu <pen-chunx.lu@intel.com> wrote:
>
> CC: Michael D Kinney <michael.d.kinney@intel.com>
> CC: Liming Gao <gaoliming@byosoft.com.cn>
> CC: Zhiguang Liu <zhiguang.liu@intel.com>
> Signed-off-by: JoeX Lu <pen-chunx.lu@intel.com>
> ---
>  MdePkg/Include/Base.h | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
> index 6597e441a6..951fce43ee 100644
> --- a/MdePkg/Include/Base.h
> +++ b/MdePkg/Include/Base.h
> @@ -45,8 +45,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  ///  to it after all compiler and linker optimizations have been performed.
>  ///
>  ///
> +#if defined (__GNUC__)
> +#define GLOBAL_REMOVE_IF_UNREFERENCED __attribute__((unused))

According to GCC and LLVM docs, unused does not affect codegen nor
linking, and only silences unused variable/member/function warnings
(-Wunused).
So this is not the attribute you want. This is only doable using LTO
or static, and LTO already does GLOBAL_REMOVE_IF_UNREFERENCED by
default (to *keep* unreferenced symbols, __attribute__((used)) *does*
work).

Note that it also does the right thing if it's a static variable and
it can verify that the current TU will not use it
(https://godbolt.org/z/GsP1TPb39).

-- 
Pedro

  reply	other threads:[~2023-04-28  4:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28  2:46 [PATCH] Support GLOBAL_REMOVE_IF_UNREFERENCED in GCC5/11 JoeX Lu
2023-04-28  4:46 ` Pedro Falcato [this message]
2023-04-28  5:53   ` [edk2-devel] " JoeX Lu
2023-05-04  6:58     ` 回复: " gaoliming
2023-05-05  0:04       ` [edk2-devel] " JoeX Lu
2023-05-05  3:15         ` 回复: " gaoliming
2023-05-05  4:47           ` [edk2-devel] " JoeX Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKbZUD1w7Rh69ygtZmoQ9RGm-_G37DRqYh8xt5BH5goMYTNq=A@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox