From nobody Wed May 15 17:45:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+112510+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112510+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702545127; cv=none; d=zohomail.com; s=zohoarc; b=Rq3gPAfAIHQn21yLxtyoaLQS42srhb1AQQ9zS7/O3keHs8D6uD3b0KKDw5Rj4AW/KvaLiWWdVQL2Mb142rh02s4SXcPs1F3sBBIuE+mKMB0f8HW8eiEj++lTEQMjRS5ZPOQMapgNci93BMExG8B1h2XD2pluk/ZSQGotlFIXPbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702545127; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=e3IUWfMELff5vuDQMhxuCcUX3Y1LJgoRImObg9Kx9JA=; b=B4n79I941/DgFEr4e4RNM/vrEviS4fTK+f8/m2mK2HfYIse6azu5iw1ExskoIEkM2Y1+ANNH3687zXkWoBO1JgpL4ISGMdAaqN0xai9Upa6ZvNCmvuiaNpaW4PllkuBOrikE/a6iWO0mSvu2fI0R3m2C+pGke1gDPdapkJnNa+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112510+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1702545127615381.3080175489114; Thu, 14 Dec 2023 01:12:07 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=0eGqqCkvwPnObJBxdkXTSw2pluZW+IRxVFto/1p7zPQ=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1702545127; v=1; b=GKGZ/mzfOjhOuvul+lflYVrlczovcSPwaiGxRGZmBLNZx2ono1N3/I68tC8dx+GaSB7ZLFoi hqe6uoY906GgFJf7hlpXVmDSJn4ZmRoCoJGm+W8gkqE85EdKZz2ze5S95cNd46aoIn9EXey3InU PHgTJhI5OYx99gtLDLUcqDs8= X-Received: by 127.0.0.2 with SMTP id 5s0LYY1788612xDkwnETINgB; Thu, 14 Dec 2023 01:12:07 -0800 X-Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mx.groups.io with SMTP id smtpd.web11.18008.1702545126130740794 for ; Thu, 14 Dec 2023 01:12:06 -0800 X-Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-336445a2749so635202f8f.0 for ; Thu, 14 Dec 2023 01:12:05 -0800 (PST) X-Gm-Message-State: D5GFciDHvGEPIQC5pmCQXpGxx1787277AA= X-Google-Smtp-Source: AGHT+IG8uP7tVF/4bTGjlajU6c1dFQAO0PIPSnw+SCabzZH5Ss61FaVHs5Db3gzZ7lOvREKtTvxZtg== X-Received: by 2002:adf:e34a:0:b0:332:de0f:d7be with SMTP id n10-20020adfe34a000000b00332de0fd7bemr4635284wrj.18.1702545123653; Thu, 14 Dec 2023 01:12:03 -0800 (PST) X-Received: from mikes-OptiPlex-3070.lan ([209.240.0.204]) by smtp.gmail.com with ESMTPSA id w18-20020a5d5452000000b00336367631efsm4586177wrv.65.2023.12.14.01.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 01:12:03 -0800 (PST) From: "Mike Beaton" To: devel@edk2.groups.io Cc: ardb@google.com, lersek@redhat.com, rebecca@bsdio.com, gaoliming@byosoft.com.cn, michael.d.kinney@intel.com, afish@apple.com, Mike Beaton Subject: [edk2-devel] [PATCH V6] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined Date: Thu, 14 Dec 2023 09:11:47 +0000 Message-Id: <20231214091146.5034-1-mjsbeaton@gmail.com> MIME-Version: 1.0 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,mjsbeaton@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1702545129491100001 Content-Type: text/plain; charset="utf-8" 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. This issue was being caused by variable EventNames in OvmfPkg/VirtioSerialDxe/VirtioSerial.c in CLANGPDB X64 RELEASE build prior to this commit, and was also being caused by the same variable in CLANGDWARF X64 RELEASE build, prior to d3225577123767fd09c91201d27e9c91663ae132 - which we revert, restoring the desirable feature of failure to build on genuinely (unintentionally) unused variables when building in either clang toolchain. Also change manual exclusion of debug vars when MDEPKG_NDEBUG is not defined in a similar cases in ArmPkg, 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 --- .../DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c | 4 ++-- .../AArch64/DefaultExceptionHandler.c | 3 --- BaseTools/Conf/tools_def.template | 2 +- MdePkg/Include/Library/DebugLib.h | 7 ++++++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActio= nLib.c b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib= .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__) CHAR8 Temp[512]; #endif =20 @@ -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 =20 diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExcep= tionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultEx= ceptionHandler.c index a39896d576..1d3ea61311 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHan= dler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHan= dler.c @@ -157,7 +157,6 @@ DescribeExceptionSyndrome ( DEBUG ((DEBUG_ERROR, "\n %a \n", Message)); } =20 -#ifndef MDEPKG_NDEBUG STATIC CONST CHAR8 * BaseName ( @@ -177,8 +176,6 @@ BaseName ( return Str; } =20 -#endif - /** This is the default action to take on an unexpected exception =20 diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate 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,--d= efsym=3DPECOFF_HEADER_SIZE=3D0x22 DEFINE CLANGDWARF_IA32_TARGET =3D -target i686-pc-linux-gnu DEFINE CLANGDWARF_X64_TARGET =3D -target x86_64-pc-linux-gnu =20 -DEFINE CLANGDWARF_WARNING_OVERRIDES =3D -Wno-parentheses-equality -Wno-= empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-opt= ion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligned-= access -Wno-unneeded-internal-declaration +DEFINE CLANGDWARF_WARNING_OVERRIDES =3D -Wno-parentheses-equality -Wno-= empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-opt= ion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligned-= access DEFINE CLANGDWARF_ALL_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) DEF(CLA= NGDWARF_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address= -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-r= edeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float= -mno-implicit-float -ftrap-function=3Dundefined_behavior_has_been_optimiz= ed_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference =20 ########################### diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/Deb= ugLib.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 =20 /** --=20 2.39.2 -=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 (#112510): https://edk2.groups.io/g/devel/message/112510 Mute This Topic: https://groups.io/mt/103166935/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-