:p
atchew
Login
Repo: https://github.com/lersek/edk2.git Branch: extra_flags_rhbz1540244 In the Fedora distribution, we'd like to pass system-wide flags related to optimization and linking when the C and C++ language base tools are built. This series lets the outermost "make" command push the EXTRA_OPTFLAGS and EXTRA_LDFLAGS macros into the BaseTools build. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Thanks Laszlo Laszlo Ersek (6): BaseTools/footer.makefile: expand BUILD_CFLAGS last for C files too BaseTools/header.makefile: remove "-c" from BUILD_CFLAGS BaseTools/Source/C: split "-O2" to BUILD_OPTFLAGS BaseTools/Pccts: clean up antlr and dlg makefiles BaseTools/Source/C: take EXTRA_OPTFLAGS from the caller BaseTools/Source/C: take EXTRA_LDFLAGS from the caller BaseTools/Source/C/Makefiles/footer.makefile | 2 +- BaseTools/Source/C/Makefiles/header.makefile | 16 ++++++++--- BaseTools/Source/C/VfrCompile/GNUmakefile | 11 +++++--- BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 22 ++++++++++----- BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile | 28 +++++++++++++------- 5 files changed, 56 insertions(+), 23 deletions(-) -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/footer.makefile +++ b/BaseTools/Source/C/Makefiles/footer.makefile @@ -XXX,XX +XXX,XX @@ $(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 $@ -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -XXX,XX +XXX,XX @@ 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 -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -XXX,XX +XXX,XX @@ $(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 @@ -XXX,XX +XXX,XX @@ 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/VfrCompile/GNUmakefile +++ b/BaseTools/Source/C/VfrCompile/GNUmakefile @@ -XXX,XX +XXX,XX @@ 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 @@ -XXX,XX +XXX,XX @@ 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 -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
(1) "-I" and "-D" options are for the preprocessor; move them to BUILD_CPPFLAGS. (This unifies BUILD_CPPFLAGS between both makefiles.) (2) COTHER is never set, drop it from "antlr". (This unifies BUILD_CFLAGS between both makefiles, as COPT.) (3) For linking "antlr" and "dlg", both BUILD_CFLAGS and BUILD_CPPFLAGS are useless, so drop BUILD_CFLAGS, and don't add BUILD_CPPFLAGS. (4) For compiling C source files: (4a) Move the "-c" mode selector to the front. (4b) Expand both BUILD_CPPFLAGS and BUILD_CFLAGS, in this order. (This results in COPT being expanded last.) (4c) Turn the source file operand into the last argument on the command line. The only change in behavior from this patch is that the following options disappear from the link-editing steps (due to (3)): -O -I. -I../support/set -I../h -DUSER_ZZSYN -DZZLEXBUFSIZE=65536 However these options made no difference for linking in the first place. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 13 ++++++++----- BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile index XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile @@ -XXX,XX +XXX,XX @@ ANTLR=${BIN_DIR}/antlr DLG=${BIN_DIR}/dlg OBJ_EXT=o OUT_OBJ = -o -BUILD_CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536 -BUILD_CPPFLAGS= + +# keep COPT last +BUILD_CFLAGS=$(COPT) + +BUILD_CPPFLAGS=-I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536 # # SGI Users, use this CFLAGS # @@ -XXX,XX +XXX,XX @@ OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o \ globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o $(BIN_DIR)/antlr : $(OBJ) $(SRC) - $(BUILD_CC) $(BUILD_CFLAGS) -o $(BIN_DIR)/antlr $(OBJ) + $(BUILD_CC) -o $(BIN_DIR)/antlr $(OBJ) # what files does PCCTS generate (both ANTLR and DLG) PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h @@ -XXX,XX +XXX,XX @@ scan.o : scan.c mode.h tokens.h # $(DLG) -C2 parser.dlg scan.c set.o : $(SET)/set.c - $(BUILD_CC) $(BUILD_CFLAGS) -c -o set.o $(SET)/set.c + $(BUILD_CC) -c $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -o set.o $(SET)/set.c %.o : %.c - $(BUILD_CC) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< -o $@ + $(BUILD_CC) -c $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -o $@ $< # # ****** These next targets are common to UNIX and PC world ******** diff --git a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile index XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile @@ -XXX,XX +XXX,XX @@ BUILD_CC?=cc COPT=-O ANTLR=${BIN_DIR}/antlr DLG=${BIN_DIR}/dlg -BUILD_CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536 -BUILD_CPPFLAGS= + +# keep COPT last +BUILD_CFLAGS=$(COPT) + +BUILD_CPPFLAGS=-I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536 OBJ_EXT=o OUT_OBJ = -o OBJ = dlg_p.o dlg_a.o main.o err.o set.o support.o output.o \ relabel.o automata.o $(BIN_DIR)/dlg : $(OBJ) $(SRC) - $(BUILD_CC) $(BUILD_CFLAGS) -o $(BIN_DIR)/dlg $(OBJ) + $(BUILD_CC) -o $(BIN_DIR)/dlg $(OBJ) SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \ relabel.c automata.c @@ -XXX,XX +XXX,XX @@ SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \ # $(DLG) -C2 parser.dlg dlg_a.c dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h - $(BUILD_CC) $(BUILD_CFLAGS) -c dlg_p.c + $(BUILD_CC) -c $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) dlg_p.c dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h - $(BUILD_CC) $(BUILD_CFLAGS) -c dlg_a.c + $(BUILD_CC) -c $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) dlg_a.c main.$(OBJ_EXT) : main.c dlg.h - $(BUILD_CC) $(BUILD_CFLAGS) -c main.c + $(BUILD_CC) -c $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) main.c set.$(OBJ_EXT) : $(SET)/set.c - $(BUILD_CC) -c $(BUILD_CFLAGS) $(SET)/set.c + $(BUILD_CC) -c $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) $(SET)/set.c %.o : %.c - $(BUILD_CC) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< -o $@ + $(BUILD_CC) -c $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -o $@ $< lint: lint *.c -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- BaseTools/Source/C/Makefiles/header.makefile | 5 ++++- BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 5 ++++- BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile index XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -XXX,XX +XXX,XX @@ 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/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile index XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile @@ -XXX,XX +XXX,XX @@ PCCTS_H=../h # UNIX (default) # BUILD_CC?=gcc -COPT=-O + +# keep EXTRA_OPTFLAGS last +COPT=-O $(EXTRA_OPTFLAGS) + ANTLR=${BIN_DIR}/antlr DLG=${BIN_DIR}/dlg OBJ_EXT=o diff --git a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile index XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile @@ -XXX,XX +XXX,XX @@ PCCTS_H=../h # UNIX # BUILD_CC?=cc -COPT=-O + +# keep EXTRA_OPTFLAGS last +COPT=-O $(EXTRA_OPTFLAGS) + ANTLR=${BIN_DIR}/antlr DLG=${BIN_DIR}/dlg -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- BaseTools/Source/C/Makefiles/header.makefile | 3 +++ BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 6 +++++- BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile index XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -XXX,XX +XXX,XX @@ 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/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile index XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile @@ -XXX,XX +XXX,XX @@ OUT_OBJ = -o BUILD_CFLAGS=$(COPT) BUILD_CPPFLAGS=-I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536 + +# keep EXTRA_LDFLAGS last +BUILD_LFLAGS = $(EXTRA_LDFLAGS) + # # SGI Users, use this CFLAGS # @@ -XXX,XX +XXX,XX @@ OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o \ globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o $(BIN_DIR)/antlr : $(OBJ) $(SRC) - $(BUILD_CC) -o $(BIN_DIR)/antlr $(OBJ) + $(BUILD_CC) -o $(BIN_DIR)/antlr $(BUILD_LFLAGS) $(OBJ) # what files does PCCTS generate (both ANTLR and DLG) PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h diff --git a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile index XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile @@ -XXX,XX +XXX,XX @@ DLG=${BIN_DIR}/dlg BUILD_CFLAGS=$(COPT) BUILD_CPPFLAGS=-I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536 + +# keep EXTRA_LDFLAGS last +BUILD_LFLAGS = $(EXTRA_LDFLAGS) + OBJ_EXT=o OUT_OBJ = -o OBJ = dlg_p.o dlg_a.o main.o err.o set.o support.o output.o \ relabel.o automata.o $(BIN_DIR)/dlg : $(OBJ) $(SRC) - $(BUILD_CC) -o $(BIN_DIR)/dlg $(OBJ) + $(BUILD_CC) -o $(BIN_DIR)/dlg $(BUILD_LFLAGS) $(OBJ) SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \ relabel.c automata.c -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Repo: https://github.com/lersek/edk2.git Branch: extra_flags_rhbz1540244_v2 Version 1 of this set was posted at http://mid.mail-archive.com/20180726004415.13381-1-lersek@redhat.com https://lists.01.org/pipermail/edk2-devel/2018-July/027606.html In version 2 (i.e., this version), the PCCTS tools (the "dlg" lexer generator and the "antlr" parser generator) are not modified. Relative to v1: - "[PATCH 4/6] BaseTools/Pccts: clean up antlr and dlg makefiles" has been dropped, - the "BaseTools/Source/C/VfrCompile/Pccts" hunks have been removed from "[PATCH 5/6] BaseTools/Source/C: take EXTRA_OPTFLAGS from the caller" and "[PATCH 6/6] BaseTools/Source/C: take EXTRA_LDFLAGS from the caller". In other words, v2 is a proper subset of v1, so that PCCTS is left alone. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Thanks! Laszlo Laszlo Ersek (5): BaseTools/footer.makefile: expand BUILD_CFLAGS last for C files too BaseTools/header.makefile: remove "-c" from BUILD_CFLAGS BaseTools/Source/C: split "-O2" to BUILD_OPTFLAGS BaseTools/Source/C: take EXTRA_OPTFLAGS from the caller BaseTools/Source/C: take EXTRA_LDFLAGS from the caller BaseTools/Source/C/Makefiles/footer.makefile | 2 +- BaseTools/Source/C/Makefiles/header.makefile | 16 +++++++++++++--- BaseTools/Source/C/VfrCompile/GNUmakefile | 11 +++++++---- 3 files changed, 21 insertions(+), 8 deletions(-) -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com> --- Notes: v2: - pick up Liming's R-b 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/footer.makefile +++ b/BaseTools/Source/C/Makefiles/footer.makefile @@ -XXX,XX +XXX,XX @@ $(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 $@ -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com> --- Notes: v2: - pick up Liming's R-b 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -XXX,XX +XXX,XX @@ 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 -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com> --- Notes: v2: - pick up Liming's R-b 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -XXX,XX +XXX,XX @@ $(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 @@ -XXX,XX +XXX,XX @@ 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/VfrCompile/GNUmakefile +++ b/BaseTools/Source/C/VfrCompile/GNUmakefile @@ -XXX,XX +XXX,XX @@ 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 @@ -XXX,XX +XXX,XX @@ 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 -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- Notes: v2: - do not patch "antlr/makefile" and "dlg/makefile" under "BaseTools/Source/C/VfrCompile/Pccts" [Liming] 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -XXX,XX +XXX,XX @@ 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 -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
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 <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1540244 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- Notes: v2: - do not patch "antlr/makefile" and "dlg/makefile" under "BaseTools/Source/C/VfrCompile/Pccts" [Liming] 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 XXXXXXX..XXXXXXX 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -XXX,XX +XXX,XX @@ endif BUILD_CFLAGS += $(BUILD_OPTFLAGS) BUILD_CXXFLAGS += $(BUILD_OPTFLAGS) +# keep EXTRA_LDFLAGS last +BUILD_LFLAGS += $(EXTRA_LDFLAGS) + .PHONY: all .PHONY: install .PHONY: clean -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel