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 46A0FAC0E35 for ; Thu, 14 Dec 2023 07:27:24 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=25HBbOUD5RSReWcadR6/eK3tjdOJKpaIPd13avhVpnw=; 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=1702538843; v=1; b=thVMfBsaq9CqXrrpk7+YP7HIeoVVZfThAx9ypKWvs151sfu3GIpvHRHk3lsmQUoBCR0OTlUi YtTPmr/aY3Z1eah9BlSzDQf92CIoJ0+/QCqqPVRdDujlr+8k49/19kjIhNWnoMgIZK/HMYi/i5S p9Apjex06GL/I4V6BvVa6Yx4= X-Received: by 127.0.0.2 with SMTP id YrV4YY7687511xkvCBFL6vfy; Wed, 13 Dec 2023 23:27:23 -0800 X-Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mx.groups.io with SMTP id smtpd.web10.16920.1702538841902297330 for ; Wed, 13 Dec 2023 23:27:22 -0800 X-Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-33642523623so1025038f8f.2 for ; Wed, 13 Dec 2023 23:27:21 -0800 (PST) X-Gm-Message-State: nnkafX3Qjqc15d3JADV6M1gCx7686176AA= X-Google-Smtp-Source: AGHT+IFUMclrkdO5jFG9r8s8dBHtndN9SWRb7sQPVCPMR0OVIg1GUKx5Vh4prttyRd/bgF7ukWuxhw== X-Received: by 2002:adf:ea48:0:b0:333:2fd2:6f5f with SMTP id j8-20020adfea48000000b003332fd26f5fmr4950051wrn.105.1702538839155; Wed, 13 Dec 2023 23:27:19 -0800 (PST) X-Received: from mikes-OptiPlex-3070.lan ([209.240.0.204]) by smtp.gmail.com with ESMTPSA id u10-20020a5d434a000000b0033342338a24sm15407972wrr.6.2023.12.13.23.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 23:27:18 -0800 (PST) From: "Mike Beaton" To: devel@edk2.groups.io Cc: ardb@google.com, lersek@redhat.com, mcb30@ipxe.org, mikhailkrichanov@gmail.com, Mike Beaton Subject: [edk2-devel] [PATCH 1/2] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined Date: Thu, 14 Dec 2023 07:27:17 +0000 Message-Id: <20231214072718.6406-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-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=thVMfBsa; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (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 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. Variables EventNames in OvmfPkg/VirtioSerialDxe/VirtioSerial.c was causing this issue in CLANGPDB X64 RELEASE build, prior to this commit. It is also necessary to remove manual work-arounds which had been applied to some similar cases in ArmPkg (see following commit). Signed-off-by: Mike Beaton --- 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.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=0D DEFINE CLANGDWARF_X64_TARGET =3D -target x86_64-pc-linux-gnu= =0D =0D -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=0D +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=0D 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=0D =0D ###########################=0D 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 ( } \=0D } while (FALSE)=0D #else=0D -#define DEBUG(Expression)=0D +#define DEBUG(Expression) \=0D + do { \=0D + if (FALSE) { \=0D + _DEBUG (Expression); \=0D + } \=0D + } while (FALSE)=0D #endif=0D =0D /**=0D --=20 2.39.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112499): https://edk2.groups.io/g/devel/message/112499 Mute This Topic: https://groups.io/mt/103166248/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-