From: "Mike Beaton" <mjsbeaton@gmail.com>
To: devel@edk2.groups.io
Cc: ardb@google.com, lersek@redhat.com, mcb30@ipxe.org,
mikhailkrichanov@gmail.com, Mike Beaton <mjsbeaton@gmail.com>
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 [thread overview]
Message-ID: <20231214072718.6406-1-mjsbeaton@gmail.com> (raw)
From: Mike Beaton <mjsbeaton@gmail.com>
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 <mjsbeaton@gmail.com>
---
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 = -Wl,--defsym=PECOFF_HEADER_SIZE=0x22
DEFINE CLANGDWARF_IA32_TARGET = -target i686-pc-linux-gnu
DEFINE CLANGDWARF_X64_TARGET = -target x86_64-pc-linux-gnu
-DEFINE CLANGDWARF_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligned-access -Wno-unneeded-internal-declaration
+DEFINE CLANGDWARF_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-unaligned-access
DEFINE CLANGDWARF_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANGDWARF_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference
###########################
diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.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
-=-=-=-=-=-=-=-=-=-=-=-
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]
-=-=-=-=-=-=-=-=-=-=-=-
next reply other threads:[~2023-12-14 7:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 7:27 Mike Beaton [this message]
2023-12-14 7:31 ` [edk2-devel] [PATCH 1/2] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined Mike Beaton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231214072718.6406-1-mjsbeaton@gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox