From 285b943a5fa264b6fb3f50d4307d328ab3378887 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Aug 31 2018 17:10:10 +0000 Subject: Fix passing through RPM build flags (bz 1540244) --- diff --git a/0017-BaseTools-footer.makefile-expand-BUILD_CFLAGS-last-f.patch b/0017-BaseTools-footer.makefile-expand-BUILD_CFLAGS-last-f.patch new file mode 100644 index 0000000..a1e5144 --- /dev/null +++ b/0017-BaseTools-footer.makefile-expand-BUILD_CFLAGS-last-f.patch @@ -0,0 +1,35 @@ +From eebbf279b59afa3787d11734d9707cc7ab24d651 Mon Sep 17 00:00:00 2001 +From: Laszlo Ersek +Date: Wed, 25 Jul 2018 22:27:53 +0200 +Subject: [PATCH] BaseTools/footer.makefile: expand BUILD_CFLAGS last for C + files too + +BUILD_CPPFLAGS should be expanded before BUILD_CFLAGS. (The rule for C++ +source files already does this, with BUILD_CPPFLAGS and BUILD_CXXFLAGS.) + +This patch doesn't change behavior. + +Cc: Liming Gao +Cc: Yonghong Zhu +Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 +Contributed-under: TianoCore Contribution Agreement 1.1 +Signed-off-by: Laszlo Ersek +Reviewed-by: Liming Gao +(cherry picked from commit 67983484a4430c5f82bb5f1397e010c759136321) +--- + BaseTools/Source/C/Makefiles/footer.makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/BaseTools/Source/C/Makefiles/footer.makefile b/BaseTools/Source/C/Makefiles/footer.makefile +index 0926aa9645..5bda9e4e36 100644 +--- a/BaseTools/Source/C/Makefiles/footer.makefile ++++ b/BaseTools/Source/C/Makefiles/footer.makefile +@@ -24,7 +24,7 @@ $(LIBRARY): $(OBJECTS) + $(BUILD_AR) crs $@ $^ + + %.o : %.c +- $(BUILD_CC) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< -o $@ ++ $(BUILD_CC) -c $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) $< -o $@ + + %.o : %.cpp + $(BUILD_CXX) -c $(BUILD_CPPFLAGS) $(BUILD_CXXFLAGS) $< -o $@ diff --git a/0018-BaseTools-header.makefile-remove-c-from-BUILD_CFLAGS.patch b/0018-BaseTools-header.makefile-remove-c-from-BUILD_CFLAGS.patch new file mode 100644 index 0000000..0942d9e --- /dev/null +++ b/0018-BaseTools-header.makefile-remove-c-from-BUILD_CFLAGS.patch @@ -0,0 +1,40 @@ +From 0af592dfa9a6d1a3379db1331344f411f7774bea Mon Sep 17 00:00:00 2001 +From: Laszlo Ersek +Date: Wed, 25 Jul 2018 22:40:09 +0200 +Subject: [PATCH] BaseTools/header.makefile: remove "-c" from BUILD_CFLAGS + +Option "-c" is a mode selection flag (choosing between compiling and +linking); it should not be in BUILD_CFLAGS, which applies only to +compiling anyway. The compilation rule for C source files, in +"footer.makefile", already includes "-c" -- currently we have double "-c" +options. + +This patch doesn't change behavior. + +Cc: Liming Gao +Cc: Yonghong Zhu +Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 +Contributed-under: TianoCore Contribution Agreement 1.1 +Signed-off-by: Laszlo Ersek +Reviewed-by: Liming Gao +(cherry picked from commit 03252ae287c4a61983b3793ff71baeabe2ff3df7) +--- + BaseTools/Source/C/Makefiles/header.makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile +index db436773cf..08421ba24c 100644 +--- a/BaseTools/Source/C/Makefiles/header.makefile ++++ b/BaseTools/Source/C/Makefiles/header.makefile +@@ -71,9 +71,9 @@ INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKE + BUILD_CPPFLAGS = $(INCLUDE) -O2 + 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 -Wno-unused-result -nostdlib -c -g ++BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g + else +-BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -c -g ++BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -g + endif + BUILD_LFLAGS = + BUILD_CXXFLAGS = -Wno-unused-result diff --git a/0019-BaseTools-Source-C-split-O2-to-BUILD_OPTFLAGS.patch b/0019-BaseTools-Source-C-split-O2-to-BUILD_OPTFLAGS.patch new file mode 100644 index 0000000..52528d9 --- /dev/null +++ b/0019-BaseTools-Source-C-split-O2-to-BUILD_OPTFLAGS.patch @@ -0,0 +1,87 @@ +From 67c8bbaf89bbb4015f0b915fed6fb2f35efd282f Mon Sep 17 00:00:00 2001 +From: Laszlo Ersek +Date: Wed, 25 Jul 2018 22:59:57 +0200 +Subject: [PATCH] BaseTools/Source/C: split "-O2" to BUILD_OPTFLAGS + +The option "-O2" is not a preprocessor flag, but a code generation +(compilation) flag. Move it from BUILD_CPPFLAGS to BUILD_CFLAGS and +BUILD_CXXFLAGS. + +Because "VfrCompile/GNUmakefile" uses "-O2" through BUILD_CPPFLAGS, and +because it doesn't use BUILD_CXXFLAGS, we have to introduce BUILD_OPTFLAGS +separately, so that "VfrCompile/GNUmakefile" can continue using just this +flag. + +This patch doesn't change behavior. + +Cc: Liming Gao +Cc: Yonghong Zhu +Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 +Contributed-under: TianoCore Contribution Agreement 1.1 +Signed-off-by: Laszlo Ersek +Reviewed-by: Liming Gao +(cherry picked from commit b8a66170264395edeaa61e6d22930a58e576a685) +--- + BaseTools/Source/C/Makefiles/header.makefile | 6 +++++- + BaseTools/Source/C/VfrCompile/GNUmakefile | 11 +++++++---- + 2 files changed, 12 insertions(+), 5 deletions(-) + +diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile +index 08421ba24c..498c6cf48b 100644 +--- a/BaseTools/Source/C/Makefiles/header.makefile ++++ b/BaseTools/Source/C/Makefiles/header.makefile +@@ -68,7 +68,8 @@ $(error Bad HOST_ARCH) + 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) -O2 ++BUILD_CPPFLAGS = $(INCLUDE) ++BUILD_OPTFLAGS = -O2 + 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 -Wno-unused-result -nostdlib -g +@@ -91,6 +92,9 @@ ifeq ($(DARWIN),Darwin) + endif + endif + ++# keep BUILD_OPTFLAGS last ++BUILD_CFLAGS += $(BUILD_OPTFLAGS) ++BUILD_CXXFLAGS += $(BUILD_OPTFLAGS) + + .PHONY: all + .PHONY: install +diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C/VfrCompile/GNUmakefile +index c4ec61aa6c..bbe562cbc5 100644 +--- a/BaseTools/Source/C/VfrCompile/GNUmakefile ++++ b/BaseTools/Source/C/VfrCompile/GNUmakefile +@@ -25,6 +25,9 @@ OBJECTS = AParser.o DLexerBase.o ATokenBuffer.o EfiVfrParser.o VfrLexer.o VfrSyn + + VFR_CPPFLAGS = -DPCCTS_USE_NAMESPACE_STD $(BUILD_CPPFLAGS) + ++# keep BUILD_OPTFLAGS last ++VFR_CXXFLAGS = $(BUILD_OPTFLAGS) ++ + LINKER = $(BUILD_CXX) + + EXTRA_CLEAN_OBJECTS = EfiVfrParser.cpp EfiVfrParser.h VfrParser.dlg VfrTokens.h VfrLexer.cpp VfrLexer.h VfrSyntax.cpp tokens.h +@@ -58,16 +61,16 @@ Pccts/dlg/dlg: + BIN_DIR='.' $(MAKE) -C Pccts/dlg + + ATokenBuffer.o: Pccts/h/ATokenBuffer.cpp +- $(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $? -o $@ ++ $(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $(VFR_CXXFLAGS) $? -o $@ + + DLexerBase.o: Pccts/h/DLexerBase.cpp +- $(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $? -o $@ ++ $(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $(VFR_CXXFLAGS) $? -o $@ + + AParser.o: Pccts/h/AParser.cpp +- $(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $? -o $@ ++ $(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $(VFR_CXXFLAGS) $? -o $@ + + VfrSyntax.o: VfrSyntax.cpp +- $(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $? -o $@ ++ $(BUILD_CXX) -c $(VFR_CPPFLAGS) $(INC) $(VFR_CXXFLAGS) $? -o $@ + + clean: localClean + diff --git a/0020-BaseTools-Source-C-take-EXTRA_OPTFLAGS-from-the-call.patch b/0020-BaseTools-Source-C-take-EXTRA_OPTFLAGS-from-the-call.patch new file mode 100644 index 0000000..f61aebe --- /dev/null +++ b/0020-BaseTools-Source-C-take-EXTRA_OPTFLAGS-from-the-call.patch @@ -0,0 +1,37 @@ +From 26296351f9a6b6dad0604f8ed62ce5de0f41ac2c Mon Sep 17 00:00:00 2001 +From: Laszlo Ersek +Date: Thu, 26 Jul 2018 00:04:26 +0200 +Subject: [PATCH] BaseTools/Source/C: take EXTRA_OPTFLAGS from the caller + +Allow the caller of the top-level makefile either to set EXTRA_OPTFLAGS in +the environment or to pass EXTRA_OPTFLAGS as a macro definition on the +command line. EXTRA_OPTFLAGS extends (and potentially overrides) default C +compilation flags set in the makefiles. + +Cc: Liming Gao +Cc: Yonghong Zhu +Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 +Contributed-under: TianoCore Contribution Agreement 1.1 +Signed-off-by: Laszlo Ersek +Reviewed-by: Liming Gao +(cherry picked from commit b0ca5dae78ff71397a8ef568f1914da7668ff5a9) +--- + BaseTools/Source/C/Makefiles/header.makefile | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile +index 498c6cf48b..1b4cad5497 100644 +--- a/BaseTools/Source/C/Makefiles/header.makefile ++++ b/BaseTools/Source/C/Makefiles/header.makefile +@@ -69,7 +69,10 @@ 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_OPTFLAGS = -O2 ++ ++# keep EXTRA_OPTFLAGS last ++BUILD_OPTFLAGS = -O2 $(EXTRA_OPTFLAGS) ++ + 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 -Wno-unused-result -nostdlib -g diff --git a/0021-BaseTools-Source-C-take-EXTRA_LDFLAGS-from-the-calle.patch b/0021-BaseTools-Source-C-take-EXTRA_LDFLAGS-from-the-calle.patch new file mode 100644 index 0000000..ed987d0 --- /dev/null +++ b/0021-BaseTools-Source-C-take-EXTRA_LDFLAGS-from-the-calle.patch @@ -0,0 +1,35 @@ +From c1a087a76d91665433f190d0468be2b33da443cd Mon Sep 17 00:00:00 2001 +From: Laszlo Ersek +Date: Thu, 26 Jul 2018 01:24:40 +0200 +Subject: [PATCH] BaseTools/Source/C: take EXTRA_LDFLAGS from the caller + +Allow the caller of the top-level makefile either to set EXTRA_LDFLAGS in +the environment or to pass EXTRA_LDFLAGS as a macro definition on the +command line. EXTRA_LDFLAGS extends (and potentially overrides) default +link-editing flags set in the makefiles. + +Cc: Liming Gao +Cc: Yonghong Zhu +Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 +Contributed-under: TianoCore Contribution Agreement 1.1 +Signed-off-by: Laszlo Ersek +Reviewed-by: Liming Gao +(cherry picked from commit 81502cee20ac4046f08bb4aec754c7091c8808dc) +--- + BaseTools/Source/C/Makefiles/header.makefile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile +index 1b4cad5497..7f283d6464 100644 +--- a/BaseTools/Source/C/Makefiles/header.makefile ++++ b/BaseTools/Source/C/Makefiles/header.makefile +@@ -99,6 +99,9 @@ endif + BUILD_CFLAGS += $(BUILD_OPTFLAGS) + BUILD_CXXFLAGS += $(BUILD_OPTFLAGS) + ++# keep EXTRA_LDFLAGS last ++BUILD_LFLAGS += $(EXTRA_LDFLAGS) ++ + .PHONY: all + .PHONY: install + .PHONY: clean diff --git a/0022-BaseTools-VfrCompile-honor-EXTRA_LDFLAGS.patch b/0022-BaseTools-VfrCompile-honor-EXTRA_LDFLAGS.patch new file mode 100644 index 0000000..a3e89c5 --- /dev/null +++ b/0022-BaseTools-VfrCompile-honor-EXTRA_LDFLAGS.patch @@ -0,0 +1,69 @@ +From d30cba687d657a68bf83b8dd54db63b3e2e6cb54 Mon Sep 17 00:00:00 2001 +From: Laszlo Ersek +Date: Thu, 16 Aug 2018 19:38:02 -0700 +Subject: [PATCH] BaseTools/VfrCompile: honor EXTRA_LDFLAGS + +In commit 81502cee20ac ("BaseTools/Source/C: take EXTRA_LDFLAGS from the +caller", 2018-08-16), I missed that "VfrCompile/GNUmakefile" does not use +BUILD_LFLAGS in the APPLICATION linking rule, unlike "app.makefile" does. +Instead, "VfrCompile/GNUmakefile" uses the (undefined) LFLAGS macro. +Therefore commit 81502cee20ac did not cover the linking step of +VfrCompile. + +Thankfully, the structure of the linking rules is the same, between +"app.makefile" and "VfrCompile/GNUmakefile". Rename the undefined LFLAGS +macro in "VfrCompile/GNUmakefile" to VFR_LFLAGS (for consistency with +VFR_CXXFLAGS), and set it to EXTRA_LDFLAGS. + +As a result, we have: + + | compilation | linking + -----------+--------------------------------+---------------------- + VfrCompile | VFR_CXXFLAGS = | VFR_LFLAGS = + | BUILD_OPTFLAGS = | EXTRA_LDFLAGS + | '-O2' + EXTRA_OPTFLAGS | + -----------+--------------------------------+---------------------- + other apps | BUILD_CFLAGS/BUILD_CXXFLAGS = | BUILD_LFLAGS = + | [...] + BUILD_OPTFLAGS = | [...] + EXTRA_LDFLAGS + | [...] + '-O2' + EXTRA_OPTFLAGS | + +This table shows +- that the VfrCompile compilation and linking flags are always a subset of + the corresponding flags used by the other apps, +- and that the EXTRA flags are always at the end. + +Cc: Liming Gao +Cc: Yonghong Zhu +Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 +Fixes: 81502cee20ac4046f08bb4aec754c7091c8808dc +Contributed-under: TianoCore Contribution Agreement 1.1 +Signed-off-by: Laszlo Ersek +Reviewed-by: Liming Gao +(cherry picked from commit aa4e0df1f0c7ffdff07d7e382c9da89cbe207cdb) +--- + BaseTools/Source/C/VfrCompile/GNUmakefile | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C/VfrCompile/GNUmakefile +index bbe562cbc5..9273589ff8 100644 +--- a/BaseTools/Source/C/VfrCompile/GNUmakefile ++++ b/BaseTools/Source/C/VfrCompile/GNUmakefile +@@ -28,6 +28,9 @@ VFR_CPPFLAGS = -DPCCTS_USE_NAMESPACE_STD $(BUILD_CPPFLAGS) + # keep BUILD_OPTFLAGS last + VFR_CXXFLAGS = $(BUILD_OPTFLAGS) + ++# keep EXTRA_LDFLAGS last ++VFR_LFLAGS = $(EXTRA_LDFLAGS) ++ + LINKER = $(BUILD_CXX) + + EXTRA_CLEAN_OBJECTS = EfiVfrParser.cpp EfiVfrParser.h VfrParser.dlg VfrTokens.h VfrLexer.cpp VfrLexer.h VfrSyntax.cpp tokens.h +@@ -42,7 +45,7 @@ APPLICATION = $(MAKEROOT)/bin/$(APPNAME) + all: $(MAKEROOT)/bin $(APPLICATION) + + $(APPLICATION): $(OBJECTS) +- $(LINKER) -o $(APPLICATION) $(LFLAGS) $(OBJECTS) -L$(MAKEROOT)/libs $(LIBS) ++ $(LINKER) -o $(APPLICATION) $(VFR_LFLAGS) $(OBJECTS) -L$(MAKEROOT)/libs $(LIBS) + + VfrCompiler.o: ../Include/Common/BuildVersion.h + diff --git a/edk2.spec b/edk2.spec index 56baa9c..9b80c15 100644 --- a/edk2.spec +++ b/edk2.spec @@ -69,6 +69,13 @@ Patch0013: 0013-OvmfPkg-EnrollDefaultKeys-application-for-enrolling-.patch Patch0014: 0014-ArmPlatformPkg-introduce-fixed-PCD-for-early-hello-m.patch Patch0015: 0015-ArmPlatformPkg-PrePeiCore-write-early-hello-message-.patch Patch0016: 0016-ArmVirtPkg-set-early-hello-message-RH-only.patch +# Fix passing through RPM build flags (bz 1540244) +Patch0017: 0017-BaseTools-footer.makefile-expand-BUILD_CFLAGS-last-f.patch +Patch0018: 0018-BaseTools-header.makefile-remove-c-from-BUILD_CFLAGS.patch +Patch0019: 0019-BaseTools-Source-C-split-O2-to-BUILD_OPTFLAGS.patch +Patch0020: 0020-BaseTools-Source-C-take-EXTRA_OPTFLAGS-from-the-call.patch +Patch0021: 0021-BaseTools-Source-C-take-EXTRA_LDFLAGS-from-the-calle.patch +Patch0022: 0022-BaseTools-VfrCompile-honor-EXTRA_LDFLAGS.patch %if 0%{?cross:1} # Tweak the tools_def to support cross-compiling. @@ -271,7 +278,9 @@ ARM_FLAGS="${CC_FLAGS}" ARM_FLAGS="${ARM_FLAGS} -D DEBUG_PRINT_ERROR_LEVEL=0x8040004F" unset MAKEFLAGS -make -C BaseTools #%{?_smp_mflags} +make -C BaseTools %{?_smp_mflags} \ + EXTRA_OPTFLAGS="%{optflags}" \ + EXTRA_LDFLAGS="%{__global_ldflags}" sed -i -e 's/-Werror//' Conf/tools_def.txt @@ -518,6 +527,9 @@ install qemu-ovmf-secureboot-%{qosb_version}/ovmf-vars-generator %{buildroot}%{_ %changelog +* Fri Aug 31 2018 Cole Robinson - 20180815gitcb5f4f45ce-2 +- Fix passing through RPM build flags (bz 1540244) + * Tue Aug 21 2018 Cole Robinson - 20180815gitcb5f4f45ce-1 - Update to edk2 git cb5f4f45ce, edk2-stable201808 - Update to qemu-ovmf-secureboot-1.1.3