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 8ECF3D80225 for ; Thu, 14 Dec 2023 07:44:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=GspNOBsJqtXI1dTv8+8Cr8L7zWT0xdh+BZS2Ez4NNeE=; 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=1702539839; v=1; b=APstX/c3BQh64YSMFU9nYX32gsyQDlyuy4ogEF6Mu26qHk+iiHJSKtJTE7ZvVVBceTlD/dVU dKg6VLPJPVDQq1Eo3E4dVXdd6q49SOL+dqiosrnjt7pO/u7lfrIUj43N7l69AJZYCjFVwPRaBCp kPMBwBqPstZAdE39/hhNaIN0= X-Received: by 127.0.0.2 with SMTP id VjaIYY7687511xj85F42zcHL; Wed, 13 Dec 2023 23:43:59 -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.17045.1702539838491124917 for ; Wed, 13 Dec 2023 23:43:58 -0800 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E15B6620EA for ; Thu, 14 Dec 2023 07:43:57 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91E0AC433CA for ; Thu, 14 Dec 2023 07:43:57 +0000 (UTC) X-Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2c9f4bb2e5eso107980171fa.1 for ; Wed, 13 Dec 2023 23:43:57 -0800 (PST) X-Gm-Message-State: EoRBW41Xvxk0tzVcvz6OdO2ox7686176AA= X-Google-Smtp-Source: AGHT+IEJt/VQJUOZikSWzIa6rJbkklXinq80pQyrSRUvx6b+iVcGN4jUgEddkLKqe8BAmK3xrk4fb+K6orK+k7Kh9NU= X-Received: by 2002:a05:651c:1057:b0:2ca:e7:aeb1 with SMTP id x23-20020a05651c105700b002ca00e7aeb1mr3623997ljm.77.1702539835749; Wed, 13 Dec 2023 23:43:55 -0800 (PST) MIME-Version: 1.0 References: <20231213230741.168859-1-mjsbeaton@gmail.com> In-Reply-To: <20231213230741.168859-1-mjsbeaton@gmail.com> From: "Ard Biesheuvel" Date: Thu, 14 Dec 2023 08:43:44 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH V3] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined To: devel@edk2.groups.io, mjsbeaton@gmail.com, Rebecca Cran , "Liming Gao (Byosoft address)" , Michael Kinney , Andrew Fish Cc: 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="APstX/c3"; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) (cc MdePkg and BaseTools maintainers) On Thu, 14 Dec 2023 at 00:08, Mike Beaton wrote: > > From: Mike Beaton > > The variant provided when MDEPKG_NDEBUG is defined will be optimised > away in RELEASE builds, but by referencing the argument list, avoids > unused variable errors from valid debug code, for example when STATIC > variables are used only in DEBUG statements. > > Signed-off-by: Mike Beaton I think this is an improvement, but others should confirm that other toolchains are happy with this too (the change is no longer specific to clang) > --- > BaseTools/Conf/tools_def.template | 2 +- > MdePkg/Include/Library/DebugLib.h | 7 ++++++- > 2 files changed, 7 insertions(+), 2 deletions(-) > > 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 40772f2e0f..bc7789f01c 100644 > --- a/MdePkg/Include/Library/DebugLib.h > +++ b/MdePkg/Include/Library/DebugLib.h > @@ -426,7 +426,12 @@ UnitTestDebugAssert ( > } \ > } while (FALSE) > #else > -#define DEBUG(Expression) > +#define DEBUG(Expression) \ > + do { \ > + if (FALSE) { \ > + _DEBUG (Expression); \ > + } \ > + } while (FALSE) > #endif > > /** > -- > 2.39.2 > > > >=20 > > -=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 (#112505): https://edk2.groups.io/g/devel/message/112505 Mute This Topic: https://groups.io/mt/103160238/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-