Blame 0019-BaseTools-Source-C-split-O2-to-BUILD_OPTFLAGS.patch

285b94
From 67c8bbaf89bbb4015f0b915fed6fb2f35efd282f Mon Sep 17 00:00:00 2001
285b94
From: Laszlo Ersek <lersek@redhat.com>
285b94
Date: Wed, 25 Jul 2018 22:59:57 +0200
285b94
Subject: [PATCH] BaseTools/Source/C: split "-O2" to BUILD_OPTFLAGS
285b94
285b94
The option "-O2" is not a preprocessor flag, but a code generation
285b94
(compilation) flag. Move it from BUILD_CPPFLAGS to BUILD_CFLAGS and
285b94
BUILD_CXXFLAGS.
285b94
285b94
Because "VfrCompile/GNUmakefile" uses "-O2" through BUILD_CPPFLAGS, and
285b94
because it doesn't use BUILD_CXXFLAGS, we have to introduce BUILD_OPTFLAGS
285b94
separately, so that "VfrCompile/GNUmakefile" can continue using just this
285b94
flag.
285b94
285b94
This patch doesn't change behavior.
285b94
285b94
Cc: Liming Gao <liming.gao@intel.com>
285b94
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
285b94
Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244
285b94
Contributed-under: TianoCore Contribution Agreement 1.1
285b94
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
285b94
Reviewed-by: Liming Gao <liming.gao@intel.com>
285b94
(cherry picked from commit b8a66170264395edeaa61e6d22930a58e576a685)
285b94
---
285b94
 BaseTools/Source/C/Makefiles/header.makefile |  6 +++++-
285b94
 BaseTools/Source/C/VfrCompile/GNUmakefile    | 11 +++++++----
285b94
 2 files changed, 12 insertions(+), 5 deletions(-)
285b94
285b94
diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
285b94
index 08421ba24c..498c6cf48b 100644
285b94
--- a/BaseTools/Source/C/Makefiles/header.makefile
285b94
+++ b/BaseTools/Source/C/Makefiles/header.makefile
285b94
@@ -68,7 +68,8 @@ $(error Bad HOST_ARCH)
285b94
 endif
285b94
 
285b94
 INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE) 
285b94
-BUILD_CPPFLAGS = $(INCLUDE) -O2
285b94
+BUILD_CPPFLAGS = $(INCLUDE)
285b94
+BUILD_OPTFLAGS = -O2
285b94
 ifeq ($(DARWIN),Darwin)
285b94
 # assume clang or clang compatible flags on OS X
285b94
 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g
285b94
@@ -91,6 +92,9 @@ ifeq ($(DARWIN),Darwin)
285b94
 endif
285b94
 endif
285b94
 
285b94
+# keep BUILD_OPTFLAGS last
285b94
+BUILD_CFLAGS   += $(BUILD_OPTFLAGS)
285b94
+BUILD_CXXFLAGS += $(BUILD_OPTFLAGS)
285b94
   
285b94
 .PHONY: all
285b94
 .PHONY: install
285b94
diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C/VfrCompile/GNUmakefile
285b94
index c4ec61aa6c..bbe562cbc5 100644
285b94
--- a/BaseTools/Source/C/VfrCompile/GNUmakefile
285b94
+++ b/BaseTools/Source/C/VfrCompile/GNUmakefile
285b94
@@ -25,6 +25,9 @@ OBJECTS = AParser.o DLexerBase.o ATokenBuffer.o EfiVfrParser.o VfrLexer.o VfrSyn
285b94
 
285b94
 VFR_CPPFLAGS = -DPCCTS_USE_NAMESPACE_STD $(BUILD_CPPFLAGS)
285b94
 
285b94
+# keep BUILD_OPTFLAGS last
285b94
+VFR_CXXFLAGS = $(BUILD_OPTFLAGS)
285b94
+
285b94
 LINKER = $(BUILD_CXX)
285b94
 
285b94
 EXTRA_CLEAN_OBJECTS = EfiVfrParser.cpp EfiVfrParser.h VfrParser.dlg VfrTokens.h VfrLexer.cpp VfrLexer.h VfrSyntax.cpp tokens.h
285b94
@@ -58,16 +61,16 @@ Pccts/dlg/dlg:
285b94
 	BIN_DIR='.' $(MAKE) -C Pccts/dlg
285b94
 
285b94
 ATokenBuffer.o: Pccts/h/ATokenBuffer.cpp
285b94
-	$(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $? -o $@
285b94
+	$(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $(VFR_CXXFLAGS) $? -o $@
285b94
 
285b94
 DLexerBase.o: Pccts/h/DLexerBase.cpp
285b94
-	$(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $? -o $@
285b94
+	$(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $(VFR_CXXFLAGS) $? -o $@
285b94
 
285b94
 AParser.o: Pccts/h/AParser.cpp
285b94
-	$(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $? -o $@
285b94
+	$(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $(VFR_CXXFLAGS) $? -o $@
285b94
 
285b94
 VfrSyntax.o: VfrSyntax.cpp
285b94
-	$(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $? -o $@
285b94
+	$(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $(VFR_CXXFLAGS) $? -o $@
285b94
 	
285b94
 clean: localClean
285b94