Re: [PATCH 2/2] perf jevents: Enable warnings through HOSTCFLAGS

From: John Garry
Date: Tue Oct 19 2021 - 04:34:40 EST


On 18/10/2021 11:41, James Clark wrote:


On 15/10/2021 17:48, John Garry wrote:
Currently no compiler warnings at all are enabled for building jevents,
so help catch bugs at compile time by enabling through HOSTCFLAGS.


Hi James,

Is there any reason to not enable -Wall and -Werror so that it builds like
the main project? Or if HOSTCFLAGS ends up being the same as CORE_CFLAGS
then why not use CORE_CFLAGS instead?

I am not sure that we really want that, as CORE_CFLAGS brings with it things like _LARGEFILE64_SOURCE, which I doubt we want.


I added them like this and only one unused function needs to be removed to
make it build successfully:


diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 65934984f032..b2edcedf01db 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -18,6 +18,8 @@ detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
+HOSTCFLAGS += -Wall
+HOSTCFLAGS += -Wextra
include $(srctree)/tools/scripts/Makefile.arch
@@ -212,6 +214,7 @@ endif
ifneq ($(WERROR),0)
CORE_CFLAGS += -Werror
CXXFLAGS += -Werror
+ HOSTCFLAGS += -Werror

These seem fine to add. Actually what I have in HOSTCFLAGS doesn't seem to detect unused functions, with one example fixed in b94729919db2.

Thanks,
John