[edk2-devel] [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size

Guomin Jiang posted 2 patches 3 years, 11 months ago
[edk2-devel] [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size
Posted by Guomin Jiang 3 years, 11 months ago
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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86747): https://edk2.groups.io/g/devel/message/86747
Mute This Topic: https://groups.io/mt/89225321/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size
Posted by Bob Feng 3 years, 11 months ago
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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87100): https://edk2.groups.io/g/devel/message/87100
Mute This Topic: https://groups.io/mt/89225321/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size
Posted by Guomin Jiang 3 years, 11 months ago
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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87110): https://edk2.groups.io/g/devel/message/87110
Mute This Topic: https://groups.io/mt/89225321/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-