From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 638AA3230 for ; Mon, 27 Jun 2016 18:41:00 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 27 Jun 2016 09:40:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,537,1459839600"; d="scan'208";a="836050609" Received: from dcarleto-mobl4.ger.corp.intel.com ([10.252.0.127]) by orsmga003.jf.intel.com with SMTP; 27 Jun 2016 09:40:58 -0700 Received: by (sSMTP sendmail emulation); Mon, 27 Jun 2016 17:40:56 +0025 Date: Mon, 27 Jun 2016 17:40:56 +0100 From: Bruce Richardson To: "Wiles, Keith" Cc: "dev@dpdk.org" Message-ID: <20160627164056.GF17808@bricha3-MOBL3> References: <1757902E-701B-4C42-BF80-285F37F50526@intel.com> <1466956452-91772-2-git-send-email-keith.wiles@intel.com> <20160627084649.GB19588@bricha3-MOBL3> <850EC958-78ED-47B1-9D5C-3D06CE5D0B04@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <850EC958-78ED-47B1-9D5C-3D06CE5D0B04@intel.com> Organization: Intel Research and =?iso-8859-1?Q?De=ACvel?= =?iso-8859-1?Q?opment?= Ireland Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v2 2/2] fix building with clang-3.8.0 compiler X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2016 16:41:00 -0000 On Mon, Jun 27, 2016 at 05:29:59PM +0100, Wiles, Keith wrote: > On 6/27/16, 7:58 AM, "dev on behalf of Wiles, Keith" wrote: >=20 > > > >On 6/27/16, 3:46 AM, "Richardson, Bruce" wr= ote: > > > >>On Sun, Jun 26, 2016 at 10:54:12AM -0500, Keith Wiles wrote: > >>> Latest clang compiler 3.8.0 on latest update of Ubuntu > >>> creates a few more warnings on -Warray-bounds and extra > >>> () around 'if' expressions. > >>>=20 > >>> Signed-off-by: Keith Wiles > >>> --- > >>> app/test-pmd/Makefile | 3 +++ > >>> app/test/Makefile | 3 +++ > >>> drivers/net/bonding/Makefile | 4 ++++ > >>> drivers/net/fm10k/Makefile | 2 ++ > >>> drivers/net/i40e/Makefile | 2 ++ > >>> lib/librte_cmdline/Makefile | 6 ++++++ > >>> lib/librte_eal/linuxapp/eal/Makefile | 8 ++++++++ > >>> 7 files changed, 28 insertions(+) > >>>=20 > >>All the fixes in this patch seem to be just disabling the compiler warn= ings, which > >>should really be the last resort in cases like this. Can some of the is= sues be > >>fixed by actually fixing the issues in the code? > > > >I did look at the code to fix the problem, because I could not see one: > > > >/work/home/rkwiles/projects/intel/dpdk/app/test-pmd/cmdline.c:3357:2140:= error: array index 3 is past the end of the array (which contains 3 elemen= ts) [-Werror,-Warray-bounds] > > if (!__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p= (res->proto) && __builtin_constant_p ("ip") && (__s1_len =3D __builtin_str= len (res->proto), __s2_len =3D __builtin_strlen ("ip"), (!((size_t)(const v= oid *)((res->proto) + 1) - (size_t)(const void *)(res->proto) =3D=3D 1) || = __s1_len >=3D 4) && (!((size_t)(const void *)(("ip") + 1) - (size_t)(const = void *)("ip") =3D=3D 1) || __s2_len >=3D 4)) ? __builtin_strcmp (res->proto= , "ip") : (__builtin_constant_p (res->proto) && ((size_t)(const void *)((re= s->proto) + 1) - (size_t)(const void *)(res->proto) =3D=3D 1) && (__s1_len = =3D __builtin_strlen (res->proto), __s1_len < 4) ? (__builtin_constant_p ("= ip") && ((size_t)(const void *)(("ip") + 1) - (size_t)(const void *)("ip") = =3D=3D 1) ? __builtin_strcmp (res->proto, "ip") : (__extension__ ({ const u= nsigned char *__s2 =3D (const unsigned char *) (const char *) ("ip"); int _= _result =3D (((const unsigned char *) (const char *) (res->proto))[0] - __s= 2[0]); if (__s1_len > 0 && __result =3D=3D 0) { __result =3D (((const unsig= ned char *) (const char *) (res->proto))[1] - __s2[1]); if (__s1_len > 1 &&= __result =3D=3D 0) { __result =3D (((const unsigned char *) (const char *)= (res->proto))[2] - __s2[2]); if (__s1_len > 2 && __result =3D=3D 0) __resu= lt =3D (((const unsigned char *) (const char *) (res->proto))[3] - __s2[3])= ; } } __result; }))) : (__builtin_constant_p ("ip") && ((size_t)(const void= *)(("ip") + 1) - (size_t)(const void *)("ip") =3D=3D 1) && (__s2_len =3D _= _builtin_strlen ("ip"), __s2_len < 4) ? (__builtin_constant_p (res->proto) = && ((size_t)(const void *)((res->proto) + 1) - (size_t)(const void *)(res->= proto) =3D=3D 1) ? __builtin_strcmp (res->proto, "ip") : (- (__extension__ = ({ const unsigned char *__s2 =3D (const unsigned char *) (const char *) (re= s->proto); int __result =3D (((const unsigned char *) (const char *) ("ip")= )[0] - __s2[0]); if (__s2_len > 0 && __result =3D=3D 0) { __result =3D (((c= onst unsigned char *) (const char *) ("ip"))[1] - __s2[1]); if (__s2_len > = 1 && __result =3D=3D 0) { __result =3D (((const unsigned char *) (const cha= r *) ("ip"))[2] - __s2[2]); if (__s2_len > 2 && __result =3D=3D 0) __result= =3D (((const unsigned char *) (const char *) ("ip"))[3] - __s2[3]); } } __= result; })))) : __builtin_strcmp (res->proto, "ip")))); })) { > > > >Here is the line of code for that one: > > if (!strcmp(res->proto, "ip")) { > > > >The =E2=80=93Wno-parenthese-equality problem gives the output here: > > > >/work/home/rkwiles/projects/intel/dpdk/lib/librte_cmdline/cmdline_cirbuf= =2Ec:288:19: error: equality comparison with extraneous parentheses [-Werro= r,-Wparentheses-equality] > > if (((cbuf)->len =3D=3D 0)) { > > > >The line is: > > > > if (CIRBUF_IS_EMPTY(cbuf)) { > > > >This one is in cmdline_cirbuf.h, which can be changed, but I do not thin= k we need to remove the parenthese. > > > >I will look at some of other solution, so I rejected the patch. >=20 > I found the problem to the compile errors I am seeing with building with = clang and shared libraries. >=20 > The x86_64-linux-gnu/bits/string2.h header file if getting included from = string.h, but this would be mean __GNUC__ is defined and this is the clang = compiler. After much investigation it turns out =E2=80=98ccache=E2=80=99 is= the problem here. If ccache is enabled with clang builds the __GNUC__ is d= efined some how, I never did find the location. >=20 > Just a warning it appears =E2=80=98ccache=E2=80=99 for caching object fil= es is not compatible with DPDK builds =E2=98=B9 in all cases. >=20 Actually, I believe it's a more general ccache and clang problem, not DPDK = specific. See e.g. http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-= 2.html where the recommendation is to set "export CCACHE_CPP2=3Dyes" in your envir= onment. This cleared quite a number of issues for me (and others) when compiling wi= th clang. [Credit too to Ferruh who first pointed this issue out to me] /Bruce