perf tools jevents build flags (was Re: [PATCH] perf jevents: Fix sys_event_tables to be freed like arch_std_events)

John Garry
2021-10-11T17:01:05Z

On 28/09/2021 21:30, John Garry wrote:
>>>
>>> OK, would you also consider reusing CFLAGS:
>>>
>>> --- a/tools/perf/pmu-events/Build
>>> +++ b/tools/perf/pmu-events/Build
>>> @@ -9,10 +9,12 @@ JSON          =  $(shell [ -d $(JDIR) ] &&
>>> \
>>> JDIR_TEST      =  pmu-events/arch/test
>>> JSON_TEST      =  $(shell [ -d $(JDIR_TEST) ] &&                       \
>>>                         find $(JDIR_TEST) -name '*.json')
>>> -
>>> +HOSTCFLAGS_jevents += $(CFLAGS)
>> Humm, we have to check if CFLAGS doesn't come with cross-build options,
>> i.e. IIRC we have to use HOSTCFLAGS instead. Unsure if there is some
>> *CFLAGS variable that gets the common part, where these -Wall and
>> -Wextra, -Werror could go.
>
> not sure. As I see, the bulk of flags we have in CFLAGS comes from
> EXTRA_WARNINGS in scripts/Makefile.include; but CFLAGS seems to also
> include EXTRA_CLAGS, which are for cross-builds (see perf/Makefile.config)
>

Hi Arnaldo,

I'm just looking at enabling warning cflags for jevents again.

So how about this:

--->8----

Subject: [PATCH] perf pmu-events: Enable jevents warnings through HOSTCFLAGS

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 0ae2e3d8b832..65934984f032 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -17,6 +17,7 @@ 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))
+HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))

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

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 7df13e74450c..118bcdc70bb4 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -226,7 +226,7 @@ else
endif

export srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWK
-export HOSTCC HOSTLD HOSTAR
+export HOSTCC HOSTLD HOSTAR HOSTCFLAGS

include $(srctree)/tools/build/Makefile.include

diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
index a055dee6a46a..d5c287f069a2 100644
--- a/tools/perf/pmu-events/Build
+++ b/tools/perf/pmu-events/Build
@@ -1,7 +1,7 @@
hostprogs := jevents

jevents-y += json.o jsmn.o jevents.o
-HOSTCFLAGS_jevents.o = -I$(srctree)/tools/include
+HOSTCFLAGS_jevents.o = -I$(srctree)/tools/include $(HOSTCFLAGS)
pmu-events-y += pmu-events.o
JDIR = pmu-events/arch/$(SRCARCH)
JSON = $(shell [ -d $(JDIR) ] && \
--
2.26.2

---8<---

The newly generated warnings in jevents.c are pretty straightforward to
tidy up.

Thanks,
John