DPDK patches and discussions
 help / color / mirror / Atom feed
From: Amit Prakash Shukla <amitprakashs@marvell.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	Jerin Jacob Kollanukkaran <jerinj@marvell.com>,
	"thomas@monjalon.net" <thomas@monjalon.net>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>,
	"dmitry.kozliuk@gmail.com" <dmitry.kozliuk@gmail.com>,
	"navasile@linux.microsoft.com" <navasile@linux.microsoft.com>,
	"dmitrym@microsoft.com" <dmitrym@microsoft.com>
Subject: RE: [EXT] Re: [PATCH] build: enable static analyzer
Date: Fri, 15 Jul 2022 12:05:41 +0000	[thread overview]
Message-ID: <PH0PR18MB5167DCED917BC3CAD968ECE8C88B9@PH0PR18MB5167.namprd18.prod.outlook.com> (raw)
In-Reply-To: <Ys/3eNh5jW6OYtR4@bricha3-MOBL.ger.corp.intel.com>

Thanks Bruce for the review. Please find my comments in-line.

> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Thursday, July 14, 2022 4:31 PM
> To: Amit Prakash Shukla <amitprakashs@marvell.com>
> Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> thomas@monjalon.net; david.marchand@redhat.com;
> dmitry.kozliuk@gmail.com; navasile@linux.microsoft.com;
> dmitrym@microsoft.com
> Subject: [EXT] Re: [PATCH] build: enable static analyzer
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Thu, Jul 14, 2022 at 12:57:22PM +0530, Amit Prakash Shukla wrote:
> > This patch adds support to enable compiler static analyzer for gcc and
> > clang.
> >
> > Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
> > ---
> >  config/meson.build                        | 14 ++++++++++++++
> >  doc/guides/prog_guide/index.rst           |  1 +
> >  doc/guides/prog_guide/static_analyzer.rst | 21
> +++++++++++++++++++++
> >  meson_options.txt                         |  2 ++
> >  4 files changed, 38 insertions(+)
> >  create mode 100644 doc/guides/prog_guide/static_analyzer.rst
> >
> > diff --git a/config/meson.build b/config/meson.build index
> > 7f7b6c92fd..1154396326 100644
> > --- a/config/meson.build
> > +++ b/config/meson.build
> > @@ -440,6 +440,20 @@ if get_option('b_sanitize') == 'address' or
> get_option('b_sanitize') == 'address
> >      endif
> >  endif
> >
> > +if get_option('static_analyzer')
> > +    if cc.get_id() == 'gcc' and cc.version().version_compare('>=10.1.0')
> > +        add_project_arguments('-fanalyzer', language: 'c')
> 
> Rather than checking for specific compiler versions, we should instead just
> check for particular flags and use those.

Sure, I will make the change as part of v2 patch.

> 
> > +    elif cc.get_id() == 'clang' and cc.version().version_compare('>=9.0.1')
> > +        add_project_arguments('--analyze', language: 'c')
> > +        add_project_arguments('-Xanalyzer', language: 'c')
> > +        add_project_arguments('-analyzer-output=text', language: 'c')
> > +    elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
> > +        error('Static analysis not supported for current gcc/clang version.')
> > +    else
> > +        error('Compiler does not support static analysis')
> > +    endif
> > +endif
> > +
> >  if get_option('default_library') == 'both'
> >      error( '''
> >   Unsupported value "both" for "default_library" option.
> > diff --git a/doc/guides/prog_guide/index.rst
> > b/doc/guides/prog_guide/index.rst index 8564883018..9f6d98904a 100644
> > --- a/doc/guides/prog_guide/index.rst
> > +++ b/doc/guides/prog_guide/index.rst
> > @@ -76,4 +76,5 @@ Programmer's Guide
> >      lto
> >      profile_app
> >      asan
> > +    static_analyzer
> >      glossary
> > diff --git a/doc/guides/prog_guide/static_analyzer.rst
> > b/doc/guides/prog_guide/static_analyzer.rst
> > new file mode 100644
> > index 0000000000..11260eebe7
> > --- /dev/null
> > +++ b/doc/guides/prog_guide/static_analyzer.rst
> > @@ -0,0 +1,21 @@
> > +.. SPDX-License-Identifier: BSD-3-Clause
> > +   Copyright(c) 2022 Marvell
> > +
> > +Running Static Analyzer
> > +========================
> > +Static analyzer is a compiler feature which when enabled scans
> > +through the source code to try and find various problems at compile-time,
> rather than at runtime.
> > +
> > +Static analyzer is a part of clang (9.0.1+) and GCC (10.1.0+).
> > +
> > +`GCC Static analyzer document
> > +<https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__gcc.gnu.org_onl
> > +inedocs_gcc-2D10.1.0_gcc_Static-2DAnalyzer-
> 2DOptions.html&d=DwIBAg&c=
> >
> +nKjWec2b6R0mOyPaz7xtfQ&r=ALGdXl3fZgFGR69VnJLdSnADun7zLaXG1p5R
> s7pXihE&
> > +m=41ZGerooHPN2LY2ibMFNcjUVJscn-
> MehdDhTHMaoqddHVciH516PLZOrDEhur1ra&s=
> > +v1pD8igta4HfoQgJlCAmOwZCo3PJ-b2_NXk0ODPEoms&e= >`_
> > +
> > +`Clang static analyzer document
> > +<https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.o
> >
> +rg_9.0.1_tools_clang_docs_ClangStaticAnalyzer.html&d=DwIBAg&c=nKjWe
> c2
> >
> +b6R0mOyPaz7xtfQ&r=ALGdXl3fZgFGR69VnJLdSnADun7zLaXG1p5Rs7pXihE&
> m=41ZGe
> > +rooHPN2LY2ibMFNcjUVJscn-
> MehdDhTHMaoqddHVciH516PLZOrDEhur1ra&s=J2lNXZy
> > +id-zCxLgclayGzcTbrof1athBH6Rn_MAGPt4&e= >`_
> > +
> > +Enabling 'Static analyzer' is done by passing the
> > +-Dstatic_analyzer=true option to the meson build system. By-default
> static analyzer is disabled.
> > +
> > +Example::
> > +  - meson setup -Dstatic_analyzer=true <build_dir>
> > diff --git a/meson_options.txt b/meson_options.txt index
> > 7c220ad68d..fde9a579a0 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -48,3 +48,5 @@ option('tests', type: 'boolean', value: true, description:
> >         'build unit tests')
> >  option('use_hpet', type: 'boolean', value: false, description:
> >         'use HPET timer in EAL')
> > +option('static_analyzer', type: 'boolean', value: false, description:
> > +       'Compile time static analyses for gcc-10.1.0+ and
> > +clang-9.0.1+')
> > --
> 
> Rather than adding support for this through DPDK project itself, this might be
> better added to meson directly so that other projects can also benefit from
> it. It also would fit in well with other meson options such as the ASAN
> support, coverage support, or PGO support.

Sure, will remove it from dpdk in v2 patch and add it to meson.

> 
> Regards,
> /Bruce

Thanks,
Amit Shukla

  reply	other threads:[~2022-07-15 12:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14  7:27 Amit Prakash Shukla
2022-07-14 11:01 ` Bruce Richardson
2022-07-15 12:05   ` Amit Prakash Shukla [this message]
2023-07-06 22:59     ` [EXT] " Stephen Hemminger

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=PH0PR18MB5167DCED917BC3CAD968ECE8C88B9@PH0PR18MB5167.namprd18.prod.outlook.com \
    --to=amitprakashs@marvell.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=dmitrym@microsoft.com \
    --cc=jerinj@marvell.com \
    --cc=navasile@linux.microsoft.com \
    --cc=thomas@monjalon.net \
    /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).