From: "Laszlo Ersek" <lersek@redhat.com>
To: Mike Beaton <mjsbeaton@gmail.com>
Cc: devel@edk2.groups.io, Ard Biesheuvel <ardb@kernel.org>,
Ard Biesheuvel <ardb@google.com>
Subject: Re: [edk2-devel] [PATCH] BaseTools/tools_def: Disable unneeded-internal-declaration warning in CLANGPDB
Date: Mon, 11 Dec 2023 17:22:08 +0100 [thread overview]
Message-ID: <12387048-80bf-87db-c15e-55583678863f@redhat.com> (raw)
In-Reply-To: <CAHzAAWQOcaKDhSu-AL6wW+BMCikLEa-oOhqBzRKh_L1c42_t-A@mail.gmail.com>
On 12/11/23 16:18, Mike Beaton wrote:
> I believe this would be logically wrong, as the other versions still
> wouldn't compile if you changed the relevant debug Pcds. (Which are
> logically independent of the compile and link options - e.g. what if for
> some reason you wanted to single step with the Debug Pcds set to
> disabled, in a NOOPT build?)
I don't think that use case exists in practice.
Anyway, my suggestion is based on prior art: I *think* we ask gcc to
whine about unused local variables in RELEASE builds only, too. See
commits 20d00edf21d2 ("BaseTools/GCC: set -Wno-unused-but-set-variables
only on RELEASE builds", 2016-03-25) and 8b6366f87584 ("BaseTools/GCC:
set -Wno-unused-const-variable on RELEASE builds", 2017-09-08).
... TBH I don't understand the current state of
"-Wno-unused-but-set-variables" and "-Wno-unused-const-variable" between
X64 and AARCH64, considering the DEBUG target. Today,
DEBUG_GCC5_AARCH64_CC_FLAGS disables these warnings, but
DEBUG_GCC5_X64_CC_FLAGS doesn't, even though *both* macros specify
-flto. Compare commit 06c8a34cc4bc ("BaseTool/tools_def GCC5: enable
optimization for ARM/AARCH64 DEBUG builds", 2017-12-08) -- I don't
understand why "-flto" had to be accompanied by
"-Wno-unused-but-set-variable -Wno-unused-const-variable" in that commit.
In brief, IA32 and X64 prior art supports my suggestion to shut up the
warning only for RELEASE (for CLANGPDB too), but ARM/AARCH64 prior art
contradicts that proposal. IOW, prior art is inconsistent per se... I
don't understand.
Laszlo
> On Mon, 11 Dec 2023, 15:00 Laszlo Ersek, <lersek@redhat.com
> <mailto:lersek@redhat.com>> wrote:
>
> On 12/10/23 11:18, Mike Beaton wrote:
> > From: Mike Beaton <mjsbeaton@gmail.com <mailto:mjsbeaton@gmail.com>>
> >
> > This warning was already disabled in CLANGDWARF by commit
> > d3225577123767fd09c91201d27e9c91663ae132.
> >
> > gcc can distinguish between optimised-away variable usage (as can
> occur in
> > valid debug code) and genuinely unused variables, and only
> complains about
> > the latter. clang cannot, and therefore this warning ends up
> complaining
> > about valid debug code under clang.
> >
> > Since EDK-II code is in general going to be compiled by gcc as
> well as clang
> > then disabling this warning in clang does not amount to entirely
> removing
> > potentially valid warnings about genuinely unused variables.
> >
> > Signed-off-by: Mike Beaton <mjsbeaton@gmail.com
> <mailto:mjsbeaton@gmail.com>>
> > ---
> > BaseTools/Conf/tools_def.template | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/BaseTools/Conf/tools_def.template
> b/BaseTools/Conf/tools_def.template
> > index c34ecfd557..48cf45245f 100755
> > --- a/BaseTools/Conf/tools_def.template
> > +++ b/BaseTools/Conf/tools_def.template
> > @@ -1754,7 +1754,7 @@ DEFINE CLANGPDB_X64_PREFIX =
> ENV(CLANG_BIN)
> > DEFINE CLANGPDB_IA32_TARGET = -target
> i686-unknown-windows-gnu
> > DEFINE CLANGPDB_X64_TARGET = -target
> x86_64-unknown-windows-gnu
> >
> > -DEFINE CLANGPDB_WARNING_OVERRIDES = -Wno-parentheses-equality
> -Wno-tautological-compare
> -Wno-tautological-constant-out-of-range-compare -Wno-empty-body
> -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option
> -Wno-unused-but-set-variable -Wno-unused-const-variable
> -Wno-unaligned-access -Wno-microsoft-enum-forward-reference
> > +DEFINE CLANGPDB_WARNING_OVERRIDES = -Wno-parentheses-equality
> -Wno-tautological-compare
> -Wno-tautological-constant-out-of-range-compare -Wno-empty-body
> -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option
> -Wno-unused-but-set-variable -Wno-unused-const-variable
> -Wno-unaligned-access -Wno-unneeded-internal-declaration
> -Wno-microsoft-enum-forward-reference
> > DEFINE CLANGPDB_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS)
> DEF(CLANGPDB_WARNING_OVERRIDES) -fno-stack-protector -funsigned-char
> -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang
> -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas
> -Wno-incompatible-library-redeclaration -Wno-null-dereference
> -mno-implicit-float -mms-bitfields -mno-stack-arg-probe -nostdlib
> -nostdlibinc -fseh-exceptions
> >
> > ###########################
>
> AFAICT, CLANGPDB_WARNING_OVERRIDES gets included in
> CLANGPDB_ALL_CC_FLAGS, which in turn gets included in all three of
> DEBUG, RELEASE and NOOPT build target flags.
>
> The original report was "RELEASE CLANGPDB OVMF currently does not
> compile".
>
> Can we use "-Wno-unneeded-internal-declaration" with RELEASE builds
> only?
>
> Thanks,
> Laszlo
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112316): https://edk2.groups.io/g/devel/message/112316
Mute This Topic: https://groups.io/mt/103087794/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-12-11 16:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-10 10:18 [edk2-devel] [PATCH] BaseTools/tools_def: Disable unneeded-internal-declaration warning in CLANGPDB Mike Beaton
2023-12-10 10:22 ` Mike Beaton
2023-12-10 10:25 ` Mike Beaton
2023-12-11 15:00 ` Laszlo Ersek
2023-12-11 15:18 ` Mike Beaton
2023-12-11 16:22 ` Laszlo Ersek [this message]
2023-12-11 17:26 ` Mike Beaton
2023-12-12 0:41 ` Laszlo Ersek
2023-12-12 7:17 ` Mike Beaton
2023-12-12 7:49 ` Ard Biesheuvel
2023-12-12 8:48 ` Mike Beaton
2023-12-12 10:12 ` Mike Beaton
2023-12-12 10:30 ` Mike Beaton
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=12387048-80bf-87db-c15e-55583678863f@redhat.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