Skip to contentSkip to conversation

tools/perf: tools: Fix perf build issues

PATCH In review Masami Hiramatsu 2 participants 4 messages May 11, 2021 perf events

lore
Share & tools
lore
#0 lore raw

cover tools/perf: tools: Fix perf build issues

Hi,

These are the patches to fix the perf build issues which I reported in the previous email.

https://lore.kernel.org/lkml/162037766527.94840.4323848545957010011.stgit@devnote2/

There are 2 issues I found and are fixed with these patches.

- Since the EXTRA_CLFAGS/WARNINGS are listed before -Wall/-Wextra in CFLAGS, all -Wno-* flags in the EXTRA_CFLAGS/WARNINGS are ignored. This makes EXTRA_WARNINGS ignored and developers can not use EXTRA_CLFAGS for debugging compiler warnings.

- Clang's missing-field-initializers warning is too sensitive compared with GCC. I think "{ NULL }" kind of syntax is allowed for simplify code.

Thank you,

---

Masami Hiramatsu (2):
perf build: Move EXTRA_CFLAGS and EXTRA_WARNINGS at the end of CFLAGS
tools: Add -Wno-missing-field-initializers to for clang

 tools/perf/Makefile.config     |    3 ++-
 tools/scripts/Makefile.include |    4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

--
Masami Hiramatsu (Linaro) <[email protected]>

#1 lore raw

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

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

---
 tools/perf/Makefile.config |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/Makefile.config +2 -1
index 406a9519145e..2ad46c66bc7b 100644
@@ -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)
#2 lore raw

PATCH 2/2 tools: Add -Wno-missing-field-initializers to for clang

In reply to Masami Hiramatsu

Since clang's -Wmissing-field-initializers warns valid syntax of initializing data structure (e.g. initializing static data structure with single NULL, the rest of fields are initialized with zero), it is better to disable this warning option for clang for now.
This can stop building perf because -Werror is also specified.

Note that same issue on gcc has been fixed in 4.7.0, so we don't need this for gcc.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750

---
 tools/scripts/Makefile.include |    4 ++++
 1 file changed, 4 insertions(+)
tools/scripts/Makefile.include +4 -0
index f9271f3ea912..4fd5d33ded03 100644
@@ -89,6 +89,10 @@ ifeq ($(CC_NO_CLANG), 1)
 EXTRA_WARNINGS += -Wstrict-aliasing=3
 endif
 
+ifneq ($(CC_NO_CLANG), 1)
+EXTRA_WARNINGS += -Wno-missing-field-initializers
+endif
+
 # Hack to avoid type-punned warnings on old systems such as RHEL5:
 # We should be changing CFLAGS and checking gcc version, but this
 # will do for now and keep the above -Wstrict-aliasing=3 in place
Acked-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] tools: Add -Wno-missing-field-initializers to for clang

Quoted 8 lines · Masami Hiramatsu

Since clang's -Wmissing-field-initializers warns valid syntax of initializing data structure (e.g. initializing static data structure with single NULL, the rest of fields are initialized with zero), it is better to disable this warning option for clang for now.
This can stop building perf because -Werror is also specified.

Quoted 6 lines

Note that same issue on gcc has been fixed in 4.7.0, so we don't need this for gcc.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750

Seems fine, it's only enabled for the kernel at W=2 anyways.

Quoted 20 lines
---
 tools/scripts/Makefile.include |    4 ++++
 1 file changed, 4 insertions(+)
tools/scripts/Makefile.include +4 -0
index f9271f3ea912..4fd5d33ded03 100644
@@ -89,6 +89,10 @@ ifeq ($(CC_NO_CLANG), 1)
 EXTRA_WARNINGS += -Wstrict-aliasing=3
 endif
 
+ifneq ($(CC_NO_CLANG), 1)
+EXTRA_WARNINGS += -Wno-missing-field-initializers
+endif
+
 # Hack to avoid type-punned warnings on old systems such as RHEL5:
 # We should be changing CFLAGS and checking gcc version, but this
 # will do for now and keep the above -Wstrict-aliasing=3 in place
Signature · 2 lines
Thanks,
~Nick Desaulniers