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 2A613D80851 for ; Thu, 14 Dec 2023 08:20:28 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=R8De9GlI+/YV0bullip50SLrCXTVGHM/vdWUQZy/Qns=; 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=1702542027; v=1; b=ckqN7MUtSKW0HAJUHtuYBK+U2ee0dT6RhkcA4RVe3W0QRkFjCPO4aEdRrfMpjAMOZE6kZMmH RhqJun99fBzsr9Dw+Sg+WGkCyWHfnWbiSJ6vwcga2uZNBPHex29i/hWUWo1KoGAaEFIhhktvUNV QK+Uyuz2PVFtZefzaXK/lT1c= X-Received: by 127.0.0.2 with SMTP id fQD2YY7687511x4utEEeEISP; Thu, 14 Dec 2023 00:20:27 -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.17463.1702542026822425008 for ; Thu, 14 Dec 2023 00:20:27 -0800 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 17580620F8 for ; Thu, 14 Dec 2023 08:20:26 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80765C433CC for ; Thu, 14 Dec 2023 08:20:25 +0000 (UTC) X-Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2ca0c36f5beso102307441fa.1 for ; Thu, 14 Dec 2023 00:20:25 -0800 (PST) X-Gm-Message-State: 2YvoqV08apvW2el8ibhzJF6Jx7686176AA= X-Google-Smtp-Source: AGHT+IGuuxaasvyXtZFosX74TwrL/573p9/SBnQ468rfGguyYHihKMWk9Ilh2w9U0s0hz/bdKxDEW5JWL8yl9+lMTTE= X-Received: by 2002:a2e:b889:0:b0:2cc:3da1:8e34 with SMTP id r9-20020a2eb889000000b002cc3da18e34mr883152ljp.54.1702542023562; Thu, 14 Dec 2023 00:20:23 -0800 (PST) MIME-Version: 1.0 References: <20231214075748.9682-1-mjsbeaton@gmail.com> In-Reply-To: <20231214075748.9682-1-mjsbeaton@gmail.com> From: "Ard Biesheuvel" Date: Thu, 14 Dec 2023 09:20:12 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH V5] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined To: devel@edk2.groups.io, mjsbeaton@gmail.com, Michael Kubacki Cc: lersek@redhat.com, rebecca@bsdio.com, gaoliming@byosoft.com.cn, michael.d.kinney@intel.com, afish@apple.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=ckqN7MUt; 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 Michael) On Thu, 14 Dec 2023 at 08:58, 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. > > Variable EventNames in OvmfPkg/VirtioSerialDxe/VirtioSerial.c > was causing this issue in CLANGPDB X64 RELEASE build, prior to this > commit. > > We also change manual exclusion of debug vars when MDEPKG_NDEBUG is > not defined, in a similar case in > ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c > to inclusion when used regardless of MDEPKG_NDEBUG (the revised DEBUG > macro automatically compiles away unused variable accesses, but there > has to be a variable, access to which to discard). > > Signed-off-by: Mike Beaton Hi Mike, I'd prefer to have some discussion with the various maintainers first - shooting off a new version of your patch every time anyone asks a question is only going to confuse people. IOW, please don't send a v6 until the discussion comes to a conclusion. > --- > .../DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c | 4 ++-- > .../AArch64/DefaultExceptionHandler.c | 3 --- > BaseTools/Conf/tools_def.template | 2 +- > MdePkg/Include/Library/DebugLib.h | 7 ++++++- These are going to have to be separate patches in any case, even the MdePkg one and BaseTools changes will need to be split. So the question is really whether the MdePkg change is palatable to the maintainers and to the users of other toolchains. Then, we can talk about how to phase the remaining changes so we don't break the ARM build. > 4 files changed, 9 insertions(+), 7 deletions(-) > > diff --git a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraAct= ionLib.c b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionL= ib.c > index 432112354f..c5c53ef3e1 100644 > --- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.= c > +++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.= c > @@ -71,7 +71,7 @@ PeCoffLoaderRelocateImageExtraAction ( > IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext > ) > { > - #if !defined (MDEPKG_NDEBUG) > + #if defined (__CC_ARM) || defined (__GNUC__) No, this is not going to be acceptable to me. You noted that only the ARM code seems to suffer from this issue, so surely, we can find a way to change this code that doesn't introduce spurious dependencies on the exact toolchain we are using. > CHAR8 Temp[512]; > #endif > > @@ -106,7 +106,7 @@ PeCoffLoaderUnloadImageExtraAction ( > IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext > ) > { > - #if !defined (MDEPKG_NDEBUG) > + #if defined (__CC_ARM) || defined (__GNUC__) > CHAR8 Temp[512]; > #endif > > diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExc= eptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/Default= ExceptionHandler.c > index a39896d576..1d3ea61311 100644 > --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionH= andler.c > +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionH= andler.c > @@ -157,7 +157,6 @@ DescribeExceptionSyndrome ( > DEBUG ((DEBUG_ERROR, "\n %a \n", Message)); > } > > -#ifndef MDEPKG_NDEBUG > STATIC > CONST CHAR8 * > BaseName ( > @@ -177,8 +176,6 @@ BaseName ( > return Str; > } > > -#endif > - > /** > This is the default action to take on an unexpected exception > > 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 (#112508): https://edk2.groups.io/g/devel/message/112508 Mute This Topic: https://groups.io/mt/103166459/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-