From: Ian Rogers Date: Fri, 28 Jul 2023 06:49:16 +0000 (-0700) Subject: perf build: Disable fewer bison warnings X-Git-Tag: accepted/tizen/unified/20240619.152004~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bfa24e0b634a28de50e681a73098bf2b84e4932f;p=platform%2Fkernel%2Flinux-amlogic.git perf build: Disable fewer bison warnings If bison is version 3.8.2, reduce the number of bison C warnings disabled. Earlier bison versions have all C warnings disabled. Avoid implicit declarations of yylex by adding the declaration in the C file. A header can't be included as a circular dependency would occur due to the lexer using the bison defined tokens. Committer notes: Some recent versions of gcc and clang (noticed on Alpine Linux 3.17, edge, clearlinux, fedora 37, etc. Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andrii Nakryiko Cc: Eduard Zingerman Cc: Gaosheng Cui Cc: Ingo Molnar Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Peter Zijlstra Cc: Rob Herring Cc: Tom Rix Cc: bpf@vger.kernel.org Cc: llvm@lists.linux.dev Link: https://lore.kernel.org/r/20230728064917.767761-6-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo [sw0312.kim: backport mainline commit ddc8e4c96692 to resolve gcc-14 build issue] Signed-off-by: Seung-Woo Kim Change-Id: I77396a323f66e759c5c37d5abeacf93419637ba2 --- diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 1dc67efad634..c82692215447 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -145,8 +145,21 @@ $(OUTPUT)util/pmu-bison.c: util/pmu.y CFLAGS_parse-events-flex.o += -w CFLAGS_pmu-flex.o += -w -CFLAGS_parse-events-bison.o += -DYYENABLE_NLS=0 -w -CFLAGS_pmu-bison.o += -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w + +# Some newer clang and gcc version complain about this +# util/parse-events-bison.c:1317:9: error: variable 'parse_events_nerrs' set but not used [-Werror,-Wunused-but-set-variable] +# int yynerrs = 0; + +bison_flags := -DYYENABLE_NLS=0 -Wno-unused-but-set-variable +BISON_GE_382 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 382) +ifeq ($(BISON_GE_382),1) + bison_flags += -Wno-switch-enum +else + bison_flags += -w +endif + +CFLAGS_parse-events-bison.o += $(bison_flags) +CFLAGS_pmu-bison.o += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags) $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 01e48a6e5d42..d30a565a6a96 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -15,6 +15,7 @@ #include "parse-events.h" #include "parse-events-bison.h" +int parse_events_lex(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , void *yyscanner); void parse_events_error(YYLTYPE *loc, void *data, void *scanner, char const *msg); #define ABORT_ON(val) \ diff --git a/tools/perf/util/pmu.y b/tools/perf/util/pmu.y index bfd7e8509869..60261e799934 100644 --- a/tools/perf/util/pmu.y +++ b/tools/perf/util/pmu.y @@ -9,6 +9,7 @@ #include #include #include "pmu.h" +#include "pmu-bison.h" extern int perf_pmu_lex (void);