* [PATCH 0/2] Reduce the ASSERT patch to save the binary size
@ 2022-02-18 2:30 Guomin Jiang
2022-02-18 2:30 ` [PATCH 1/2] BaseTools/Conf: " Guomin Jiang
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Guomin Jiang @ 2022-02-18 2:30 UTC (permalink / raw)
To: devel
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
1. Use DEBUG_FILE to control ASSERT path
2. Default use file name as ASSERT path
Motivation and Goal:
1. The path will occupy many size in DEBUG build when file path is long
2. We hope can reduce the size but not impact the debug capability
3. If only use filename, we can search the filename to locate file. It
can save many size meanwhile.
Guomin Jiang (2):
BaseTools/Conf: Reduce the ASSERT patch to save the binary size
MdePkg/Include: Define new DEBUG_FILE to specify path.
BaseTools/Conf/build_rule.template | 10 ++++----
MdePkg/Include/Library/DebugLib.h | 39 +++++++++++++++++++++---------
2 files changed, 33 insertions(+), 16 deletions(-)
--
2.35.1.windows.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size
2022-02-18 2:30 [PATCH 0/2] Reduce the ASSERT patch to save the binary size Guomin Jiang
@ 2022-02-18 2:30 ` Guomin Jiang
2022-02-28 9:52 ` Bob Feng
2022-02-18 2:30 ` [PATCH 2/2] MdePkg/Include: Define new DEBUG_FILE to specify path Guomin Jiang
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Guomin Jiang @ 2022-02-18 2:30 UTC (permalink / raw)
To: devel; +Cc: Bob Feng, Liming Gao, Yuwei Chen
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
Use DEBUG_FILE to control ASSERT path
Motivation and Goal:
1. The path will occupy many size in DEBUG build when file path is long
2. We hope can reduce the size but not impact the debug capability
3. If only use filename, we can search the filename to locate file. It
can save many size meanwhile.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
BaseTools/Conf/build_rule.template | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template
index f40118234471..ad0bae42be62 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -126,14 +126,14 @@
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
<Command.MSFT, Command.INTEL>
- "$(CC)" /Fo${dst} $(DEPS_FLAGS) $(CC_FLAGS) $(INC) ${src}
+ "$(CC)" /Fo${dst} $(DEPS_FLAGS) /D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS) $(INC) ${src}
<Command.GCC, Command.RVCT>
# For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues
- "$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
+ "$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
<Command.XCODE>
- "$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -o ${dst} $(INC) ${src}
+ "$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS) -o ${dst} $(INC) ${src}
[C-Code-File.BASE.AARCH64,C-Code-File.SEC.AARCH64,C-Code-File.PEI_CORE.AARCH64,C-Code-File.PEIM.AARCH64,C-Code-File.BASE.ARM,C-Code-File.SEC.ARM,C-Code-File.PEI_CORE.ARM,C-Code-File.PEIM.ARM]
<InputFile>
@@ -146,7 +146,7 @@
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
<Command.GCC, Command.RVCT>
- "$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
+ "$(CC)" -D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
[C-Header-File]
<InputFile>
--
2.35.1.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] MdePkg/Include: Define new DEBUG_FILE to specify path.
2022-02-18 2:30 [PATCH 0/2] Reduce the ASSERT patch to save the binary size Guomin Jiang
2022-02-18 2:30 ` [PATCH 1/2] BaseTools/Conf: " Guomin Jiang
@ 2022-02-18 2:30 ` Guomin Jiang
2022-02-18 3:33 ` [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size Michael D Kinney
[not found] ` <16D4C08DC1603ADF.6551@groups.io>
3 siblings, 0 replies; 9+ messages in thread
From: Guomin Jiang @ 2022-02-18 2:30 UTC (permalink / raw)
To: devel; +Cc: Michael D Kinney, Liming Gao, Zhiguang Liu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
Use DEBUG_FILE to control ASSERT path
Motivation and Goal:
1. The path will occupy many size in DEBUG build when file path is long
2. We hope can reduce the size but not impact the debug capability
3. If only use filename, we can search the filename to locate file. It
can save many size meanwhile.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
MdePkg/Include/Library/DebugLib.h | 39 ++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h
index 8d3d08638d73..5469c6308422 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -8,7 +8,7 @@
of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
defined, then debug and assert related macros wrapped by it are the NULL implementations.
-Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -85,6 +85,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define DEBUG_LINE_NUMBER __LINE__
#endif
+//
+// Source file.
+// Default is use the to compiler provided __FILE__ macro value. The __FILE__
+// mapping can be overriden by predefining DEBUG_FILE
+//
+// Defining DEBUG_FILE to a fixed value is useful when comparing builds
+// across machine or configuration with different slash or path
+// file.
+//
+// Another benefit is we can customize the ASSERT path without depending on
+// compiler ability
+//
+// It's for all no matter VS, GCC, CLANG
+//
+#ifdef DEBUG_FILE
+#else
+#define DEBUG_FILE __FILE__
+#endif
+
+// Blow override for keep clang behavior
+#if defined (__clang__) && defined (__FILE_NAME__)
+#undef DEBUG_FILE
+#define DEBUG_FILE __FILE_NAME__
+#endif
+
/**
Macro that converts a Boolean expression to a Null-terminated ASCII string.
@@ -337,17 +362,9 @@ UnitTestDebugAssert (
IN CONST CHAR8 *Description
);
- #if defined (__clang__) && defined (__FILE_NAME__)
-#define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
- #else
-#define _ASSERT(Expression) UnitTestDebugAssert (__FILE__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
- #endif
+#define _ASSERT(Expression) UnitTestDebugAssert (DEBUG_FILE, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
#else
- #if defined (__clang__) && defined (__FILE_NAME__)
-#define _ASSERT(Expression) DebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
- #else
-#define _ASSERT(Expression) DebugAssert (__FILE__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
- #endif
+#define _ASSERT(Expression) DebugAssert (DEBUG_FILE, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
#endif
/**
--
2.35.1.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size
2022-02-18 2:30 [PATCH 0/2] Reduce the ASSERT patch to save the binary size Guomin Jiang
2022-02-18 2:30 ` [PATCH 1/2] BaseTools/Conf: " Guomin Jiang
2022-02-18 2:30 ` [PATCH 2/2] MdePkg/Include: Define new DEBUG_FILE to specify path Guomin Jiang
@ 2022-02-18 3:33 ` Michael D Kinney
2022-02-21 1:30 ` Guomin Jiang
[not found] ` <16D4C08DC1603ADF.6551@groups.io>
3 siblings, 1 reply; 9+ messages in thread
From: Michael D Kinney @ 2022-02-18 3:33 UTC (permalink / raw)
To: devel@edk2.groups.io, Jiang, Guomin, Kinney, Michael D
Guomin,
I think there is a cleaner solution to this problem using
compiler flags to change the contents of the __FILE__ macro.
https://blog.conan.io/2019/09/02/Deterministic-builds-with-C-C++.html
https://reproducible-builds.org/docs/build-path/
https://developercommunity.visualstudio.com/t/map-file-to-a-relative-path/1393881
I found this content when I was working on the CompareBuild tool
and using these techniques can guarantee the same binaries are
produced when the path to WORKSPACE is different on different
build systems.
Does your change provide a module-relative, package-relative,
or workspace-relative file path in the ASSERT()?
How does ASSERT() in autogen work?
Thanks,
Mike
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin Jiang
> Sent: Thursday, February 17, 2022 6:30 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
>
> 1. Use DEBUG_FILE to control ASSERT path
> 2. Default use file name as ASSERT path
>
> Motivation and Goal:
> 1. The path will occupy many size in DEBUG build when file path is long
> 2. We hope can reduce the size but not impact the debug capability
> 3. If only use filename, we can search the filename to locate file. It
> can save many size meanwhile.
>
> Guomin Jiang (2):
> BaseTools/Conf: Reduce the ASSERT patch to save the binary size
> MdePkg/Include: Define new DEBUG_FILE to specify path.
>
> BaseTools/Conf/build_rule.template | 10 ++++----
> MdePkg/Include/Library/DebugLib.h | 39 +++++++++++++++++++++---------
> 2 files changed, 33 insertions(+), 16 deletions(-)
>
> --
> 2.35.1.windows.2
>
>
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size
2022-02-18 3:33 ` [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size Michael D Kinney
@ 2022-02-21 1:30 ` Guomin Jiang
2022-03-01 1:47 ` 回复: " gaoliming
0 siblings, 1 reply; 9+ messages in thread
From: Guomin Jiang @ 2022-02-21 1:30 UTC (permalink / raw)
To: Kinney, Michael D, devel@edk2.groups.io
Comment inline
Thank
Guomin
> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Friday, February 18, 2022 11:34 AM
> To: devel@edk2.groups.io; Jiang, Guomin <guomin.jiang@intel.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>
> Subject: RE: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the
> binary size
>
> Guomin,
>
> I think there is a cleaner solution to this problem using compiler flags to
> change the contents of the __FILE__ macro.
Thanks for your information. It is useful.
1. From the link, it seem that the VS haven't support it yet.
2. From my though, It is not good solution that we have strong depend on compiler.
>
> https://blog.conan.io/2019/09/02/Deterministic-builds-with-C-C++.html
> https://reproducible-builds.org/docs/build-path/
> https://developercommunity.visualstudio.com/t/map-file-to-a-relative-
> path/1393881
>
> I found this content when I was working on the CompareBuild tool and using
> these techniques can guarantee the same binaries are produced when the
> path to WORKSPACE is different on different build systems.
>
> Does your change provide a module-relative, package-relative, or
> workspace-relative file path in the ASSERT()?
No, I only use filename to replace the __FILE__
>
> How does ASSERT() in autogen work?
>
It is need to do some POC.
> Thanks,
>
> Mike
>
>
>
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
> Guomin
> > Jiang
> > Sent: Thursday, February 17, 2022 6:30 PM
> > To: devel@edk2.groups.io
> > Subject: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the
> > binary size
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> >
> > 1. Use DEBUG_FILE to control ASSERT path 2. Default use file name as
> > ASSERT path
> >
> > Motivation and Goal:
> > 1. The path will occupy many size in DEBUG build when file path is
> > long 2. We hope can reduce the size but not impact the debug
> > capability 3. If only use filename, we can search the filename to locate file.
> It
> > can save many size meanwhile.
> >
> > Guomin Jiang (2):
> > BaseTools/Conf: Reduce the ASSERT patch to save the binary size
> > MdePkg/Include: Define new DEBUG_FILE to specify path.
> >
> > BaseTools/Conf/build_rule.template | 10 ++++----
> > MdePkg/Include/Library/DebugLib.h | 39 +++++++++++++++++++++------
> ---
> > 2 files changed, 33 insertions(+), 16 deletions(-)
> >
> > --
> > 2.35.1.windows.2
> >
> >
> >
> >
> >
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [edk2-devel] [PATCH 2/2] MdePkg/Include: Define new DEBUG_FILE to specify path.
[not found] ` <16D4C08DC1603ADF.6551@groups.io>
@ 2022-02-24 2:33 ` Guomin Jiang
0 siblings, 0 replies; 9+ messages in thread
From: Guomin Jiang @ 2022-02-24 2:33 UTC (permalink / raw)
To: devel@edk2.groups.io, Liu, Zhiguang, Gao, Liming; +Cc: Kinney, Michael D
Hi Kinney, Liming, Zhiguang,
Can you give comments on this patch
Thanks
Guomin
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin
> Jiang
> Sent: Friday, February 18, 2022 10:30 AM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
> <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>
> Subject: [edk2-devel] [PATCH 2/2] MdePkg/Include: Define new
> DEBUG_FILE to specify path.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
>
> Use DEBUG_FILE to control ASSERT path
>
> Motivation and Goal:
> 1. The path will occupy many size in DEBUG build when file path is long 2. We
> hope can reduce the size but not impact the debug capability 3. If only use
> filename, we can search the filename to locate file. It
> can save many size meanwhile.
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
> ---
> MdePkg/Include/Library/DebugLib.h | 39 ++++++++++++++++++++++-------
> --
> 1 file changed, 28 insertions(+), 11 deletions(-)
>
> diff --git a/MdePkg/Include/Library/DebugLib.h
> b/MdePkg/Include/Library/DebugLib.h
> index 8d3d08638d73..5469c6308422 100644
> --- a/MdePkg/Include/Library/DebugLib.h
> +++ b/MdePkg/Include/Library/DebugLib.h
> @@ -8,7 +8,7 @@
> of size reduction when compiler optimization is disabled. If
> MDEPKG_NDEBUG is
> defined, then debug and assert related macros wrapped by it are the NULL
> implementations.
>
> -Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -85,6 +85,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define
> DEBUG_LINE_NUMBER __LINE__ #endif
>
> +//
> +// Source file.
> +// Default is use the to compiler provided __FILE__ macro value. The
> +__FILE__ // mapping can be overriden by predefining DEBUG_FILE // //
> +Defining DEBUG_FILE to a fixed value is useful when comparing builds //
> +across machine or configuration with different slash or path // file.
> +//
> +// Another benefit is we can customize the ASSERT path without
> +depending on // compiler ability // // It's for all no matter VS, GCC,
> +CLANG // #ifdef DEBUG_FILE #else #define DEBUG_FILE __FILE__ #endif
> +
> +// Blow override for keep clang behavior #if defined (__clang__) &&
> +defined (__FILE_NAME__) #undef DEBUG_FILE #define DEBUG_FILE
> +__FILE_NAME__ #endif
> +
> /**
> Macro that converts a Boolean expression to a Null-terminated ASCII string.
>
> @@ -337,17 +362,9 @@ UnitTestDebugAssert (
> IN CONST CHAR8 *Description
> );
>
> - #if defined (__clang__) && defined (__FILE_NAME__) -#define
> _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> - #else
> -#define _ASSERT(Expression) UnitTestDebugAssert (__FILE__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> - #endif
> +#define _ASSERT(Expression) UnitTestDebugAssert (DEBUG_FILE,
> +DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> #else
> - #if defined (__clang__) && defined (__FILE_NAME__) -#define
> _ASSERT(Expression) DebugAssert (__FILE_NAME__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> - #else
> -#define _ASSERT(Expression) DebugAssert (__FILE__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> - #endif
> +#define _ASSERT(Expression) DebugAssert (DEBUG_FILE,
> +DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> #endif
>
> /**
> --
> 2.35.1.windows.2
>
>
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size
2022-02-18 2:30 ` [PATCH 1/2] BaseTools/Conf: " Guomin Jiang
@ 2022-02-28 9:52 ` Bob Feng
2022-03-01 0:47 ` Guomin Jiang
0 siblings, 1 reply; 9+ messages in thread
From: Bob Feng @ 2022-02-28 9:52 UTC (permalink / raw)
To: Jiang, Guomin, devel@edk2.groups.io; +Cc: Gao, Liming, Chen, Christine
Hi Guomin,
I think this patch should work.
I concern the case that there would be already DEBUG_FILE macro defined in some existing platform.
Could you add the 2 patches' review link to the Bugzilla?
And I'd like to see the other associated patch review comments also.
Thanks,
Bob
-----Original Message-----
From: Jiang, Guomin <guomin.jiang@intel.com>
Sent: Friday, February 18, 2022 10:30 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>
Subject: [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
Use DEBUG_FILE to control ASSERT path
Motivation and Goal:
1. The path will occupy many size in DEBUG build when file path is long 2. We hope can reduce the size but not impact the debug capability 3. If only use filename, we can search the filename to locate file. It
can save many size meanwhile.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
BaseTools/Conf/build_rule.template | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template
index f40118234471..ad0bae42be62 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2022, Intel Corporation. All rights
+reserved.<BR>
# Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR> # Copyright (c) 2020, ARM Ltd. All rights reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -126,14 +126,14 @@
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
<Command.MSFT, Command.INTEL>
- "$(CC)" /Fo${dst} $(DEPS_FLAGS) $(CC_FLAGS) $(INC) ${src}
+ "$(CC)" /Fo${dst} $(DEPS_FLAGS) /D DEBUG_FILE="\"${s_base}.c\""
+ $(CC_FLAGS) $(INC) ${src}
<Command.GCC, Command.RVCT>
# For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues
- "$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
+ "$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\""
+ $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
<Command.XCODE>
- "$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -o ${dst} $(INC) ${src}
+ "$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\""
+ $(CC_FLAGS) -o ${dst} $(INC) ${src}
[C-Code-File.BASE.AARCH64,C-Code-File.SEC.AARCH64,C-Code-File.PEI_CORE.AARCH64,C-Code-File.PEIM.AARCH64,C-Code-File.BASE.ARM,C-Code-File.SEC.ARM,C-Code-File.PEI_CORE.ARM,C-Code-File.PEIM.ARM]
<InputFile>
@@ -146,7 +146,7 @@
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
<Command.GCC, Command.RVCT>
- "$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
+ "$(CC)" -D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS)
+ $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
[C-Header-File]
<InputFile>
--
2.35.1.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size
2022-02-28 9:52 ` Bob Feng
@ 2022-03-01 0:47 ` Guomin Jiang
0 siblings, 0 replies; 9+ messages in thread
From: Guomin Jiang @ 2022-03-01 0:47 UTC (permalink / raw)
To: Feng, Bob C, devel@edk2.groups.io; +Cc: Gao, Liming, Chen, Christine
Hi Bob,
Have and the review link to the Bugzilla.
Thanks
> -----Original Message-----
> From: Feng, Bob C <bob.c.feng@intel.com>
> Sent: Monday, February 28, 2022 5:52 PM
> To: Jiang, Guomin <guomin.jiang@intel.com>; devel@edk2.groups.io
> Cc: Gao, Liming <gaoliming@byosoft.com.cn>; Chen, Christine
> <yuwei.chen@intel.com>
> Subject: RE: [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save
> the binary size
>
> Hi Guomin,
>
> I think this patch should work.
> I concern the case that there would be already DEBUG_FILE macro defined in
> some existing platform.
>
> Could you add the 2 patches' review link to the Bugzilla?
>
> And I'd like to see the other associated patch review comments also.
>
> Thanks,
> Bob
>
> -----Original Message-----
> From: Jiang, Guomin <guomin.jiang@intel.com>
> Sent: Friday, February 18, 2022 10:30 AM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming
> <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>
> Subject: [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the
> binary size
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
>
> Use DEBUG_FILE to control ASSERT path
>
> Motivation and Goal:
> 1. The path will occupy many size in DEBUG build when file path is long 2. We
> hope can reduce the size but not impact the debug capability 3. If only use
> filename, we can search the filename to locate file. It
> can save many size meanwhile.
>
> Cc: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Yuwei Chen <yuwei.chen@intel.com>
> Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
> ---
> BaseTools/Conf/build_rule.template | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/BaseTools/Conf/build_rule.template
> b/BaseTools/Conf/build_rule.template
> index f40118234471..ad0bae42be62 100755
> --- a/BaseTools/Conf/build_rule.template
> +++ b/BaseTools/Conf/build_rule.template
> @@ -1,5 +1,5 @@
> #
> -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2007 - 2022, Intel Corporation. All rights
> +reserved.<BR>
> # Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR> #
> Copyright (c) 2020, ARM Ltd. All rights reserved.<BR> # SPDX-License-
> Identifier: BSD-2-Clause-Patent @@ -126,14 +126,14 @@
> $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
>
> <Command.MSFT, Command.INTEL>
> - "$(CC)" /Fo${dst} $(DEPS_FLAGS) $(CC_FLAGS) $(INC) ${src}
> + "$(CC)" /Fo${dst} $(DEPS_FLAGS) /D DEBUG_FILE="\"${s_base}.c\""
> + $(CC_FLAGS) $(INC) ${src}
>
> <Command.GCC, Command.RVCT>
> # For RVCTCYGWIN CC_FLAGS must be first to work around pathing
> issues
> - "$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
> + "$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\""
> + $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
>
> <Command.XCODE>
> - "$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -o ${dst} $(INC) ${src}
> + "$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\""
> + $(CC_FLAGS) -o ${dst} $(INC) ${src}
>
> [C-Code-File.BASE.AARCH64,C-Code-File.SEC.AARCH64,C-Code-
> File.PEI_CORE.AARCH64,C-Code-File.PEIM.AARCH64,C-Code-
> File.BASE.ARM,C-Code-File.SEC.ARM,C-Code-File.PEI_CORE.ARM,C-Code-
> File.PEIM.ARM]
> <InputFile>
> @@ -146,7 +146,7 @@
> $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
>
> <Command.GCC, Command.RVCT>
> - "$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
> + "$(CC)" -D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS)
> + $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
>
> [C-Header-File]
> <InputFile>
> --
> 2.35.1.windows.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* 回复: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size
2022-02-21 1:30 ` Guomin Jiang
@ 2022-03-01 1:47 ` gaoliming
0 siblings, 0 replies; 9+ messages in thread
From: gaoliming @ 2022-03-01 1:47 UTC (permalink / raw)
To: devel, guomin.jiang, 'Kinney, Michael D'
Guomin:
I add my comments.
> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Guomin Jiang
> 发送时间: 2022年2月21日 9:31
> 收件人: Kinney, Michael D <michael.d.kinney@intel.com>;
> devel@edk2.groups.io
> 主题: Re: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the
> binary size
>
> Comment inline
>
> Thank
> Guomin
>
> > -----Original Message-----
> > From: Kinney, Michael D <michael.d.kinney@intel.com>
> > Sent: Friday, February 18, 2022 11:34 AM
> > To: devel@edk2.groups.io; Jiang, Guomin <guomin.jiang@intel.com>;
> Kinney,
> > Michael D <michael.d.kinney@intel.com>
> > Subject: RE: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the
> > binary size
> >
> > Guomin,
> >
> > I think there is a cleaner solution to this problem using compiler flags to
> > change the contents of the __FILE__ macro.
>
> Thanks for your information. It is useful.
> 1. From the link, it seem that the VS haven't support it yet.
> 2. From my though, It is not good solution that we have strong depend on
> compiler.
Why do you think the compiler option is not good option? If the compiler supports such option,
it will reduce the customization in Edk2 BaseTools.
>
> >
> > https://blog.conan.io/2019/09/02/Deterministic-builds-with-C-C++.html
> > https://reproducible-builds.org/docs/build-path/
> > https://developercommunity.visualstudio.com/t/map-file-to-a-relative-
> > path/1393881
> >
> > I found this content when I was working on the CompareBuild tool and using
> > these techniques can guarantee the same binaries are produced when the
> > path to WORKSPACE is different on different build systems.
> >
>
>
> > Does your change provide a module-relative, package-relative, or
> > workspace-relative file path in the ASSERT()?
>
> No, I only use filename to replace the __FILE__
This solution changes FILE from full path to file name. It can reduce the image size.
But, it loses the file path information. If the developer doesn't care the image size,
how does he enable the full patch file information in ASSERT?
>
> >
> > How does ASSERT() in autogen work?
> >
>
> It is need to do some POC.
ASSERT works in autogen.c. But, the different modules have the same AutoGen.c file.
If ASSERT happens in AutoGen.c, only AutoGen.c print in debug message. The developer
may not know which this AutoGen.c is from.
Thanks
Liming
>
> > Thanks,
> >
> > Mike
> >
> >
> >
> > > -----Original Message-----
> > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
> > Guomin
> > > Jiang
> > > Sent: Thursday, February 17, 2022 6:30 PM
> > > To: devel@edk2.groups.io
> > > Subject: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the
> > > binary size
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> > >
> > > 1. Use DEBUG_FILE to control ASSERT path 2. Default use file name as
> > > ASSERT path
> > >
> > > Motivation and Goal:
> > > 1. The path will occupy many size in DEBUG build when file path is
> > > long 2. We hope can reduce the size but not impact the debug
> > > capability 3. If only use filename, we can search the filename to locate file.
> > It
> > > can save many size meanwhile.
> > >
> > > Guomin Jiang (2):
> > > BaseTools/Conf: Reduce the ASSERT patch to save the binary size
> > > MdePkg/Include: Define new DEBUG_FILE to specify path.
> > >
> > > BaseTools/Conf/build_rule.template | 10 ++++----
> > > MdePkg/Include/Library/DebugLib.h | 39
> +++++++++++++++++++++------
> > ---
> > > 2 files changed, 33 insertions(+), 16 deletions(-)
> > >
> > > --
> > > 2.35.1.windows.2
> > >
> > >
> > >
> > >
> > >
>
>
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-03-01 1:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-18 2:30 [PATCH 0/2] Reduce the ASSERT patch to save the binary size Guomin Jiang
2022-02-18 2:30 ` [PATCH 1/2] BaseTools/Conf: " Guomin Jiang
2022-02-28 9:52 ` Bob Feng
2022-03-01 0:47 ` Guomin Jiang
2022-02-18 2:30 ` [PATCH 2/2] MdePkg/Include: Define new DEBUG_FILE to specify path Guomin Jiang
2022-02-18 3:33 ` [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size Michael D Kinney
2022-02-21 1:30 ` Guomin Jiang
2022-03-01 1:47 ` 回复: " gaoliming
[not found] ` <16D4C08DC1603ADF.6551@groups.io>
2022-02-24 2:33 ` [edk2-devel] [PATCH 2/2] MdePkg/Include: Define new DEBUG_FILE to specify path Guomin Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox