From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 325C3AC0E3F for ; Tue, 12 Dec 2023 09:26:24 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=JgasbtThBwwFlFq0ADVu1hRwHQLp92zZGFDasKRMBxw=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1702373183; v=1; b=l+6d2FKgq72/VKiZ236GEqHig99NP3WHQZNQFAFaH/95Q+OeNEOsb96QRHH63bBjFcUZaPts lMUOhq/HhqQTth7msXR5afOWEj71tboo1gmsTROYOtYNJBnB/FPUW02EkdD2rLjHlZnGewSE5Gi uQh3C389bXrNxULoQvzdoaGo= X-Received: by 127.0.0.2 with SMTP id bJKdYY7687511xFbRtAfPsk1; Tue, 12 Dec 2023 01:26:23 -0800 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.12956.1702373183140659094 for ; Tue, 12 Dec 2023 01:26:23 -0800 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6D2AB61721 for ; Tue, 12 Dec 2023 09:26:22 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B5D4C433C8 for ; Tue, 12 Dec 2023 09:26:22 +0000 (UTC) X-Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2ca00dffc23so68245951fa.2 for ; Tue, 12 Dec 2023 01:26:22 -0800 (PST) X-Gm-Message-State: BaazaHLJ7pI0mwAlTxLlSw8dx7686176AA= X-Google-Smtp-Source: AGHT+IGN0XrWLlUf5Nhk1LSQdoPQ9vIddBOctp5d+jYsjDvGZuJaB6vbhFNBXpTOvL5OLQMccGYfzlsGZnFJuh6p/M4= X-Received: by 2002:a05:651c:229:b0:2c9:ee73:9198 with SMTP id z9-20020a05651c022900b002c9ee739198mr2150588ljn.94.1702373180327; Tue, 12 Dec 2023 01:26:20 -0800 (PST) MIME-Version: 1.0 References: <20231212084856.118099-1-mjsbeaton@gmail.com> In-Reply-To: <20231212084856.118099-1-mjsbeaton@gmail.com> From: "Ard Biesheuvel" Date: Tue, 12 Dec 2023 10:26:09 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH] DebugLib: Allow -Wunneeded-internal-declaration with clang To: devel@edk2.groups.io, mjsbeaton@gmail.com Cc: ardb@google.com, lersek@redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=l+6d2FKg; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Tue, 12 Dec 2023 at 09:49, Mike Beaton wrote: > > From: Mike Beaton > > Provides a variant of the DEBUG macro for clang when MDEPKG_NDEBUG is def= ined, > which uses but discards the contained expression, this means clang can te= ll > that it has optimised away variable usage, therefore we can keep > -Wunneeded-internal-declaration (as part of -Wall) to warn about any > mistakenly genuinely unused variables. > > Signed-off-by: Mike Beaton You failed to mention where you found this patch. > --- > BaseTools/Conf/tools_def.template | 2 +- > MdePkg/Include/Library/DebugLib.h | 10 ++++++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def= .template > index c34ecfd557..eaccf0b698 100755 > --- a/BaseTools/Conf/tools_def.template > +++ b/BaseTools/Conf/tools_def.template > @@ -1859,7 +1859,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS =3D -Wl,-= -defsym=3DPECOFF_HEADER_SIZE=3D0x22 > DEFINE CLANGDWARF_IA32_TARGET =3D -target i686-pc-linux-gnu > DEFINE CLANGDWARF_X64_TARGET =3D -target x86_64-pc-linux-gn= u > > -DEFINE CLANGDWARF_WARNING_OVERRIDES =3D -Wno-parentheses-equality -Wn= o-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-o= ption -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligne= d-access -Wno-unneeded-internal-declaration > +DEFINE CLANGDWARF_WARNING_OVERRIDES =3D -Wno-parentheses-equality -Wn= o-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-o= ption -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligne= d-access > DEFINE CLANGDWARF_ALL_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) DEF(C= LANGDWARF_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-addre= ss -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library= -redeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-flo= at -mno-implicit-float -ftrap-function=3Dundefined_behavior_has_been_optim= ized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference > > ########################### > diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/D= ebugLib.h > index f0c9f64487..e2158b1a3d 100644 > --- a/MdePkg/Include/Library/DebugLib.h > +++ b/MdePkg/Include/Library/DebugLib.h > @@ -425,6 +425,16 @@ UnitTestDebugAssert ( > _DEBUG (Expression); \ > } \ > } while (FALSE) > +#elif defined (__clang__) > +#define DEBUG(Expression) \ > + do { \ > + _Pragma("GCC diagnostic push") \ > + _Pragma("GCC diagnostic ignored \"-Wunused-value\"") \ This seems redundant to me. Either we set the pragma and the compiler does not care, or we don't, and rely on the fact that the compiler can infer that 'Expression' will never be evaluated at runtime, but won't complain about symbols that are only referenced via 'Expression' and nowhere else. > + if ((FALSE)) { \ > + (VOID) Expression; \ > + } \ > + _Pragma("GCC diagnostic pop") \ > + } while (FALSE) > #else > #define DEBUG(Expression) > #endif > -- > 2.39.2 > > > > ------------ > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#112363): https://edk2.groups.io/g/devel/message/11236= 3 > Mute This Topic: https://groups.io/mt/103126777/5717338 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [ardb+tianocore@kernel.= org] > ------------ > > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112366): https://edk2.groups.io/g/devel/message/112366 Mute This Topic: https://groups.io/mt/103126777/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-