Blame kernel-tools-c99.patch

eabe1bf
From: Florian Weimer <fweimer@redhat.com>
eabe1bf
Subject: [PATCH v4] perf: Avoid implicit function declarations in
eabe1bf
 lexer/parse interface
eabe1bf
To: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
eabe1bf
Cc:     Peter Zijlstra <peterz@infradead.org>,
eabe1bf
        Ingo Molnar <mingo@redhat.com>,
eabe1bf
        Arnaldo Carvalho de Melo <acme@kernel.org>,
eabe1bf
        Mark Rutland <mark.rutland@arm.com>,
eabe1bf
        Alexander Shishkin <alexander.shishkin@linux.intel.com>,
eabe1bf
        Jiri Olsa <jolsa@kernel.org>,
eabe1bf
        Namhyung Kim <namhyung@kernel.org>,
eabe1bf
        Ian Rogers <irogers@google.com>,
eabe1bf
        Adrian Hunter <adrian.hunter@intel.com>,
eabe1bf
        Ian Rogers <irogers@google.com>,
eabe1bf
        Justin M. Forbes <jforbes@fedoraproject.org>
eabe1bf
Date: Wed, 03 May 2023 20:06:09 +0200 (25 minutes, 29 seconds ago)
eabe1bf
Message-ID: <874jot47e6.fsf@oldenburg.str.redhat.com>
eabe1bf
eabe1bf
In future compilers, -Wno-implicit-function-declaration may not bring
eabe1bf
back support for implicit function declarations, a feature that was
eabe1bf
removed from the C language in C99.  Instead of relying on implicit
eabe1bf
declarations, include the flex-generated header from the
eabe1bf
bison-generated C code.
eabe1bf
eabe1bf
The expr-flex.h and pmu-flex.h headers needs to be included very late,
eabe1bf
so that the definition of YYSTYPE is available at that point.
eabe1bf
eabe1bf
Signed-off-by: Florian Weimer <fweimer@redhat.com>
eabe1bf
eabe1bf
---
eabe1bf
v4: Rebase on top of perf-next and integrate with bpf-filter.y as well.
eabe1bf
    Even later inclusion of "pmu-flex.h".
eabe1bf
v3: Fix commit message typo.  Try to repost via different mail server.
eabe1bf
v2: Include the flex-generated files instead of manually-written prototypes.
eabe1bf
 tools/perf/util/Build          | 11 ++++++++++-
eabe1bf
 tools/perf/util/bpf-filter.y   |  1 +
eabe1bf
 tools/perf/util/expr.y         |  2 ++
eabe1bf
 tools/perf/util/parse-events.y |  1 +
eabe1bf
 tools/perf/util/pmu.y          |  4 ++++
eabe1bf
 5 files changed, 18 insertions(+), 1 deletion(-)
eabe1bf
eabe1bf
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
eabe1bf
index bd18fe5f2719..865ce4f66756 100644
eabe1bf
--- a/tools/perf/util/Build
eabe1bf
+++ b/tools/perf/util/Build
eabe1bf
@@ -298,7 +298,7 @@ CFLAGS_bpf-filter-flex.o    += $(flex_flags)
eabe1bf
 bison_flags := -DYYENABLE_NLS=0
eabe1bf
 BISON_GE_35 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\)/\1\2/g') \>\= 35)
eabe1bf
 ifeq ($(BISON_GE_35),1)
eabe1bf
-  bison_flags += -Wno-unused-parameter -Wno-nested-externs -Wno-implicit-function-declaration -Wno-switch-enum -Wno-unused-but-set-variable -Wno-unknown-warning-option
eabe1bf
+  bison_flags += -Wno-unused-parameter -Wno-nested-externs -Wno-switch-enum -Wno-unused-but-set-variable -Wno-unknown-warning-option
eabe1bf
 else
eabe1bf
   bison_flags += -w
eabe1bf
 endif
eabe1bf
@@ -357,3 +357,12 @@ $(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE
eabe1bf
 $(OUTPUT)util/list_sort.o: ../lib/list_sort.c FORCE
eabe1bf
 	$(call rule_mkdir)
eabe1bf
 	$(call if_changed_dep,cc_o_c)
eabe1bf
+
eabe1bf
+# These dependencies ensure that the flex-generated .h file is
eabe1bf
+# available at the time the bison-generated .c sources are compiled.
eabe1bf
+# Do not depend on the generated .h file to prevent triggering
eabe1bf
+# parallel flex invocations for the same two output files.
eabe1bf
+$(OUTPUT)util/bpf-filter-bison.o : $(OUTPUT)util/bpf-filter-flex.c
eabe1bf
+$(OUTPUT)util/expr-bison.o : $(OUTPUT)util/expr-flex.c
eabe1bf
+$(OUTPUT)util/parse-events-bison.o : $(OUTPUT)util/parse-events-flex.c
eabe1bf
+$(OUTPUT)util/pmu-bison.o : $(OUTPUT)util/pmu-flex.c
eabe1bf
diff --git a/tools/perf/util/bpf-filter.y b/tools/perf/util/bpf-filter.y
eabe1bf
index 07d6c7926c13..935afafe22eb 100644
eabe1bf
--- a/tools/perf/util/bpf-filter.y
eabe1bf
+++ b/tools/perf/util/bpf-filter.y
eabe1bf
@@ -8,6 +8,7 @@
eabe1bf
 #include <linux/compiler.h>
eabe1bf
 #include <linux/list.h>
eabe1bf
 #include "bpf-filter.h"
eabe1bf
+#include "bpf-filter-flex.h"
eabe1bf
 
eabe1bf
 static void perf_bpf_filter_error(struct list_head *expr __maybe_unused,
eabe1bf
 				  char const *msg)
eabe1bf
diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
eabe1bf
index 250e444bf032..8879fa14960f 100644
eabe1bf
--- a/tools/perf/util/expr.y
eabe1bf
+++ b/tools/perf/util/expr.y
eabe1bf
@@ -53,6 +53,8 @@
eabe1bf
 %destructor { ids__free($$.ids); } <ids>
eabe1bf
 
eabe1bf
 %{
eabe1bf
+#include "expr-flex.h"
eabe1bf
+
eabe1bf
 static void expr_error(double *final_val __maybe_unused,
eabe1bf
 		       struct expr_parse_ctx *ctx __maybe_unused,
eabe1bf
 		       bool compute_ids __maybe_unused,
eabe1bf
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
eabe1bf
index 4488443e506e..401d33714b23 100644
eabe1bf
--- a/tools/perf/util/parse-events.y
eabe1bf
+++ b/tools/perf/util/parse-events.y
eabe1bf
@@ -17,6 +17,7 @@
eabe1bf
 #include "evsel.h"
eabe1bf
 #include "parse-events.h"
eabe1bf
 #include "parse-events-bison.h"
eabe1bf
+#include "parse-events-flex.h"
eabe1bf
 
eabe1bf
 void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner, char const *msg);
eabe1bf
 
eabe1bf
diff --git a/tools/perf/util/pmu.y b/tools/perf/util/pmu.y
eabe1bf
index dff4e892ac4d..9c67f3d05a80 100644
eabe1bf
--- a/tools/perf/util/pmu.y
eabe1bf
+++ b/tools/perf/util/pmu.y
eabe1bf
@@ -32,6 +32,10 @@ do { \
eabe1bf
 	DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS);
eabe1bf
 }
eabe1bf
 
eabe1bf
+%{
eabe1bf
+#include "pmu-flex.h"
eabe1bf
+%}
eabe1bf
+
eabe1bf
 %%
eabe1bf
 
eabe1bf
 format:
eabe1bf
eabe1bf
base-commit: 5d27a645f60940fdf589e4ff5351506a7f0fdbaa