public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools
@ 2016-09-29 14:12 Liming Gao
  2016-09-29 14:12 ` [Patch 1/4] BaseTools EfiLdrImage: Remove unnecessary exit (0) Liming Gao
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Liming Gao @ 2016-09-29 14:12 UTC (permalink / raw)
  To: edk2-devel

After enable optimization, C tool build time is reduced by ~50%. Please see 
below example to use LzmaCompress to compress OVMF DXEFV.

Tool                         Compression time Decompression time
LzmaCompress (GCC O0)        3.476s           0.204s
LzmaCompress (GCC Ofast)     1.655s           0.107s
LzmaCompress (VS Od)         3.047s           0.210s
LzmaCompress (VS O2)         1.551s           0.126s

Liming Gao (4):
  BaseTools EfiLdrImage: Remove unnecessary exit (0)
  BaseTools Makefile: Enable O2 option to replace Od for VS tool chain
  BaseTools GenVtf: Initialize the return point as NULL
  BaseTools Makefile: Enable Ofast option for GCC tool chain

 BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c | 1 -
 BaseTools/Source/C/GenVtf/GenVtf.c           | 1 +
 BaseTools/Source/C/Makefiles/header.makefile | 6 +++---
 BaseTools/Source/C/Makefiles/ms.app          | 2 +-
 BaseTools/Source/C/Makefiles/ms.common       | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

-- 
2.8.0.windows.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Patch 1/4] BaseTools EfiLdrImage: Remove unnecessary exit (0)
  2016-09-29 14:12 [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools Liming Gao
@ 2016-09-29 14:12 ` Liming Gao
  2016-09-29 14:12 ` [Patch 2/4] BaseTools Makefile: Enable O2 option to replace Od for VS tool chain Liming Gao
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Liming Gao @ 2016-09-29 14:12 UTC (permalink / raw)
  To: edk2-devel

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c b/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c
index 88cc345..a46ecf8 100644
--- a/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c
+++ b/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c
@@ -75,7 +75,6 @@ Returns:
 --*/
 {
   printf ("%s Version %d.%d Build %s\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
-  exit (0);
 }
 
 VOID
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Patch 2/4] BaseTools Makefile: Enable O2 option to replace Od for VS tool chain
  2016-09-29 14:12 [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools Liming Gao
  2016-09-29 14:12 ` [Patch 1/4] BaseTools EfiLdrImage: Remove unnecessary exit (0) Liming Gao
@ 2016-09-29 14:12 ` Liming Gao
  2016-09-29 14:12 ` [Patch 3/4] BaseTools GenVtf: Initialize the return point as NULL Liming Gao
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Liming Gao @ 2016-09-29 14:12 UTC (permalink / raw)
  To: edk2-devel

Enable O2 option to generate fast code for performance improvement.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/C/Makefiles/ms.app    | 2 +-
 BaseTools/Source/C/Makefiles/ms.common | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/Makefiles/ms.app b/BaseTools/Source/C/Makefiles/ms.app
index 908ffe8..93d51f9 100644
--- a/BaseTools/Source/C/Makefiles/ms.app
+++ b/BaseTools/Source/C/Makefiles/ms.app
@@ -17,7 +17,7 @@ all: $(APPLICATION)
 
 $(APPLICATION) : $(OBJECTS) 
 	-@if not exist $(BIN_PATH) mkdir $(BIN_PATH)
-	$(LD) /nologo /debug /incremental:no /nodefaultlib:libc.lib /out:$@ $(LIBS) $**
+	$(LD) /nologo /debug /OPT:REF /OPT:ICF=10 /incremental:no /nodefaultlib:libc.lib /out:$@ $(LIBS) $**
 
 $(OBJECTS) : ..\Include\Common\BuildVersion.h
 
diff --git a/BaseTools/Source/C/Makefiles/ms.common b/BaseTools/Source/C/Makefiles/ms.common
index 9e50b21..5c3991d 100644
--- a/BaseTools/Source/C/Makefiles/ms.common
+++ b/BaseTools/Source/C/Makefiles/ms.common
@@ -61,6 +61,6 @@ LINKER = $(LD)
 
 INC = -I . -I $(SOURCE_PATH)\Include -I $(ARCH_INCLUDE) -I $(SOURCE_PATH)\Common $(INC)
 
-CFLAGS = $(CFLAGS) /nologo /c /Zi /Od /RTC1 /D _DEBUG /MTd /W4 /WX /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE 
-CPPFLAGS = $(CPPFLAGS) /EHsc /nologo /c /Zi /Od /RTC1 /D _DEBUG /MTd /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE 
+CFLAGS = $(CFLAGS) /nologo /Zi /c /O2 /MD /W4 /WX /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE 
+CPPFLAGS = $(CPPFLAGS) /EHsc /nologo /Zi /c /O2 /MD /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE 
 
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Patch 3/4] BaseTools GenVtf: Initialize the return point as NULL
  2016-09-29 14:12 [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools Liming Gao
  2016-09-29 14:12 ` [Patch 1/4] BaseTools EfiLdrImage: Remove unnecessary exit (0) Liming Gao
  2016-09-29 14:12 ` [Patch 2/4] BaseTools Makefile: Enable O2 option to replace Od for VS tool chain Liming Gao
@ 2016-09-29 14:12 ` Liming Gao
  2016-09-29 14:12 ` [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain Liming Gao
  2016-09-30 17:46 ` [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools Jordan Justen
  4 siblings, 0 replies; 10+ messages in thread
From: Liming Gao @ 2016-09-29 14:12 UTC (permalink / raw)
  To: edk2-devel

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/C/GenVtf/GenVtf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c
index 9a3f508..f6765dd 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.c
+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
@@ -796,6 +796,7 @@ Returns:
 
   TmpFitPtr         = (FIT_TABLE *) RelativeAddress;
   NumFitComponents  = TmpFitPtr->CompSize;
+  *FitPtr           = NULL;
 
   for (Index = 0; Index < NumFitComponents; Index++) {
     if ((TmpFitPtr->CvAndType & FIT_TYPE_MASK) == COMP_TYPE_FIT_UNUSED) {
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain
  2016-09-29 14:12 [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools Liming Gao
                   ` (2 preceding siblings ...)
  2016-09-29 14:12 ` [Patch 3/4] BaseTools GenVtf: Initialize the return point as NULL Liming Gao
@ 2016-09-29 14:12 ` Liming Gao
  2016-09-29 18:29   ` Laszlo Ersek
  2016-09-30 17:46 ` [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools Jordan Justen
  4 siblings, 1 reply; 10+ messages in thread
From: Liming Gao @ 2016-09-29 14:12 UTC (permalink / raw)
  To: edk2-devel

Enable Ofast option to generate fast code for performance improvement.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/C/Makefiles/header.makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
index f2041f8..ca2dc2e 100644
--- a/BaseTools/Source/C/Makefiles/header.makefile
+++ b/BaseTools/Source/C/Makefiles/header.makefile
@@ -44,12 +44,12 @@ ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
 endif
 
 INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE) 
-BUILD_CPPFLAGS = $(INCLUDE)
+BUILD_CPPFLAGS = $(INCLUDE) -Ofast
 ifeq ($(DARWIN),Darwin)
 # assume clang or clang compatible flags on OS X
-BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -nostdlib -c -g
+BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g
 else
-BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -nostdlib -c -g
+BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g
 endif
 BUILD_LFLAGS =
 BUILD_CXXFLAGS =
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain
  2016-09-29 14:12 ` [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain Liming Gao
@ 2016-09-29 18:29   ` Laszlo Ersek
  2016-09-30  0:24     ` Gao, Liming
  0 siblings, 1 reply; 10+ messages in thread
From: Laszlo Ersek @ 2016-09-29 18:29 UTC (permalink / raw)
  To: Liming Gao; +Cc: edk2-devel, Ard Biesheuvel, Jordan Justen (Intel address)

Hi Liming,

On 09/29/16 16:12, Liming Gao wrote:
> Enable Ofast option to generate fast code for performance improvement.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao <liming.gao@intel.com>
> ---
>  BaseTools/Source/C/Makefiles/header.makefile | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
> index f2041f8..ca2dc2e 100644
> --- a/BaseTools/Source/C/Makefiles/header.makefile
> +++ b/BaseTools/Source/C/Makefiles/header.makefile
> @@ -44,12 +44,12 @@ ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
>  endif
>  
>  INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE) 
> -BUILD_CPPFLAGS = $(INCLUDE)
> +BUILD_CPPFLAGS = $(INCLUDE) -Ofast
>  ifeq ($(DARWIN),Darwin)
>  # assume clang or clang compatible flags on OS X
> -BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -nostdlib -c -g
> +BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g
>  else
> -BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -nostdlib -c -g
> +BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g
>  endif
>  BUILD_LFLAGS =
>  BUILD_CXXFLAGS =
> 

are you sure -Ofast is a good idea? The gcc manual says,

  -Ofast
    Disregard strict standards compliance.  -Ofast enables all -O3
    optimizations.  It also enables optimizations that are not valid for
    all standard-compliant programs.  It turns on -ffast-math and the
    Fortran-specific -fno-protect-parens and -fstack-arrays.

To me this sounds quite scary -- I'm worried it might break the base
utilities in various obscure ways, which in turn could break the
firmware built with these tools in obscure ways.

Most upstream projects and GNU/Linux distributions use -O2 for
performance-optimized builds. Can you try that please and see if the
performance improvements (relative to the current status) are still
acceptable? If so, I would strongly prefer -O2 over -Ofast.

Also, while building BaseTools with your series applied (using gcc-4.8),
I saw one warning issued:

> g++ -c -I Pccts/h -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/  -Ofast  VfrFormPkg.cpp -o VfrFormPkg.o
> VfrFormPkg.cpp: In member function 'void CIfrRecordInfoDB::IfrUpdateRecordInfoForDynamicOpcode(BOOLEAN)':
> VfrFormPkg.cpp:1360:91: warning: deprecated conversion from string constant to 'CHAR8* {aka char*}' [-Wwrite-strings]
>      gCVfrErrorHandle.PrintMsg (0, "Error", "Can not find the adjust offset in the record.");
                                                                                           ^
Thanks!
Laszlo




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain
  2016-09-29 18:29   ` Laszlo Ersek
@ 2016-09-30  0:24     ` Gao, Liming
  2016-09-30  6:56       ` Gao, Liming
  0 siblings, 1 reply; 10+ messages in thread
From: Gao, Liming @ 2016-09-30  0:24 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel@ml01.01.org, Ard Biesheuvel, Justen, Jordan L

Laszlo:
   Thanks for your suggestion. I will try O2 option and see the performance and warning.

Thanks
Liming
From: Laszlo Ersek [mailto:lersek@redhat.com]
Sent: Friday, September 30, 2016 2:30 AM
To: Gao, Liming <liming.gao@intel.com>
Cc: edk2-devel@ml01.01.org; Ard Biesheuvel <ard.biesheuvel@linaro.org>; Justen, Jordan L <jordan.l.justen@intel.com>
Subject: Re: [edk2] [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain

Hi Liming,

On 09/29/16 16:12, Liming Gao wrote:
> Enable Ofast option to generate fast code for performance improvement.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao
> ---
> BaseTools/Source/C/Makefiles/header.makefile | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
> index f2041f8..ca2dc2e 100644
> --- a/BaseTools/Source/C/Makefiles/header.makefile
> +++ b/BaseTools/Source/C/Makefiles/header.makefile
> @@ -44,12 +44,12 @@ ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
> endif
>
> INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
> -BUILD_CPPFLAGS = $(INCLUDE)
> +BUILD_CPPFLAGS = $(INCLUDE) -Ofast
> ifeq ($(DARWIN),Darwin)
> # assume clang or clang compatible flags on OS X
> -BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -nostdlib -c -g
> +BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g
> else
> -BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -nostdlib -c -g
> +BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g
> endif
> BUILD_LFLAGS =
> BUILD_CXXFLAGS =
>

are you sure -Ofast is a good idea? The gcc manual says,

-Ofast
Disregard strict standards compliance. -Ofast enables all -O3
optimizations. It also enables optimizations that are not valid for
all standard-compliant programs. It turns on -ffast-math and the
Fortran-specific -fno-protect-parens and -fstack-arrays.

To me this sounds quite scary -- I'm worried it might break the base
utilities in various obscure ways, which in turn could break the
firmware built with these tools in obscure ways.

Most upstream projects and GNU/Linux distributions use -O2 for
performance-optimized builds. Can you try that please and see if the
performance improvements (relative to the current status) are still
acceptable? If so, I would strongly prefer -O2 over -Ofast.

Also, while building BaseTools with your series applied (using gcc-4.8),
I saw one warning issued:

> g++ -c -I Pccts/h -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ -Ofast VfrFormPkg.cpp -o VfrFormPkg.o
> VfrFormPkg.cpp: In member function 'void CIfrRecordInfoDB::IfrUpdateRecordInfoForDynamicOpcode(BOOLEAN)':
> VfrFormPkg.cpp:1360:91: warning: deprecated conversion from string constant to 'CHAR8* {aka char*}' [-Wwrite-strings]
> gCVfrErrorHandle.PrintMsg (0, "Error", "Can not find the adjust offset in the record.");
^
Thanks!
Laszlo


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain
  2016-09-30  0:24     ` Gao, Liming
@ 2016-09-30  6:56       ` Gao, Liming
  2016-09-30  9:49         ` Laszlo Ersek
  0 siblings, 1 reply; 10+ messages in thread
From: Gao, Liming @ 2016-09-30  6:56 UTC (permalink / raw)
  To: Gao, Liming, Laszlo Ersek
  Cc: Justen, Jordan L, edk2-devel@ml01.01.org, Ard Biesheuvel

Ersek:
  I try O2 option. Compared to Ofast, there is a little different. I think it is acceptable. I will use O2 option. And, this warning message also exists without O2 enable. It is not introduced by this patch.


Tool                                               Compression time Decompression time

LzmaCompress (GCC O0)          3.476s           0.204s

LzmaCompress (GCC Ofast)     1.655s           0.107s

LzmaCompress (GCC O2)          1.687s          0.105s

Thanks
Liming
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Gao, Liming
Sent: Friday, September 30, 2016 8:24 AM
To: Laszlo Ersek <lersek@redhat.com>
Cc: Justen, Jordan L <jordan.l.justen@intel.com>; edk2-devel@ml01.01.org; Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [edk2] [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain

Laszlo:
Thanks for your suggestion. I will try O2 option and see the performance and warning.

Thanks
Liming
From: Laszlo Ersek [mailto:lersek@redhat.com]
Sent: Friday, September 30, 2016 2:30 AM
To: Gao, Liming
Cc: edk2-devel@ml01.01.org<mailto:edk2-devel@ml01.01.org>; Ard Biesheuvel ; Justen, Jordan L
Subject: Re: [edk2] [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain

Hi Liming,

On 09/29/16 16:12, Liming Gao wrote:
> Enable Ofast option to generate fast code for performance improvement.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao
> ---
> BaseTools/Source/C/Makefiles/header.makefile | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
> index f2041f8..ca2dc2e 100644
> --- a/BaseTools/Source/C/Makefiles/header.makefile
> +++ b/BaseTools/Source/C/Makefiles/header.makefile
> @@ -44,12 +44,12 @@ ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
> endif
>
> INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
> -BUILD_CPPFLAGS = $(INCLUDE)
> +BUILD_CPPFLAGS = $(INCLUDE) -Ofast
> ifeq ($(DARWIN),Darwin)
> # assume clang or clang compatible flags on OS X
> -BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -nostdlib -c -g
> +BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g
> else
> -BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -nostdlib -c -g
> +BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g
> endif
> BUILD_LFLAGS =
> BUILD_CXXFLAGS =
>

are you sure -Ofast is a good idea? The gcc manual says,

-Ofast
Disregard strict standards compliance. -Ofast enables all -O3
optimizations. It also enables optimizations that are not valid for
all standard-compliant programs. It turns on -ffast-math and the
Fortran-specific -fno-protect-parens and -fstack-arrays.

To me this sounds quite scary -- I'm worried it might break the base
utilities in various obscure ways, which in turn could break the
firmware built with these tools in obscure ways.

Most upstream projects and GNU/Linux distributions use -O2 for
performance-optimized builds. Can you try that please and see if the
performance improvements (relative to the current status) are still
acceptable? If so, I would strongly prefer -O2 over -Ofast.

Also, while building BaseTools with your series applied (using gcc-4.8),
I saw one warning issued:

> g++ -c -I Pccts/h -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ -Ofast VfrFormPkg.cpp -o VfrFormPkg.o
> VfrFormPkg.cpp: In member function 'void CIfrRecordInfoDB::IfrUpdateRecordInfoForDynamicOpcode(BOOLEAN)':
> VfrFormPkg.cpp:1360:91: warning: deprecated conversion from string constant to 'CHAR8* {aka char*}' [-Wwrite-strings]
> gCVfrErrorHandle.PrintMsg (0, "Error", "Can not find the adjust offset in the record.");
^
Thanks!
Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain
  2016-09-30  6:56       ` Gao, Liming
@ 2016-09-30  9:49         ` Laszlo Ersek
  0 siblings, 0 replies; 10+ messages in thread
From: Laszlo Ersek @ 2016-09-30  9:49 UTC (permalink / raw)
  To: Gao, Liming; +Cc: Justen, Jordan L, edk2-devel@ml01.01.org, Ard Biesheuvel

On 09/30/16 08:56, Gao, Liming wrote:
> Ersek:
> 
>   I try O2 option. Compared to Ofast, there is a little different. I
> think it is acceptable. I will use O2 option. And, this warning message
> also exists without O2 enable. It is not introduced by this patch.
> 
>  
> 
> Tool                                               Compression time
> Decompression time
> 
> LzmaCompress (GCC O0)          3.476s           0.204s
> 
> LzmaCompress (GCC Ofast)     1.655s           0.107s
> 
> LzmaCompress (GCC O2)          1.687s          0.105s
> 

Thank you very much!
Laszlo



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools
  2016-09-29 14:12 [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools Liming Gao
                   ` (3 preceding siblings ...)
  2016-09-29 14:12 ` [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain Liming Gao
@ 2016-09-30 17:46 ` Jordan Justen
  4 siblings, 0 replies; 10+ messages in thread
From: Jordan Justen @ 2016-09-30 17:46 UTC (permalink / raw)
  To: Liming Gao, edk2-devel

On 2016-09-29 07:12:43, Liming Gao wrote:
> After enable optimization, C tool build time is reduced by ~50%. Please see 
> below example to use LzmaCompress to compress OVMF DXEFV.
> 
> Tool                         Compression time Decompression time
> LzmaCompress (GCC O0)        3.476s           0.204s
> LzmaCompress (GCC Ofast)     1.655s           0.107s
> LzmaCompress (VS Od)         3.047s           0.210s
> LzmaCompress (VS O2)         1.551s           0.126s
> 
> Liming Gao (4):
>   BaseTools EfiLdrImage: Remove unnecessary exit (0)

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

>   BaseTools Makefile: Enable O2 option to replace Od for VS tool chain

I assume these flag changes work fine with the older versions of VS?
If so,

Acked-by: Jordan Justen <jordan.l.justen@intel.com>

>   BaseTools GenVtf: Initialize the return point as NULL

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

>   BaseTools Makefile: Enable Ofast option for GCC tool chain

If changed to -O2 (Thanks for the suggesion Laszlo):

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

> 
>  BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c | 1 -
>  BaseTools/Source/C/GenVtf/GenVtf.c           | 1 +
>  BaseTools/Source/C/Makefiles/header.makefile | 6 +++---
>  BaseTools/Source/C/Makefiles/ms.app          | 2 +-
>  BaseTools/Source/C/Makefiles/ms.common       | 4 ++--
>  5 files changed, 7 insertions(+), 7 deletions(-)
> 
> -- 
> 2.8.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-09-30 17:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-29 14:12 [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools Liming Gao
2016-09-29 14:12 ` [Patch 1/4] BaseTools EfiLdrImage: Remove unnecessary exit (0) Liming Gao
2016-09-29 14:12 ` [Patch 2/4] BaseTools Makefile: Enable O2 option to replace Od for VS tool chain Liming Gao
2016-09-29 14:12 ` [Patch 3/4] BaseTools GenVtf: Initialize the return point as NULL Liming Gao
2016-09-29 14:12 ` [Patch 4/4] BaseTools Makefile: Enable Ofast option for GCC tool chain Liming Gao
2016-09-29 18:29   ` Laszlo Ersek
2016-09-30  0:24     ` Gao, Liming
2016-09-30  6:56       ` Gao, Liming
2016-09-30  9:49         ` Laszlo Ersek
2016-09-30 17:46 ` [Patch 0/4] BaseTools: Enable optimization to generate fast code in C tools Jordan Justen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox