On Fri, Apr 28, 2023 at 3:47 AM JoeX Lu <[email protected]> wrote: > > CC: Michael D Kinney <[email protected]> > CC: Liming Gao <[email protected]> > CC: Zhiguang Liu <[email protected]> > Signed-off-by: JoeX Lu <[email protected]> > --- > 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: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
