From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mx.groups.io with SMTP id smtpd.web11.12201.1682657225239410624 for ; Thu, 27 Apr 2023 21:47:05 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@gmail.com header.s=20221208 header.b=K5ZqayyM; spf=pass (domain: gmail.com, ip: 209.85.216.49, mailfrom: pedro.falcato@gmail.com) Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-246fd87a124so8067033a91.0 for ; Thu, 27 Apr 2023 21:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682657224; x=1685249224; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=giVzNhrXtq2Gb1geYEffrKTdBsp4SbZ0zTx0QIHtQdk=; b=K5ZqayyMmuGNho/e0tXrnJ06Bz9LEsjavcYDec1hJlF06NHGL2aFLpcbx+az+BVxF4 vTyF8Vri8I98eBuBdwiDRLSqq1Noo02Xn9DqnV9uE6FNYBNhUInIh/IwZrG84JR73/jf 2vVUwlpodYYuzqflEjXE4Jo8q/PiWVCcc19gfNvu6O+70mdKODTDqiBEZskt1uUhPPs6 g1WD/OnJBhvZmmzgtyTsZewVvKvShjWFRMpkSP7C5UKFqO9gO56UbZraloa470uFJYDe wGvSn6wI6CSTPNByoMmM/wRnhs6rMw66XuImJ9+i662v+QzB6oaAmFQUAKglqzGDazFN HK+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682657224; x=1685249224; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=giVzNhrXtq2Gb1geYEffrKTdBsp4SbZ0zTx0QIHtQdk=; b=CmBkN6LhcCIFIVMXNx3VL0BkQB9JrkG1Z/rZ6JJmUn7xadPw93lyIMUwb4T5Jy5/w/ dissXY2OMAxFV74fJydGGE5ny+PUHCzwN4NqFjKWI5fNYbTkuh2YLD3dlPKhjx+BnRCC d+3q8Jt5YXFBm+u046Qs0F0EqGBlL2jjVSs3YnaX9pl1r6KOaY9lRhAY6kGOJFtTd8TS gqyCgTAxi0G+ZB3Xbf29garDCcZiWyAD5+usx8Gzy4CgLhEGIOzLitXSG8O9FEL2qkAi uzKX/JorwhsrsZPftlQEbTTHVAmfDyLNQNadwoAyJ2YQAsL6bhBtB8QBJUis72m4Pg6u 62bw== X-Gm-Message-State: AC+VfDw3ClTfFrMRBKH0eMcyJu8f+MSwn/VLfXfgER/5gPv7d9L6qSrS XMvcFplYL5SiUitWWqeE3yswfGGSfzIyagQmqg+CgAUJ6pIthw== X-Google-Smtp-Source: ACHHUZ4zxp76N1gpXBskTiE6wTb1nVY5o13XJ9k6Nu0EpmkzWIFOjMmmCG7e5pIXFecpUBSah19ruqH/HKDFeH5N1/Y= X-Received: by 2002:a17:90b:390d:b0:24b:3123:8dd8 with SMTP id ob13-20020a17090b390d00b0024b31238dd8mr4249444pjb.27.1682657224363; Thu, 27 Apr 2023 21:47:04 -0700 (PDT) MIME-Version: 1.0 References: <20230428024637.34637-1-pen-chunx.lu@intel.com> In-Reply-To: <20230428024637.34637-1-pen-chunx.lu@intel.com> From: "Pedro Falcato" Date: Fri, 28 Apr 2023 05:46:53 +0100 Message-ID: Subject: Re: [edk2-devel] [PATCH] Support GLOBAL_REMOVE_IF_UNREFERENCED in GCC5/11 To: devel@edk2.groups.io, pen-chunx.lu@intel.com Cc: Michael D Kinney , Liming Gao , Zhiguang Liu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 28, 2023 at 3:47=E2=80=AFAM JoeX Lu wr= ote: > > CC: Michael D Kinney > CC: Liming Gao > CC: Zhiguang Liu > Signed-off-by: JoeX Lu > --- > 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 perform= ed. > /// > /// > +#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). --=20 Pedro