On Fri, Apr 28, 2023 at 3:47 AM JoeX Lu <pen-chunx...@intel.com> wrote: > > CC: Michael D Kinney <michael.d.kin...@intel.com> > CC: Liming Gao <gaolim...@byosoft.com.cn> > CC: Zhiguang Liu <zhiguang....@intel.com> > Signed-off-by: JoeX Lu <pen-chunx...@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 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103747): https://edk2.groups.io/g/devel/message/103747 Mute This Topic: https://groups.io/mt/98551348/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-