From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A25E9A0032; Fri, 15 Jul 2022 14:05:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3FEC440A87; Fri, 15 Jul 2022 14:05:47 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id EDB1B40696 for ; Fri, 15 Jul 2022 14:05:45 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26F9d0G7009931; Fri, 15 Jul 2022 05:05:45 -0700 Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h9udu9jfe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Jul 2022 05:05:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zl+A2HowSLjtUI83oAdzARXk7NR5MRB4oITN1z+u0GN5TZze5RTZCsCrnrKHlpjAOAZLdEHpmNHE6oYsQVkOaZJHYj/RasGO0z3+a/cB/a1ZZ+n0xHm+CMKVHkKNNzSl6Z6DfJRurwUEFFsjmfG/tFpWrrimlVwp8hMFhWFGFpTMwXk2sNWfkMBYw/JJcVgbh/geFDgDVUEESBEvQG0+iivh1Fv8upPVJkrn7/rGiOVUNVjF2v5XQOWIKcMvND4DJyADciGCapG/xyIFSg/5WjrBNWMBCtbN3XaP1fjDo5opBHk0aFnN3HIx030Jdqb3XJAYzG7HZJfZVw2PIMVIFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F37O6u2YnnNvQ0WjLEwMEjFChfungv0zRryvRwj02v4=; b=NFb+5pgL/rs8IotfWd3xmu3nx/joi3i9280ZuhAbbyW5Mmsv0Efmc9G94aFsnCJWc35I2ySbnrlhavcletckfCIuQvE0HD6GsDeqWmhycGPC1JHtZAk8zGXOUASeUG7BG9M/cfaSJ10MTuOBGlghz0obhCvJj2UUAEtW6kQGWYm+91P5Mt0vrAyOxekgqg6P2V+GmndVtkHQQUeh7xa8lA8Q5sHY9+BnOrSMbjj8sSY9YyfI3o8F1cuyH4fNHsAtnk1p1pUuySiFlgirX+BGy4duyAw+UxQAfE31xf6Z6WkvGjkYbeCwXKjSTB+Ui3qSAfZ/IsRa5yAuWu99IgFHkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F37O6u2YnnNvQ0WjLEwMEjFChfungv0zRryvRwj02v4=; b=JMIvSDSaj+cqeYOxjmJUFYO7ywRS3ya6mtsMQWtYX9yNSTnSWUgy1m19tntPzv8rcZObM/MkKxuPG95Fqfr8273rmOw52Ukb82LtuHfFFAk1M9axnqSXKHxv/DVWuC2kk1kKJXkCLis8YZ89zGrsyzfVk6Gk75xnTl06QfT0h/I= Received: from PH0PR18MB5167.namprd18.prod.outlook.com (2603:10b6:510:168::7) by CO3PR18MB4944.namprd18.prod.outlook.com (2603:10b6:303:170::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Fri, 15 Jul 2022 12:05:41 +0000 Received: from PH0PR18MB5167.namprd18.prod.outlook.com ([fe80::55b1:e473:794e:91bb]) by PH0PR18MB5167.namprd18.prod.outlook.com ([fe80::55b1:e473:794e:91bb%6]) with mapi id 15.20.5438.015; Fri, 15 Jul 2022 12:05:41 +0000 From: Amit Prakash Shukla To: Bruce Richardson CC: "dev@dpdk.org" , Jerin Jacob Kollanukkaran , "thomas@monjalon.net" , "david.marchand@redhat.com" , "dmitry.kozliuk@gmail.com" , "navasile@linux.microsoft.com" , "dmitrym@microsoft.com" Subject: RE: [EXT] Re: [PATCH] build: enable static analyzer Thread-Topic: [EXT] Re: [PATCH] build: enable static analyzer Thread-Index: AQHYl1M7NiavN6TbUEy53mK1hYJQeK19s2gAgAGikQA= Date: Fri, 15 Jul 2022 12:05:41 +0000 Message-ID: References: <20220714072722.879156-1-amitprakashs@marvell.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 272cef00-aea1-467f-15fe-08da665a5696 x-ms-traffictypediagnostic: CO3PR18MB4944:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: yz+iZmrYvBQS1hrRabDTmNjBfoLFsJV1xmhj9JgiblQwT1Nr7+tOpXx1HEu3pJ/iZ8p0VK+qj8yo+tE7tnek0zS/bhD0wN6NJg0rYnT9lwQpie5TrhTGWUORZZogHYxFSDnQL72ifDvlOtOPTNxdrc+Uw8GkAcM4MCXq7dR+oeO8gnZsUsU6tIrsx5b29nhCQfw5BRAyPymu43BEse+FoMgrvXGLb8nKGBMymNrG6MB4SnVyPbV57t34Q38C5eG51/oLA6m+Sdv2a4RDiz0Qk8w8nX2aNx+dZI/QT2X/yRJg7iwg0JGKIhi0YhLvEFM5yIOm2giDiXdTLQQy/FfjZsS7wBDgLb22vHTs1PC+2gYaAWC+syvCzHx2SYBEppWI/gOxrAk1sAMvsmjHbvNKj+xL/MqFW3lBDCL4vXhOmaC2fEAEoyAnpr+9wLAxxpt29O3p0LhzR9/hjAQ26G1VxVGy8B57w8GGFVRFgdVlyu19Td2FSJcSI4lKRsLnRrLXA1LPJib9wTYFIJ4G6WqNtdQOv/jY6+bhwff9zCtCbsBrQUP+WiVAary0L6ckpmnezvjUuBwXmFmffl044sqRZLpvPIveu9cDA1wVIpdWOz3m759iomDuIzsdH9Bx9VPrZrRT4WHgJ/EcbjcIg6DDIhjePz9J7O7S+beBD2huBRTWWRToBg/r6ubBQ68zRtmTM76dEH5yh3hAfvJ7UfxWWM77Eab7nxg69b5vssWSbiUG3oqValLCC+/Wr1Q6rXGJJsunBdsUPCfHat1uvVVMq6FE6evqdXxaEUXkf6SyHXZspNxXkttRBF19SHG10jw9VWSJHaeU7B8ghfmNGB+0JBa4/Ah9MSyZZQCTWG3eHTN2HsXJ+13uVv84lHB+0vZN x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR18MB5167.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(376002)(136003)(39860400002)(366004)(396003)(41300700001)(478600001)(26005)(9686003)(86362001)(38070700005)(53546011)(186003)(7696005)(122000001)(6506007)(83380400001)(38100700002)(52536014)(33656002)(55016003)(8936002)(5660300002)(2906002)(76116006)(19627235002)(6916009)(8676002)(54906003)(316002)(71200400001)(66446008)(66476007)(4326008)(64756008)(66556008)(45080400002)(66946007); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?prgAX35lHhTTJnQKsMbwmB9PRaqLktt3/g/LscjStSO4pi0K11D+v146SeKT?= =?us-ascii?Q?FqNFHmex0s8r+qNXeyCdOtNsrc2w2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0YYm+t7jrHhHz+e1KsIWChwI1CVbZt/n1f+u0jBJ3oRggMDkPw1425Kg?= =?us-ascii?Q?0QrE6fcl2rX1KB0DoIbfn6+iSu8MygdhlMfvuLsuxXC2N+gWkNSlZnUPt7Cn?= =?us-ascii?Q?nx/jansEgLkvEql5qH6i4NpHVffUJjOH099xBS53FGE4vJHIFoG/pWRls1hj?= =?us-ascii?Q?54kyI0J5hQ5NmN+sqg83fhJxttfqTuAqJiWjBzMtECm+52JdAi94faiQ+8GA?= =?us-ascii?Q?j/fE0Y3xihggtrrtvFoGLKZgxWIeZhSYT359J8p6H9qTh0IKKps35PdECxI/?= =?us-ascii?Q?ThnwmCLhBSv1jHxhOZvMTLM4w5KMmeF7ZWImpN93vnwfhD2o4B9M9fD8z6uG?= =?us-ascii?Q?xskILoO5VmM7/B3ZGdwrAeUGrvPT4bxiTlu4iOuUBrdV8WfJV/mLSjdckN4L?= =?us-ascii?Q?NbM0XWQ6STGz4Mw7fsFJw+gvBZUKlt3va4Lxm9Z0ompNsirSisiAbD5j8LKY?= =?us-ascii?Q?13ZIO9w35mR//syMSq7gcZFbql1rp17Hf62VXoRq61ptI+NYdmToGo8LehOy?= =?us-ascii?Q?DWOEoUzFBvGStoqU6hJfxVZkq+3PaMgjP0HRB2N0mBXq1d6KDV9cKaP4p37E?= =?us-ascii?Q?wy7PWiTwdMl/ij/PmJ6doQGZKx3HDi8HyVTIxp4E?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR18MB5167.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 272cef00-aea1-467f-15fe-08da665a5696 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jul 2022 12:05:41.1644 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 6MOs9+v3xjRe7CXwpEqaKwzKPAyUN3XRTw799Z1grhWBDVaEE5+QInGnGFIclWlUy9auCU33+VxGtqJmvfMPw1hhpmzEXsOvWfPqlu/6ZpY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO3PR18MB4944 X-Proofpoint-GUID: 27p4a2Nn6bDq0tTuBDY58N587YpbpQRP X-Proofpoint-ORIG-GUID: 27p4a2Nn6bDq0tTuBDY58N587YpbpQRP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-15_04,2022-07-15_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Thanks Bruce for the review. Please find my comments in-line. > -----Original Message----- > From: Bruce Richardson > Sent: Thursday, July 14, 2022 4:31 PM > To: Amit Prakash Shukla > Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran ; > 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 >=20 > External Email >=20 > ---------------------------------------------------------------------- > 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 > > --- > > 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') =3D=3D 'address' or > get_option('b_sanitize') =3D=3D 'address > > endif > > endif > > > > +if get_option('static_analyzer') > > + if cc.get_id() =3D=3D 'gcc' and cc.version().version_compare('>=3D= 10.1.0') > > + add_project_arguments('-fanalyzer', language: 'c') >=20 > Rather than checking for specific compiler versions, we should instead ju= st > check for particular flags and use those. Sure, I will make the change as part of v2 patch. >=20 > > + elif cc.get_id() =3D=3D 'clang' and cc.version().version_compare('= >=3D9.0.1') > > + add_project_arguments('--analyze', language: 'c') > > + add_project_arguments('-Xanalyzer', language: 'c') > > + add_project_arguments('-analyzer-output=3Dtext', language: 'c'= ) > > + elif cc.get_id() =3D=3D 'gcc' or cc.get_id() =3D=3D 'clang' > > + error('Static analysis not supported for current gcc/clang ver= sion.') > > + else > > + error('Compiler does not support static analysis') > > + endif > > +endif > > + > > if get_option('default_library') =3D=3D '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 > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D > > +Static analyzer is a compiler feature which when enabled scans > > +through the source code to try and find various problems at compile-ti= me, > rather than at runtime. > > + > > +Static analyzer is a part of clang (9.0.1+) and GCC (10.1.0+). > > + > > +`GCC Static analyzer document > > + 3A__gcc.gnu.org_onl > > +inedocs_gcc-2D10.1.0_gcc_Static-2DAnalyzer- > 2DOptions.html&d=3DDwIBAg&c=3D > > > +nKjWec2b6R0mOyPaz7xtfQ&r=3DALGdXl3fZgFGR69VnJLdSnADun7zLaXG1p5R > s7pXihE& > > +m=3D41ZGerooHPN2LY2ibMFNcjUVJscn- > MehdDhTHMaoqddHVciH516PLZOrDEhur1ra&s=3D > > +v1pD8igta4HfoQgJlCAmOwZCo3PJ-b2_NXk0ODPEoms&e=3D >`_ > > + > > +`Clang static analyzer document > > + > > +rg_9.0.1_tools_clang_docs_ClangStaticAnalyzer.html&d=3DDwIBAg&c=3DnKjWe > c2 > > > +b6R0mOyPaz7xtfQ&r=3DALGdXl3fZgFGR69VnJLdSnADun7zLaXG1p5Rs7pXihE& > m=3D41ZGe > > +rooHPN2LY2ibMFNcjUVJscn- > MehdDhTHMaoqddHVciH516PLZOrDEhur1ra&s=3DJ2lNXZy > > +id-zCxLgclayGzcTbrof1athBH6Rn_MAGPt4&e=3D >`_ > > + > > +Enabling 'Static analyzer' is done by passing the > > +-Dstatic_analyzer=3Dtrue option to the meson build system. By-default > static analyzer is disabled. > > + > > +Example:: > > + - meson setup -Dstatic_analyzer=3Dtrue > > 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, descrip= tion: > > '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+') > > -- >=20 > Rather than adding support for this through DPDK project itself, this mig= ht be > better added to meson directly so that other projects can also benefit fr= om > 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. >=20 > Regards, > /Bruce Thanks, Amit Shukla