Re: [PATCH v2] perf: Avoid implicit function declarations in lexer/parse interface

From: Arnaldo Carvalho de Melo
Date: Fri Apr 28 2023 - 21:34:34 EST


Em Tue, Apr 25, 2023 at 10:40:14AM -0700, Ian Rogers escreveu:
> On Tue, Apr 25, 2023 at 10:12 AM Florian Weimer <fweimer@xxxxxxxxxx> wrote:
> >
> > In future compilers, -Wno-implicit-function-declaration may not bring
> > back support for implicit function declarations, a feature that was
> > removed from the C language in C99. Instead of relying on implicit
> > declarations, include the flex-generated header from the
> > bison-generated C code.
> >
> > he expr-flex.h header needs to be included later than the others
>
> nit: s/he/The/
>
> > because at the early point, the definition of YYSTYPE is not yet
> > available.
> >
> > Signed-off-by: Florian Weimer <fweimer@xxxxxxxxxx>
>
> Acked-by: Ian Rogers <irogers@xxxxxxxxxx>
>
> Thanks for fighting the build wrt parallel dependencies!
> Ian


Thanks, applied. BTW b4 coulnd't find this message (nor the original):

⬢[acme@toolbox perf-tools-next]$ b4 am -ctsl --cc-trailers 87sfcn7uot.fsf@xxxxxxxxxxxxxxxxxxxxxxxx
Grabbing thread from lore.kernel.org/all/87sfcn7uot.fsf%40oldenburg.str.redhat.com/t.mbox.gz
That message-id is not known.
⬢[acme@toolbox perf-tools-next]$ b4 am -ctsl --cc-trailers CAP-5=fXZv+KCdCN05wVUcAwDCZAgXjWunoaviGBQEiUPqNwOmg@xxxxxxxxxxxxxx
Grabbing thread from lore.kernel.org/all/CAP-5%3DfXZv%2BKCdCN05wVUcAwDCZAgXjWunoaviGBQEiUPqNwOmg%40mail.gmail.com/t.mbox.gz
Analyzing 1 messages in the thread
No patches found.
⬢[acme@toolbox perf-tools-next]$

I applied it in the old fashion.


- Arnaldo


> > ---
> > v2: Include the flex-generated files instead of manually-written prototypes.
> >
> > tools/perf/util/Build | 10 +++++++++-
> > tools/perf/util/expr.y | 2 ++
> > tools/perf/util/parse-events.y | 1 +
> > tools/perf/util/pmu.y | 1 +
> > 4 files changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> > index 918b501f9bd8..92897068c362 100644
> > --- a/tools/perf/util/Build
> > +++ b/tools/perf/util/Build
> > @@ -283,7 +283,7 @@ CFLAGS_expr-flex.o += $(flex_flags)
> > bison_flags := -DYYENABLE_NLS=0
> > BISON_GE_35 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\)/\1\2/g') \>\= 35)
> > ifeq ($(BISON_GE_35),1)
> > - bison_flags += -Wno-unused-parameter -Wno-nested-externs -Wno-implicit-function-declaration -Wno-switch-enum -Wno-unused-but-set-variable -Wno-unknown-warning-option
> > + bison_flags += -Wno-unused-parameter -Wno-nested-externs -Wno-switch-enum -Wno-unused-but-set-variable -Wno-unknown-warning-option
> > else
> > bison_flags += -w
> > endif
> > @@ -340,3 +340,11 @@ $(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE
> > $(OUTPUT)util/list_sort.o: ../lib/list_sort.c FORCE
> > $(call rule_mkdir)
> > $(call if_changed_dep,cc_o_c)
> > +
> > +# These dependencies ensure that the flex-generated .h file is
> > +# available at the time the bison-generated .c sources are compiled.
> > +# Do not depend on the generated .h file to prevent triggering
> > +# parallel flex invocations for the same two output files.
> > +$(OUTPUT)util/expr-bison.o : $(OUTPUT)util/expr-flex.c
> > +$(OUTPUT)util/parse-events-bison.o : $(OUTPUT)util/parse-events-flex.c
> > +$(OUTPUT)util/pmu-bison.o : $(OUTPUT)util/pmu-flex.c
> > diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
> > index 635e562350c5..99581193ca4c 100644
> > --- a/tools/perf/util/expr.y
> > +++ b/tools/perf/util/expr.y
> > @@ -53,6 +53,8 @@
> > %destructor { ids__free($$.ids); } <ids>
> >
> > %{
> > +#include "expr-flex.h"
> > +
> > static void expr_error(double *final_val __maybe_unused,
> > struct expr_parse_ctx *ctx __maybe_unused,
> > bool compute_ids __maybe_unused,
> > diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> > index be8c51770051..67a7f70c4767 100644
> > --- a/tools/perf/util/parse-events.y
> > +++ b/tools/perf/util/parse-events.y
> > @@ -17,6 +17,7 @@
> > #include "evsel.h"
> > #include "parse-events.h"
> > #include "parse-events-bison.h"
> > +#include "parse-events-flex.h"
> >
> > void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg);
> >
> > diff --git a/tools/perf/util/pmu.y b/tools/perf/util/pmu.y
> > index e675d79a0274..2170f1ac7b74 100644
> > --- a/tools/perf/util/pmu.y
> > +++ b/tools/perf/util/pmu.y
> > @@ -9,6 +9,7 @@
> > #include <linux/bitmap.h>
> > #include <string.h>
> > #include "pmu.h"
> > +#include "pmu-flex.h"
> >
> > #define ABORT_ON(val) \
> > do { \
> >
> > base-commit: 173ea743bf7a9eef04460e03b00ba267cc52aee2
> >

--

- Arnaldo