[PATCH 1/2] perf build: Move EXTRA_CFLAGS and EXTRA_WARNINGS at the end of CFLAGS

From: Masami Hiramatsu
Date: Tue May 11 2021 - 11:02:40 EST


Move EXTRA_CFLAGS and EXTRA_WARNINGS at the end of CFLAGS so that
additional flags will be passed to the compiler correctly.

CFLAGS is composed by CORE_CFLAGS, INC_FLAGS, EXTRA_CFLAGS, and
EXTRA_WARNINGS in the following order;

CFLAGS = $EXTRA_CFLAGS $EXTRA_WARNINGS $CORE_CFLAGS $INC_FLAGS

But since CORE_CFLAGS includes "-Wall" and "-Wextra", the other -Wno-*
flags in EXTRA_CFLAGS and EXTRA_WARNINGS are overridden and ignored.

To fix this issue, move those EXTRA_* at the end of CFLAGS definition
as below.

CFLAGS = $CORE_CFLAGS $INC_FLAGS $EXTRA_CFLAGS $EXTRA_WARNINGS

Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
---
tools/perf/Makefile.config | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 406a9519145e..2ad46c66bc7b 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -16,7 +16,7 @@ $(shell printf "" > $(OUTPUT).config-detected)
detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)

-CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
+CFLAGS :=

include $(srctree)/tools/scripts/Makefile.arch

@@ -340,6 +340,7 @@ INC_FLAGS += -I$(srctree)/tools/lib/
CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE

CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS)
+CFLAGS += $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
CXXFLAGS += $(INC_FLAGS)

LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)