From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1C5C3A00B8; Mon, 28 Oct 2019 11:50:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D3EC51BEE6; Mon, 28 Oct 2019 11:50:57 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 88C991BEE4 for ; Mon, 28 Oct 2019 11:50:55 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9SAoDfP018750; Mon, 28 Oct 2019 03:50:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=oTI8VNvdglmyAeX95VjJVnkh14Rd2Kr8guxQSvOSN5I=; b=VYCZAoZUc6rOak689H2wTAXhhW5HzmjRJaoVrjmRNUkeFQVsn432vVvLK4Z1vJOL3m89 4Y/XavzgPW8qahYN9IFbbXJixeTYECBNKX3eIWX8ocNNg9V11l1axmF0FIjGZhNKB2h+ nyRRHteLWQYceCgIp46WOaWCOE7qhl+o/fqH92WBGLjEoAQ7DSwDMJUVUUUNeQTq0w4x 8Mo6iiadCsgZCI33txZuauyHwcyFjnwI5oPoYUHBc1AvmZWHs4ujPBmh++8UWHbWO5/l F18IQ6w1bze94Jrj8aV35XD88+WhPgw8vgWAl7wCTxuQVKhvcMY4TVGOHyMG8kvUCCeB nA== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2vvkgq5k7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2019 03:50:54 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 28 Oct 2019 03:50:53 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (104.47.42.50) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 28 Oct 2019 03:50:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZNquo57+nf8/LTsZQn8WJMw6qjvaBAun6PcK9B7qNDZQGFKDWwRcHjf+CP3Z/mb10qCQCReTrAFhZMn5m2ewFLh2ml6r+gLLyFzusfyCm6oSjCgaNDXO3NKgUXnZpWl9JnpHXXKojhfwqG0aR95cTgCjDY4y2BC4452uml2P+OuINnx62GGaLH4wsjhoZNvcYIHQc+W6TWnANveafKrbIuF4WCAeyZyy6LsqjIsTLCL8x3153AguAukLv9WqvIPbe1EHHbvIeexI47ajeGKJngNLzYJI+pe+OMu8RMEFuuVKBWlox7nn7rBQfZn6sbJ3X8HRBhgUQtdfsvoMEmU6Ig== 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-SenderADCheck; bh=oTI8VNvdglmyAeX95VjJVnkh14Rd2Kr8guxQSvOSN5I=; b=Q9J8nklBuyPaJlsRW/lLbgCI0Lv5UnTqG5bOnpd6HnH+hoYJi/jnzRwtiXKqWoNyBgK4fRISj4O9DGo0FrYvZ4ttRjHDrsYLbVHz0BHTYtK2QoxnDqJw7kR4p5z0L+adkC8/iXPPI9Iy7NJImPKdLxLFIlK3uADTPstZk8hshtKSLLPTXmwuqvFpFifqBS5sB5WWJEE7OrvvSxiUT0N3cBePvJsfYFjdYg62E4qJaEmWkifbxk2BRjSenHsD9ssioEna9u9Z8M/HSOfvGlP0IuocXr8EgKDZGrtHUhDOaS1YPN6w6tDpfs2JOTzqDjearTRx71/Pi1kZQ/T8DbVgOw== 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=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oTI8VNvdglmyAeX95VjJVnkh14Rd2Kr8guxQSvOSN5I=; b=kI8j8W41ROSVU32QevKykTtxJ5444inno7bVmK4zWO30RbnfEXqODDclTfJdbx01Uax3/rJzVD5oLNTZk+jyh8kkFCj6x0I+bo4lJVHtVGoojKW7IcY8VTWaL6GPj4GoLS1phLJXWa342avHQ3Wvq9D7Tb3/y0ncvZAne5EMMC4= Received: from MN2PR18MB2848.namprd18.prod.outlook.com (20.179.21.149) by MN2PR18MB2525.namprd18.prod.outlook.com (20.179.82.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20; Mon, 28 Oct 2019 10:50:52 +0000 Received: from MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::cc97:455d:adca:ef1e]) by MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::cc97:455d:adca:ef1e%4]) with mapi id 15.20.2387.021; Mon, 28 Oct 2019 10:50:51 +0000 From: Harman Kalra To: Thomas Monjalon , John McNamara , Marko Kovacevic , "Bruce Richardson" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] mk: add support for UBSAN Thread-Index: AQHVVpTDs7FnaDuo7UCImNLU+qa6/acp/xsAgCkKtQCAHUQVAA== Date: Mon, 28 Oct 2019 10:50:51 +0000 Message-ID: <20191028105035.GA112066@outlook.office365.com> References: <1566222457-17342-1-git-send-email-hkalra@marvell.com> <20190913114026.GA172657@outlook.office365.com> <20191009142524.GA8087@outlook.office365.com> In-Reply-To: <20191009142524.GA8087@outlook.office365.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BMXPR01CA0029.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::15) To MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:3e::21) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 38990c27-62c6-4bb8-2a8a-08d75b94b313 x-ms-traffictypediagnostic: MN2PR18MB2525: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 0204F0BDE2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39850400004)(376002)(136003)(396003)(366004)(346002)(189003)(199004)(6436002)(1076003)(229853002)(256004)(6486002)(66066001)(81166006)(30864003)(186003)(14444005)(478600001)(486006)(102836004)(81156014)(11346002)(8676002)(446003)(476003)(25786009)(26005)(14454004)(5660300002)(316002)(71200400001)(86362001)(8936002)(3846002)(6506007)(6116002)(33656002)(2906002)(6246003)(71190400001)(64756008)(66556008)(66446008)(66946007)(66476007)(110136005)(55236004)(76176011)(52116002)(386003)(4326008)(7736002)(305945005)(9686003)(6512007)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2525; H:MN2PR18MB2848.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YT6DZjMBJxBysGzxGH2sMhyJoYM5N/Caht2Qi9uu/IYXXL81R40/C4Owrzxs3TJuqVR1RleaWQJKIULZB/FBYSQbElEYwb+RGV8/xxHOmZMp62JESCRspmazkBUbvTH4DCZ42/tBEhik7QdrCdrrmM5QRGzfZrO0g96SxHoUZR6GD8WvotbOs3fRyOWKKkhGV+b/W/APEBNN3hXOTbX5gYo0mkbvzsiW/6A/zbCvGYbLqLXaCSxMO4Imn9iADGhPZ/KeSbGHYwUgJ6oLEPUfBZrgfTetjYn5PFJMU1JyFgvfSHMmC3q9tnFTchDEMyJL6T3mSps2MKj7bvU46ppKxUndymdPrsAcdb2Gd0jhXsQyUt9Otlt4se5J9R4/WGuPoMEj4sSgmUYKW77RGwd9u4AlQAI1TMO8j74dlYWNwf/aSEYunL0gIZmG9RitrQNg x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-ID: <74DA4E488F71464C867F9C2BAE9BA845@namprd18.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 38990c27-62c6-4bb8-2a8a-08d75b94b313 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Oct 2019 10:50:51.7977 (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: xTEZ0y1mMCabrUKxFMOc00VXPAdOG3lRvJmNYhIORB9hRuEEy628E48TSkqFFkSRPggtWU3rJQ1S9/MwrBEw6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2525 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-28_05:2019-10-25,2019-10-28 signatures=0 Subject: Re: [dpdk-dev] [PATCH] mk: add support for UBSAN X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Ping... Kindly review this patch. On Wed, Oct 09, 2019 at 02:25:52PM +0000, Harman Kalra wrote: > Ping.. >=20 > On Fri, Sep 13, 2019 at 11:40:40AM +0000, Harman Kalra wrote: > > Ping.. > > Kindly review this patch. > >=20 > > On Mon, Aug 19, 2019 at 07:18:21PM +0530, Harman Kalra wrote: > > > UndefinedBehaviorSanitizer (UBSan) is a fast undefined behavior > > > detector. UBSan modifies the program at compile-time to catch > > > various kinds of undefined behavior during program execution. > > >=20 > > > This patch implements support for UBSan to the DPDK. > > >=20 > > > See: doc/guides/prog_guide/ubsan.rst for more information. > > >=20 > > > Signed-off-by: Harman Kalra > > > --- > > > config/common_base | 6 ++ > > > config/meson.build | 15 ++++ > > > doc/guides/prog_guide/index.rst | 1 + > > > doc/guides/prog_guide/ubsan.rst | 112 +++++++++++++++++++++++= ++ > > > doc/guides/rel_notes/release_19_11.rst | 7 ++ > > > meson_options.txt | 2 + > > > mk/rte.app.mk | 10 +++ > > > mk/rte.lib.mk | 12 +++ > > > mk/toolchain/clang/rte.vars.mk | 4 + > > > mk/toolchain/gcc/rte.vars.mk | 8 ++ > > > 10 files changed, 177 insertions(+) > > > create mode 100644 doc/guides/prog_guide/ubsan.rst > > >=20 > > > diff --git a/config/common_base b/config/common_base > > > index 8ef75c203..b47a6f28e 100644 > > > --- a/config/common_base > > > +++ b/config/common_base > > > @@ -1067,3 +1067,9 @@ CONFIG_RTE_APP_CRYPTO_PERF=3Dy > > > # Compile the eventdev application > > > # > > > CONFIG_RTE_APP_EVENTDEV=3Dy > > > + > > > +# > > > +# Enable undefined behavior sanitizer > > > +# > > > +CONFIG_RTE_UBSAN=3Dn > > > +CONFIG_RTE_UBSAN_SANITIZE_ALL=3Dn > > > diff --git a/config/meson.build b/config/meson.build > > > index 2bafea530..6a2fa117d 100644 > > > --- a/config/meson.build > > > +++ b/config/meson.build > > > @@ -196,3 +196,18 @@ add_project_arguments('-D_GNU_SOURCE', language:= 'c') > > > if is_freebsd > > > add_project_arguments('-D__BSD_VISIBLE', language: 'c') > > > endif > > > + > > > +# enable ubsan > > > +if get_option('enable_ubsan') > > > + if cc.has_argument('-fsanitize=3Dundefined') > > > + ubsan_dep =3D cc.find_library('libubsan', required: false) > > > + if ubsan_dep.found() > > > + add_project_arguments('-fsanitize=3Dundefined', language: 'c') > > > + add_project_link_arguments('-fsanitize=3Dundefined', language: 'c= ') > > > + else > > > + message('libubsan not found, UBSAN cannot be enabled') > > > + endif > > > + else > > > + message('gcc version does not support UBSAN') > > > + endif > > > +endif > > > diff --git a/doc/guides/prog_guide/index.rst b/doc/guides/prog_guide/= index.rst > > > index 692409af8..970901e9a 100644 > > > --- a/doc/guides/prog_guide/index.rst > > > +++ b/doc/guides/prog_guide/index.rst > > > @@ -66,4 +66,5 @@ Programmer's Guide > > > perf_opt_guidelines > > > writing_efficient_code > > > profile_app > > > + ubsan > > > glossary > > > diff --git a/doc/guides/prog_guide/ubsan.rst b/doc/guides/prog_guide/= ubsan.rst > > > new file mode 100644 > > > index 000000000..cb19f3bd9 > > > --- /dev/null > > > +++ b/doc/guides/prog_guide/ubsan.rst > > > @@ -0,0 +1,112 @@ > > > +.. SPDX-License-Identifier: BSD-3-Clause > > > + Copyright(c) 2019 Marvell International Ltd. > > > + > > > +The Undefined Behavior Sanitizer - UBSan > > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > + > > > +UndefinedBehaviorSanitizer (UBSan) is a runtime undefined behavior d= etector. > > > +UBSan uses compile-time instrumentation and modifies the program by = adding > > > +some stubs which perform certain checks before operations that might= cause > > > +undefined behaviour. If some UB detected, respective _UBSan_handle_*= handlers > > > +(which are defined in libUBSan library) are called to prints the err= or message. > > > + > > > +Some examples of undefined behaviour checks: > > > + > > > +* Misaligned memory access > > > +* Signed integer overflow > > > +* Load from/store to an object with insufficient space. > > > +* Integer divide by zero as well as INT_MIN / -1 division > > > +* Out-of-bounds memory accesses. > > > +* Null argument declared with nonnull attribute, returned null from = function > > > + which never returns null, null ptr dereference > > > +* Variable size array with non-positive length > > > + > > > +GCC supports this feature since 4.9, however GCC 5.0 onwards has man= y more > > > +checkers implemented. > > > + > > > +Example UBSan error > > > +-------------------- > > > + > > > +Following error was reported when UBSan was enabled: > > > + > > > +.. code-block:: console > > > + > > > + drivers/net/octeontx2/otx2_stats.c:82:26: runtime error: left sh= ift of > > > + 1 by 31 places cannot be represented in type 'int' > > > + > > > +Code responsible for this error: > > > + > > > +.. code-block:: c > > > + > > > + if (dev->txmap[i] & (1 << 31)) { > > > + > > > +To fix this error: > > > + > > > +.. code-block:: c > > > + > > > + if (dev->txmap[i] & (1U << 31)) { > > > + > > > +Usage > > > +----- > > > + > > > +make build > > > +^^^^^^^^^^ > > > + > > > +To enable UBSan, enable following configuration: > > > + > > > +.. code-block:: console > > > + > > > + CONFIG_RTE_UBSAN=3Dy > > > + > > > +UBSan framework supports three modes: > > > + > > > +1. Enable UBSan on the entire DPDK source code - set following confi= guration: > > > + > > > +.. code-block:: console > > > + > > > + CONFIG_RTE_UBSAN_SANITIZE_ALL=3Dy > > > + > > > +2. Enable UBSan on a particular library or PMD - add the following l= ine to the > > > + respective Makefile of the library or PMD > > > + (make sure ``CONFIG_RTE_UBSAN_SANITIZE_ALL=3Dn``). This will inst= rument only > > > + the library or PMD and not the entire repository. > > > + > > > +.. code-block:: console > > > + > > > + UBSAN_SANITIZE :=3D y > > > + > > > +3. Disable UBSan for a particular library or PMD - add the following= line to > > > + the respective Makefile of the library or PMD. Make sure > > > + ``CONFIG_RTE_UBSAN_SANITIZE_ALL=3Dy`` config is set. This will in= strument > > > + entire DPDK repository but not this specific library or PMD. > > > + > > > +.. code-block:: console > > > + > > > + UBSAN_SANITIZE :=3D n > > > + > > > +.. Note:: > > > + > > > + Standard DPDK applications like test, testpmd, etc. cannot be > > > + chosen explicitly for UBSan check, like libraries or PMD. The reas= on is, > > > + say UBSan is enabled for library X, and ``UBSAN_SANITIZE=3Dy`` is = not added > > > + in Makefile of app Y which uses X APIs. This will lead to undefine= d > > > + reference to _UBSan_handle_* handlers as Y is not compiled with UB= San flags. > > > + Hence UBSan check is enabled for all standard DPDK applications as= soon as > > > + ``CONFIG_RTE_UBSAN=3Dy`` is set. > > > + > > > +meson build > > > +^^^^^^^^^^^ > > > + > > > +To enable UBSan in meson build system, use following meson build com= mand: > > > + > > > +**Example usage:** > > > + > > > +.. code-block:: console > > > + > > > + meson build -Denable_ubsan=3Dtrue > > > + ninja -C build > > > + > > > +.. Note:: > > > + > > > + Meson build works only in one mode i.e. UBSan can be enabled for > > > + the entire DPDK sources and not individual libraries or PMD, like = make build. > > > diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_= notes/release_19_11.rst > > > index 8490d897c..cfefdbeec 100644 > > > --- a/doc/guides/rel_notes/release_19_11.rst > > > +++ b/doc/guides/rel_notes/release_19_11.rst > > > @@ -56,6 +56,13 @@ New Features > > > Also, make sure to start the actual text at the margin. > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > =20 > > > +* **Added Undefined Behavior Sanitizer framework.** > > > + > > > + UBSan is a fast runtime undefined behavior detector which uses com= pile-time > > > + instrumentation and modifies the program by adding some stubs that= perform > > > + certain checks before operations that might cause undefined behavi= or. > > > + > > > + See :doc:`../prog_guide/ubsan` for more information: > > > =20 > > > Removed Items > > > ------------- > > > diff --git a/meson_options.txt b/meson_options.txt > > > index 448f3e63d..fb0aead00 100644 > > > --- a/meson_options.txt > > > +++ b/meson_options.txt > > > @@ -8,6 +8,8 @@ option('enable_docs', type: 'boolean', value: false, > > > description: 'build documentation') > > > option('enable_kmods', type: 'boolean', value: true, > > > description: 'build kernel modules') > > > +option('enable_ubsan', type: 'boolean', value: false, > > > + description: 'Enables undefined behavior sanitizer') > > > option('examples', type: 'string', value: '', > > > description: 'Comma-separated list of examples to build by default'= ) > > > option('flexran_sdk', type: 'string', value: '', > > > diff --git a/mk/rte.app.mk b/mk/rte.app.mk > > > index ba5c39e01..9ea421a83 100644 > > > --- a/mk/rte.app.mk > > > +++ b/mk/rte.app.mk > > > @@ -374,6 +374,16 @@ endif > > > =20 > > > MAPFLAGS =3D -Map=3D$@.map --cref > > > =20 > > > +# > > > +# If UBSAN is enabled, all application will be compiled with > > > +# '-fsanitize=3Dundefined' flag > > > +# > > > +ifeq ($(CONFIG_RTE_UBSAN),y) > > > +ifeq ($(UBSAN_ENABLE),y) > > > +CFLAGS +=3D -fsanitize=3Dundefined > > > +endif > > > +endif > > > + > > > .PHONY: all > > > all: install > > > =20 > > > diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk > > > index 4df8849a0..33f5746c8 100644 > > > --- a/mk/rte.lib.mk > > > +++ b/mk/rte.lib.mk > > > @@ -29,6 +29,18 @@ CPU_LDFLAGS +=3D --version-script=3D$(SRCDIR)/$(EX= PORT_MAP) > > > endif > > > endif > > > =20 > > > +# > > > +# If UBSAN is enabled, lib to undergo check can be chosen > > > +# by setting UBSAN_SANITIZE=3Dy in respective lib Makefile > > > +# else set CONFIG_RTE_UBSAN_SANITIZE_ALL=3Dy to enforce check > > > +# on entire repo. > > > +# > > > +ifeq ($(CONFIG_RTE_UBSAN),y) > > > +ifeq ($(UBSAN_ENABLE),y) > > > +CFLAGS +=3D $(if $(patsubst %n,,$(CONFIG_RTE_UBSAN_SANITIZE_ALL)$(UB= SAN_SANITIZE)) \ > > > + , -fsanitize=3Dundefined) > > > +endif > > > +endif > > > =20 > > > _BUILD =3D $(LIB) > > > PREINSTALL =3D $(SYMLINK-FILES-y) > > > diff --git a/mk/toolchain/clang/rte.vars.mk b/mk/toolchain/clang/rte.= vars.mk > > > index 3c49dc568..623780106 100644 > > > --- a/mk/toolchain/clang/rte.vars.mk > > > +++ b/mk/toolchain/clang/rte.vars.mk > > > @@ -56,5 +56,9 @@ ifeq ($(shell test $(CLANG_MAJOR_VERSION) -ge 4 && = echo 1), 1) > > > WERROR_FLAGS +=3D -Wno-address-of-packed-member > > > endif > > > =20 > > > +ifeq ($(CONFIG_RTE_UBSAN),y) > > > +UBSAN_ENABLE :=3D y > > > +endif > > > + > > > export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF > > > export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS > > > diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars= .mk > > > index b852fcfd7..d40e14d61 100644 > > > --- a/mk/toolchain/gcc/rte.vars.mk > > > +++ b/mk/toolchain/gcc/rte.vars.mk > > > @@ -90,5 +90,13 @@ endif > > > # disable packed member unalign warnings > > > WERROR_FLAGS +=3D -Wno-address-of-packed-member > > > =20 > > > +ifeq ($(CONFIG_RTE_UBSAN),y) > > > +ifeq ($(shell test $(GCC_VERSION) -lt 49 && echo 1), 1) > > > +$(warning UBSAN not supported gcc < 4.9) > > > +else > > > +UBSAN_ENABLE =3D y > > > +endif > > > +endif > > > + > > > export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF > > > export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS > > > --=20 > > > 2.18.0 > > >=20