If flex is version 2.6.4, reduce the number of flex C warnings
disabled. Earlier flex versions have all C warnings disabled.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/Build | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 96f4ea1d45c5..32239c4b0393 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -279,13 +279,9 @@ $(OUTPUT)util/bpf-filter-bison.c $(OUTPUT)util/bpf-filter-bison.h: util/bpf-filt
$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
-o $(OUTPUT)util/bpf-filter-bison.c -p perf_bpf_filter_
-FLEX_GE_26 := $(shell expr $(shell $(FLEX) --version | sed -e 's/flex \([0-9]\+\).\([0-9]\+\)/\1\2/g') \>\= 26)
-ifeq ($(FLEX_GE_26),1)
- flex_flags := -Wno-switch-enum -Wno-switch-default -Wno-unused-function -Wno-redundant-decls -Wno-sign-compare -Wno-unused-parameter -Wno-missing-prototypes -Wno-missing-declarations
- CC_HASNT_MISLEADING_INDENTATION := $(shell echo "int main(void) { return 0 }" | $(CC) -Werror -Wno-misleading-indentation -o /dev/null -xc - 2>&1 | grep -q -- -Wno-misleading-indentation ; echo $$?)
- ifeq ($(CC_HASNT_MISLEADING_INDENTATION), 1)
- flex_flags += -Wno-misleading-indentation
- endif
+FLEX_GE_264 := $(shell expr $(shell $(FLEX) --version | sed -e 's/flex \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 264)
+ifeq ($(FLEX_GE_264),1)
+ flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function
else
flex_flags := -w
endif
--
2.41.0.487.g6d72f3e995-goog
On 28/07/2023 07:49, Ian Rogers wrote:
> If flex is version 2.6.4, reduce the number of flex C warnings
> disabled. Earlier flex versions have all C warnings disabled.
Hi Ian,
I get a build error with either this one or the bison warning change:
$ make LLVM=1 -C tools/perf NO_BPF_SKEL=1 DEBUG=1
util/pmu-bison.c:855:9: error: variable 'perf_pmu_nerrs' set but not
used [-Werror,-Wunused-but-set-variable]
int yynerrs = 0;
I tried a clean build which normally fixes these kind of bison errors.
Let me know if you need any version info.
James
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/util/Build | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 96f4ea1d45c5..32239c4b0393 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -279,13 +279,9 @@ $(OUTPUT)util/bpf-filter-bison.c $(OUTPUT)util/bpf-filter-bison.h: util/bpf-filt
> $(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
> -o $(OUTPUT)util/bpf-filter-bison.c -p perf_bpf_filter_
>
> -FLEX_GE_26 := $(shell expr $(shell $(FLEX) --version | sed -e 's/flex \([0-9]\+\).\([0-9]\+\)/\1\2/g') \>\= 26)
> -ifeq ($(FLEX_GE_26),1)
> - flex_flags := -Wno-switch-enum -Wno-switch-default -Wno-unused-function -Wno-redundant-decls -Wno-sign-compare -Wno-unused-parameter -Wno-missing-prototypes -Wno-missing-declarations
> - CC_HASNT_MISLEADING_INDENTATION := $(shell echo "int main(void) { return 0 }" | $(CC) -Werror -Wno-misleading-indentation -o /dev/null -xc - 2>&1 | grep -q -- -Wno-misleading-indentation ; echo $$?)
> - ifeq ($(CC_HASNT_MISLEADING_INDENTATION), 1)
> - flex_flags += -Wno-misleading-indentation
> - endif
> +FLEX_GE_264 := $(shell expr $(shell $(FLEX) --version | sed -e 's/flex \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 264)
> +ifeq ($(FLEX_GE_264),1)
> + flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function
> else
> flex_flags := -w
> endif
Em Fri, Jul 28, 2023 at 09:50:59AM +0100, James Clark escreveu:
>
>
> On 28/07/2023 07:49, Ian Rogers wrote:
> > If flex is version 2.6.4, reduce the number of flex C warnings
> > disabled. Earlier flex versions have all C warnings disabled.
>
> Hi Ian,
>
> I get a build error with either this one or the bison warning change:
>
> $ make LLVM=1 -C tools/perf NO_BPF_SKEL=1 DEBUG=1
>
> util/pmu-bison.c:855:9: error: variable 'perf_pmu_nerrs' set but not
> used [-Werror,-Wunused-but-set-variable]
> int yynerrs = 0;
>
> I tried a clean build which normally fixes these kind of bison errors.
> Let me know if you need any version info.
Trying to build it with the command line above I get:
CC util/expr.o
CC util/parse-events.o
CC util/parse-events-flex.o
util/parse-events-flex.c:7503:13: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
if ( ! yyg->yy_state_buf )
^
util/parse-events-flex.c:7501:9: note: previous statement is here
if ( ! yyg->yy_state_buf )
^
1 error generated.
make[4]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:97: util/parse-events-flex.o] Error 1
make[4]: *** Waiting for unfinished jobs....
LD util/scripting-engines/perf-in.o
make[3]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:140: util] Error 2
make[2]: *** [Makefile.perf:682: perf-in.o] Error 2
make[2]: *** Waiting for unfinished jobs....
CC pmu-events/pmu-events.o
LD pmu-events/pmu-events-in.o
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
⬢[acme@toolbox perf-tools-next]$ clang --version
clang version 14.0.5 (Fedora 14.0.5-2.fc36)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
⬢[acme@toolbox perf-tools-next]$
Em Fri, Jul 28, 2023 at 10:59:38AM -0300, Arnaldo Carvalho de Melo escreveu: > Em Fri, Jul 28, 2023 at 09:50:59AM +0100, James Clark escreveu: > > > > > > On 28/07/2023 07:49, Ian Rogers wrote: > > > If flex is version 2.6.4, reduce the number of flex C warnings > > > disabled. Earlier flex versions have all C warnings disabled. > > > > Hi Ian, > > > > I get a build error with either this one or the bison warning change: > > > > $ make LLVM=1 -C tools/perf NO_BPF_SKEL=1 DEBUG=1 > > > > util/pmu-bison.c:855:9: error: variable 'perf_pmu_nerrs' set but not > > used [-Werror,-Wunused-but-set-variable] > > int yynerrs = 0; > > > > I tried a clean build which normally fixes these kind of bison errors. > > Let me know if you need any version info. > > Trying to build it with the command line above I get: > > CC util/expr.o > CC util/parse-events.o > CC util/parse-events-flex.o > util/parse-events-flex.c:7503:13: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] > if ( ! yyg->yy_state_buf ) > ^ > util/parse-events-flex.c:7501:9: note: previous statement is here > if ( ! yyg->yy_state_buf ) > ^ I added this to the patch to get it moving: make: Leaving directory '/var/home/acme/git/perf-tools-next/tools/perf' ⬢[acme@toolbox perf-tools-next]$ git diff diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 32239c4b0393c319..afa93eff495811cf 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -281,7 +281,7 @@ $(OUTPUT)util/bpf-filter-bison.c $(OUTPUT)util/bpf-filter-bison.h: util/bpf-filt FLEX_GE_264 := $(shell expr $(shell $(FLEX) --version | sed -e 's/flex \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 264) ifeq ($(FLEX_GE_264),1) - flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function + flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function -Wno-misleading-indentation else flex_flags := -w endif ⬢[acme@toolbox perf-tools-next]$ > 1 error generated. > make[4]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:97: util/parse-events-flex.o] Error 1 > make[4]: *** Waiting for unfinished jobs.... > LD util/scripting-engines/perf-in.o > make[3]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:140: util] Error 2 > make[2]: *** [Makefile.perf:682: perf-in.o] Error 2 > make[2]: *** Waiting for unfinished jobs.... > CC pmu-events/pmu-events.o > LD pmu-events/pmu-events-in.o > make[1]: *** [Makefile.perf:242: sub-make] Error 2 > make: *** [Makefile:70: all] Error 2 > > ⬢[acme@toolbox perf-tools-next]$ clang --version > clang version 14.0.5 (Fedora 14.0.5-2.fc36) > Target: x86_64-redhat-linux-gnu > Thread model: posix > InstalledDir: /usr/bin > ⬢[acme@toolbox perf-tools-next]$ -- - Arnaldo
On Fri, Jul 28, 2023 at 7:02 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Fri, Jul 28, 2023 at 10:59:38AM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Fri, Jul 28, 2023 at 09:50:59AM +0100, James Clark escreveu:
> > >
> > >
> > > On 28/07/2023 07:49, Ian Rogers wrote:
> > > > If flex is version 2.6.4, reduce the number of flex C warnings
> > > > disabled. Earlier flex versions have all C warnings disabled.
> > >
> > > Hi Ian,
> > >
> > > I get a build error with either this one or the bison warning change:
> > >
> > > $ make LLVM=1 -C tools/perf NO_BPF_SKEL=1 DEBUG=1
> > >
> > > util/pmu-bison.c:855:9: error: variable 'perf_pmu_nerrs' set but not
> > > used [-Werror,-Wunused-but-set-variable]
> > > int yynerrs = 0;
> > >
> > > I tried a clean build which normally fixes these kind of bison errors.
> > > Let me know if you need any version info.
> >
> > Trying to build it with the command line above I get:
> >
> > CC util/expr.o
> > CC util/parse-events.o
> > CC util/parse-events-flex.o
> > util/parse-events-flex.c:7503:13: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
> > if ( ! yyg->yy_state_buf )
> > ^
> > util/parse-events-flex.c:7501:9: note: previous statement is here
> > if ( ! yyg->yy_state_buf )
> > ^
>
> I added this to the patch to get it moving:
>
> make: Leaving directory '/var/home/acme/git/perf-tools-next/tools/perf'
> ⬢[acme@toolbox perf-tools-next]$ git diff
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 32239c4b0393c319..afa93eff495811cf 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -281,7 +281,7 @@ $(OUTPUT)util/bpf-filter-bison.c $(OUTPUT)util/bpf-filter-bison.h: util/bpf-filt
>
> FLEX_GE_264 := $(shell expr $(shell $(FLEX) --version | sed -e 's/flex \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 264)
> ifeq ($(FLEX_GE_264),1)
> - flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function
> + flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function -Wno-misleading-indentation
> else
> flex_flags := -w
> endif
> ⬢[acme@toolbox perf-tools-next]$
>
>
> > 1 error generated.
> > make[4]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:97: util/parse-events-flex.o] Error 1
> > make[4]: *** Waiting for unfinished jobs....
> > LD util/scripting-engines/perf-in.o
> > make[3]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:140: util] Error 2
> > make[2]: *** [Makefile.perf:682: perf-in.o] Error 2
> > make[2]: *** Waiting for unfinished jobs....
> > CC pmu-events/pmu-events.o
> > LD pmu-events/pmu-events-in.o
> > make[1]: *** [Makefile.perf:242: sub-make] Error 2
> > make: *** [Makefile:70: all] Error 2
> >
> > ⬢[acme@toolbox perf-tools-next]$ clang --version
> > clang version 14.0.5 (Fedora 14.0.5-2.fc36)
> > Target: x86_64-redhat-linux-gnu
> > Thread model: posix
> > InstalledDir: /usr/bin
> > ⬢[acme@toolbox perf-tools-next]$
Thanks James/Arnaldo, I was trying to be aggressive in having more
flags, but it seems too aggressive. We should probably bring back the
logic to make this flag only added if it is supported:
CC_HASNT_MISLEADING_INDENTATION := $(shell echo "int main(void) {
return 0 }" | $(CC) -Werror -Wno-misleading-indentation -o /dev/null
-xc - 2>&1 | grep -q -- -Wno-misleading-indentation ; echo $$?)
ifeq ($(CC_HASNT_MISLEADING_INDENTATION), 1)
flex_flags += -Wno-misleading-indentation
endif
Arnaldo, is the misleading indentation in the bison generated code or
something copy-pasted from the parse-events.l ? If the latter we may
be able to fix the .l file to keep the warning.
Thanks,
Ian
> --
>
> - Arnaldo
Em Fri, Jul 28, 2023 at 08:26:54AM -0700, Ian Rogers escreveu:
> On Fri, Jul 28, 2023 at 7:02 AM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > Em Fri, Jul 28, 2023 at 10:59:38AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Fri, Jul 28, 2023 at 09:50:59AM +0100, James Clark escreveu:
> > > >
> > > >
> > > > On 28/07/2023 07:49, Ian Rogers wrote:
> > > > > If flex is version 2.6.4, reduce the number of flex C warnings
> > > > > disabled. Earlier flex versions have all C warnings disabled.
> > > >
> > > > Hi Ian,
> > > >
> > > > I get a build error with either this one or the bison warning change:
> > > >
> > > > $ make LLVM=1 -C tools/perf NO_BPF_SKEL=1 DEBUG=1
> > > >
> > > > util/pmu-bison.c:855:9: error: variable 'perf_pmu_nerrs' set but not
> > > > used [-Werror,-Wunused-but-set-variable]
> > > > int yynerrs = 0;
> > > >
> > > > I tried a clean build which normally fixes these kind of bison errors.
> > > > Let me know if you need any version info.
> > >
> > > Trying to build it with the command line above I get:
> > >
> > > CC util/expr.o
> > > CC util/parse-events.o
> > > CC util/parse-events-flex.o
> > > util/parse-events-flex.c:7503:13: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
> > > if ( ! yyg->yy_state_buf )
> > > ^
> > > util/parse-events-flex.c:7501:9: note: previous statement is here
> > > if ( ! yyg->yy_state_buf )
> > > ^
> >
> > I added this to the patch to get it moving:
> >
> > make: Leaving directory '/var/home/acme/git/perf-tools-next/tools/perf'
> > ⬢[acme@toolbox perf-tools-next]$ git diff
> > diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> > index 32239c4b0393c319..afa93eff495811cf 100644
> > --- a/tools/perf/util/Build
> > +++ b/tools/perf/util/Build
> > @@ -281,7 +281,7 @@ $(OUTPUT)util/bpf-filter-bison.c $(OUTPUT)util/bpf-filter-bison.h: util/bpf-filt
> >
> > FLEX_GE_264 := $(shell expr $(shell $(FLEX) --version | sed -e 's/flex \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 264)
> > ifeq ($(FLEX_GE_264),1)
> > - flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function
> > + flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function -Wno-misleading-indentation
> > else
> > flex_flags := -w
> > endif
> > ⬢[acme@toolbox perf-tools-next]$
> >
> >
> > > 1 error generated.
> > > make[4]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:97: util/parse-events-flex.o] Error 1
> > > make[4]: *** Waiting for unfinished jobs....
> > > LD util/scripting-engines/perf-in.o
> > > make[3]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:140: util] Error 2
> > > make[2]: *** [Makefile.perf:682: perf-in.o] Error 2
> > > make[2]: *** Waiting for unfinished jobs....
> > > CC pmu-events/pmu-events.o
> > > LD pmu-events/pmu-events-in.o
> > > make[1]: *** [Makefile.perf:242: sub-make] Error 2
> > > make: *** [Makefile:70: all] Error 2
> > >
> > > ⬢[acme@toolbox perf-tools-next]$ clang --version
> > > clang version 14.0.5 (Fedora 14.0.5-2.fc36)
> > > Target: x86_64-redhat-linux-gnu
> > > Thread model: posix
> > > InstalledDir: /usr/bin
> > > ⬢[acme@toolbox perf-tools-next]$
>
> Thanks James/Arnaldo, I was trying to be aggressive in having more
> flags, but it seems too aggressive. We should probably bring back the
> logic to make this flag only added if it is supported:
> CC_HASNT_MISLEADING_INDENTATION := $(shell echo "int main(void) {
> return 0 }" | $(CC) -Werror -Wno-misleading-indentation -o /dev/null
> -xc - 2>&1 | grep -q -- -Wno-misleading-indentation ; echo $$?)
> ifeq ($(CC_HASNT_MISLEADING_INDENTATION), 1)
> flex_flags += -Wno-misleading-indentation
> endif
> Arnaldo, is the misleading indentation in the bison generated code or
> something copy-pasted from the parse-events.l ? If the latter we may
> be able to fix the .l file to keep the warning.
I haven't checked, lemme do it now.
- Arnaldo
Em Fri, Jul 28, 2023 at 03:10:05PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Jul 28, 2023 at 08:26:54AM -0700, Ian Rogers escreveu:
> > On Fri, Jul 28, 2023 at 7:02 AM Arnaldo Carvalho de Melo
> > > I added this to the patch to get it moving:
> > >
> > > make: Leaving directory '/var/home/acme/git/perf-tools-next/tools/perf'
> > > ⬢[acme@toolbox perf-tools-next]$ git diff
> > > diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> > > index 32239c4b0393c319..afa93eff495811cf 100644
> > > --- a/tools/perf/util/Build
> > > +++ b/tools/perf/util/Build
> > > @@ -281,7 +281,7 @@ $(OUTPUT)util/bpf-filter-bison.c $(OUTPUT)util/bpf-filter-bison.h: util/bpf-filt
> > >
> > > FLEX_GE_264 := $(shell expr $(shell $(FLEX) --version | sed -e 's/flex \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 264)
> > > ifeq ($(FLEX_GE_264),1)
> > > - flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function
> > > + flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function -Wno-misleading-indentation
> > > else
> > > flex_flags := -w
> > > endif
> > > ⬢[acme@toolbox perf-tools-next]$
> > >
> > >
> > > > 1 error generated.
> > > > make[4]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:97: util/parse-events-flex.o] Error 1
> > > > make[4]: *** Waiting for unfinished jobs....
> > > > LD util/scripting-engines/perf-in.o
> > > > make[3]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:140: util] Error 2
> > > > make[2]: *** [Makefile.perf:682: perf-in.o] Error 2
> > > > make[2]: *** Waiting for unfinished jobs....
> > > > CC pmu-events/pmu-events.o
> > > > LD pmu-events/pmu-events-in.o
> > > > make[1]: *** [Makefile.perf:242: sub-make] Error 2
> > > > make: *** [Makefile:70: all] Error 2
> > > >
> > > > ⬢[acme@toolbox perf-tools-next]$ clang --version
> > > > clang version 14.0.5 (Fedora 14.0.5-2.fc36)
> > > > Target: x86_64-redhat-linux-gnu
> > > > Thread model: posix
> > > > InstalledDir: /usr/bin
> > > > ⬢[acme@toolbox perf-tools-next]$
> >
> > Thanks James/Arnaldo, I was trying to be aggressive in having more
> > flags, but it seems too aggressive. We should probably bring back the
> > logic to make this flag only added if it is supported:
> > CC_HASNT_MISLEADING_INDENTATION := $(shell echo "int main(void) {
> > return 0 }" | $(CC) -Werror -Wno-misleading-indentation -o /dev/null
> > -xc - 2>&1 | grep -q -- -Wno-misleading-indentation ; echo $$?)
> > ifeq ($(CC_HASNT_MISLEADING_INDENTATION), 1)
> > flex_flags += -Wno-misleading-indentation
> > endif
> > Arnaldo, is the misleading indentation in the bison generated code or
> > something copy-pasted from the parse-events.l ? If the latter we may
> > be able to fix the .l file to keep the warning.
>
> I haven't checked, lemme do it now.
It comes directly from flex's m4 files:
https://github.com/westes/flex/blob/master/src/c99-flex.skl#L2044
So I'll keep the -Wno-misleading-indentation, ok?
- Arnaldo
© 2016 - 2026 Red Hat, Inc.