bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: Andrii Nakryiko <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@fb.com>, Kernel Team <kernel-team@fb.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@gmail.com>
Subject: Re: [PATCH bpf] libbpf: fix missing __WORDSIZE definition
Date: Fri, 19 Jul 2019 14:48:54 -0700	[thread overview]
Message-ID: <CAEf4BzYQSmXyA0r79QfXJPLGg2vpmkhV03SncRndBEWzko6bKA@mail.gmail.com> (raw)
In-Reply-To: <20190719202703.GR3624@kernel.org>

On Fri, Jul 19, 2019 at 1:27 PM Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.com> wrote:
>
> Em Fri, Jul 19, 2019 at 01:04:32PM -0700, Andrii Nakryiko escreveu:
> > On Fri, Jul 19, 2019 at 11:34 AM Arnaldo Carvalho de Melo
> > <arnaldo.melo@gmail.com> wrote:
> > >
> > > Em Fri, Jul 19, 2019 at 11:26:50AM -0700, Andrii Nakryiko escreveu:
> > > > On Fri, Jul 19, 2019 at 11:14 AM Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> wrote:
> > > > > Em Fri, Jul 19, 2019 at 10:54:44AM -0700, Andrii Nakryiko escreveu:
> > > > > > Ok, did some more googling. This warning (turned error in your setup)
> > > > > > is emitted when -Wshadow option is enabled for GCC/clang. It appears
> > > > > > to be disabled by default, so it must be enabled somewhere for perf
> > > > > > build or something.
> > >
> > > > > Right, I came to the exact same conclusion, doing tests here:
> > >
> > > > > [perfbuilder@3a58896a648d tmp]$ gcc -Wshadow shadow_global_decl.c   -o shadow_global_decl
> > > > > shadow_global_decl.c: In function 'main':
> > > > > shadow_global_decl.c:9: warning: declaration of 'link' shadows a global declaration
> > > > > shadow_global_decl.c:4: warning: shadowed declaration is here
> > > > > [perfbuilder@3a58896a648d tmp]$ gcc --version |& head -1
> > > > > gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
> > > > > [perfbuilder@3a58896a648d tmp]$ gcc shadow_global_decl.c   -o shadow_global_decl
> > > > > [perfbuilder@3a58896a648d tmp]$
> > >
> > > > > So I'm going to remove this warning from the places where it causes
> > > > > problems.
> > >
> > > > > > Would it be possible to disable it at least for libbpf when building
> > > > > > from perf either everywhere or for those systems where you see this
> > > > > > warning? I don't think this warning is useful, to be honest, just
> > > > > > random name conflict between any local and global variables will cause
> > > > > > this.
> > >
> > > > > Yeah, I might end up having this applied.
> > >
> > > > Thanks!
> > >
> > > So, I'm ending up with the patch below, there is some value after all in
> > > Wshadow, that is, from gcc 4.8 onwards :-)
> >
> > I agree with the intent, but see below.
> >
> > >
> > > - Arnaldo
> > >
> > > diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
> > > index 495066bafbe3..ded7a950dc40 100644
> > > --- a/tools/scripts/Makefile.include
> > > +++ b/tools/scripts/Makefile.include
> > > @@ -32,7 +32,6 @@ EXTRA_WARNINGS += -Wno-system-headers
> > >  EXTRA_WARNINGS += -Wold-style-definition
> > >  EXTRA_WARNINGS += -Wpacked
> > >  EXTRA_WARNINGS += -Wredundant-decls
> > > -EXTRA_WARNINGS += -Wshadow
> > >  EXTRA_WARNINGS += -Wstrict-prototypes
> > >  EXTRA_WARNINGS += -Wswitch-default
> > >  EXTRA_WARNINGS += -Wswitch-enum
> > > @@ -69,8 +68,16 @@ endif
> > >  # will do for now and keep the above -Wstrict-aliasing=3 in place
> > >  # in newer systems.
> > >  # Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h
> > > +#
> > > +# See https://lkml.org/lkml/2006/11/28/253 and https://gcc.gnu.org/gcc-4.8/changes.html,
> > > +# that takes into account Linus's comments (search for Wshadow) for the reasoning about
> > > +# -Wshadow not being interesting before gcc 4.8.
> > > +
> > >  ifneq ($(filter 3.%,$(MAKE_VERSION)),)  # make-3
> >
> > This is checking make version, not GCC version. So code comment and
> > configurations are not in sync?
>
> Ah, I should have added a few lines back:
>
> # Hack to avoid type-punned warnings on old systems such as RHEL5:
> # We should be changing CFLAGS and checking gcc version, but this
> # will do for now and keep the above -Wstrict-aliasing=3 in place
> # in newer systems.
> # Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h
> #
> # See https://lkml.org/lkml/2006/11/28/253 and https://gcc.gnu.org/gcc-4.8/changes.html,
> # that takes into account Linus's comments (search for Wshadow) for the reasoning about
> # -Wshadow not being interesting before gcc 4.8.
>
>
> In time I'll try and get it to use the gcc version to be strict.

Oh well, if it's how it's done right now :)

Acked-by: Andrii Nakryiko <andriin@fb.com>

>
> - Arnaldo

      reply	other threads:[~2019-07-19 21:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18 17:25 [PATCH bpf] libbpf: fix missing __WORDSIZE definition Andrii Nakryiko
2019-07-18 17:26 ` Andrii Nakryiko
2019-07-18 17:55 ` Arnaldo Carvalho de Melo
2019-07-18 18:04   ` Andrii Nakryiko
2019-07-18 18:56     ` Arnaldo Carvalho de Melo
2019-07-18 19:14       ` Arnaldo Carvalho de Melo
2019-07-18 21:16         ` Andrii Nakryiko
2019-07-19  1:16           ` Arnaldo Carvalho de Melo
2019-07-19 17:54             ` Andrii Nakryiko
2019-07-19 18:14               ` Arnaldo Carvalho de Melo
2019-07-19 18:26                 ` Andrii Nakryiko
2019-07-19 18:34                   ` Arnaldo Carvalho de Melo
2019-07-19 20:04                     ` Andrii Nakryiko
2019-07-19 20:27                       ` Arnaldo Carvalho de Melo
2019-07-19 21:48                         ` Andrii Nakryiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEf4BzYQSmXyA0r79QfXJPLGg2vpmkhV03SncRndBEWzko6bKA@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jolsa@redhat.com \
    --cc=kernel-team@fb.com \
    --cc=namhyung@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).