[edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size

Guomin Jiang posted 2 patches 2 years, 2 months ago
Failed in applying to current master (apply log)
BaseTools/Conf/build_rule.template | 10 ++++----
MdePkg/Include/Library/DebugLib.h  | 39 +++++++++++++++++++++---------
2 files changed, 33 insertions(+), 16 deletions(-)
[edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size
Posted by Guomin Jiang 2 years, 2 months ago
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



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


Re: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size
Posted by Michael D Kinney 2 years, 2 months ago
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
> 
> 
> 
> 
> 



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


Re: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size
Posted by Guomin Jiang 2 years, 2 months ago
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
> >
> >
> >
> > 
> >



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


回复: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size
Posted by gaoliming 2 years, 2 months ago
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
> > >
> > >
> > >
> > >
> > >
> 
> 
> 
> 
> 





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