DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: "Wiles, Keith" <keith.wiles@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 2/2] fix building with clang-3.8.0 compiler
Date: Mon, 27 Jun 2016 17:40:56 +0100	[thread overview]
Message-ID: <20160627164056.GF17808@bricha3-MOBL3> (raw)
In-Reply-To: <850EC958-78ED-47B1-9D5C-3D06CE5D0B04@intel.com>

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" <dev-bounces@dpdk.org on behalf of keith.wiles@intel.com> wrote:
> 
> >
> >On 6/27/16, 3:46 AM, "Richardson, Bruce" <bruce.richardson@intel.com> wrote:
> >
> >>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.
> >>> 
> >>> Signed-off-by: Keith Wiles <keith.wiles@intel.com>
> >>> ---
> >>>  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(+)
> >>> 
> >>All the fixes in this patch seem to be just disabling the compiler warnings, which
> >>should really be the last resort in cases like this. Can some of the issues 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 elements) [-Werror,-Warray-bounds]
> >  if (!__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (res->proto) && __builtin_constant_p ("ip") && (__s1_len = __builtin_strlen (res->proto), __s2_len = __builtin_strlen ("ip"), (!((size_t)(const void *)((res->proto) + 1) - (size_t)(const void *)(res->proto) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("ip") + 1) - (size_t)(const void *)("ip") == 1) || __s2_len >= 4)) ? __builtin_strcmp (res->proto, "ip") : (__builtin_constant_p (res->proto) && ((size_t)(const void *)((res->proto) + 1) - (size_t)(const void *)(res->proto) == 1) && (__s1_len = __builtin_strlen (res->proto), __s1_len < 4) ? (__builtin_constant_p ("ip") && ((size_t)(const void *)(("ip") + 1) - (size_t)(const void *)("ip") == 1) ? __builtin_strcmp (res->proto, "ip") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("ip"); int __result = (((const unsigned char *) (const char *) (res->proto))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (res->proto))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (res->proto))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((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") == 1) && (__s2_len = __builtin_strlen ("ip"), __s2_len < 4) ? (__builtin_constant_p (res->proto) && ((size_t)(const void *)((res->proto) + 1) - (size_t)(const void *)(res->proto) == 1) ? __builtin_strcmp (res->proto, "ip") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (res->proto); int __result = (((const unsigned char *) (const char *) ("ip"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ip"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ip"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((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 –Wno-parenthese-equality problem gives the output here:
> >
> >/work/home/rkwiles/projects/intel/dpdk/lib/librte_cmdline/cmdline_cirbuf.c:288:19: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
> > if (((cbuf)->len == 0)) {
> >
> >The line is:
> >
> >        if (CIRBUF_IS_EMPTY(cbuf)) {
> >
> >This one is in cmdline_cirbuf.h, which can be changed, but I do not think we need to remove the parenthese.
> >
> >I will look at some of other solution, so I rejected the patch.
> 
> I found the problem to the compile errors I am seeing with building with clang and shared libraries.
> 
> 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 ‘ccache’ is the problem here. If ccache is enabled with clang builds the __GNUC__ is defined some how, I never did find the location.
> 
> Just a warning it appears ‘ccache’ for caching object files is not compatible with DPDK builds ☹ in all cases.
> 
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=yes" in your environment.
This cleared quite a number of issues for me (and others) when compiling with
clang.

[Credit too to Ferruh who first pointed this issue out to me]

/Bruce

  reply	other threads:[~2016-06-27 16:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-26 15:32 [dpdk-dev] [PATCH 1/2] e1000:fix gcc test for clang builds Keith Wiles
2016-06-26 15:32 ` [dpdk-dev] [PATCH 2/2] fix building with clang-3.8.0 compiler Keith Wiles
2016-06-26 15:50   ` Wiles, Keith
2016-06-26 15:54     ` [dpdk-dev] [PATCH v2 1/2] e1000:fix gcc test for clang builds Keith Wiles
2016-06-26 15:54     ` [dpdk-dev] [PATCH v2 2/2] fix building with clang-3.8.0 compiler Keith Wiles
2016-06-27  8:46       ` Bruce Richardson
2016-06-27 12:58         ` Wiles, Keith
2016-06-27 16:29           ` Wiles, Keith
2016-06-27 16:40             ` Bruce Richardson [this message]
2016-06-27 16:51               ` Wiles, Keith
2016-06-27 17:13                 ` Thomas Monjalon
2016-06-27  8:48       ` Thomas Monjalon
2016-06-26 15:49 ` [dpdk-dev] [PATCH 1/2] e1000:fix gcc test for clang builds Wiles, Keith

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=20160627164056.GF17808@bricha3-MOBL3 \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=keith.wiles@intel.com \
    /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).