Skip to contentSkip to conversation

e1000:fix gcc test for clang builds

PATCH Superseded Keith Wiles 3 participants 13 messages Jun 26, 2016 – Jun 27, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 e1000:fix gcc test for clang builds

---
 drivers/net/e1000/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/e1000/Makefile +4 -1
index 5b801f5..1305163 100644
@@ -48,7 +48,7 @@ ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
 # CFLAGS for icc
 #
 CFLAGS_BASE_DRIVER = -wd177 -wd181 -wd188 -wd869 -wd2259
-else
+else ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 #
 # CFLAGS for gcc
 #
@@ -57,6 +57,9 @@ CFLAGS_BASE_DRIVER += -Wno-unused-variable
 ifeq ($(shell test $(GCC_VERSION) -ge 60 && echo 1), 1)
 CFLAGS_BASE_DRIVER += -Wno-misleading-indentation
 endif
+else
+CFLAGS_BASE_DRIVER = -Wno-uninitialized -Wno-unused-parameter
+CFLAGS_BASE_DRIVER += -Wno-unused-variable
 endif
 
 #
Signature · 1 line
2.8.0.GIT
#1 lore raw

PATCH 2/2 fix building with clang-3.8.0 compiler

Latest clang compiler 3.8.0 on latest update of Ubuntu creates a few more warnings on -Warray-bounds and extra () around 'if' expressions.

---
 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 | 7 +++++++
 7 files changed, 27 insertions(+)
app/test-pmd/Makefile +3 -0
index 2a0b5a5..14ab77c 100644
@@ -59,6 +59,9 @@ SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 
 CFLAGS_cmdline.o := -D_GNU_SOURCE
+ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_cmdline.o += -Wno-array-bounds
+endif
 
 # this application needs libraries first
 DEPDIRS-y += lib drivers
app/test/Makefile +3 -0
index 2de8c7a..5593426 100644
@@ -211,6 +211,9 @@ ifeq ($(shell test $(GCC_VERSION) -ge 44 && echo 1), 1)
 CFLAGS_test_memcpy.o += -fno-var-tracking-assignments
 CFLAGS_test_memcpy_perf.o += -fno-var-tracking-assignments
 endif
+else ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_test_errno.o += -Wno-array-bounds
+CFLAGS_test_devargs.o += -Wno-array-bounds
 endif
 
 # this application needs libraries first
drivers/net/bonding/Makefile +4 -0
index 504f2e8..ee5f44a 100644
@@ -43,6 +43,10 @@ EXPORT_MAP := rte_eth_bond_version.map
 
 LIBABIVER := 1
 
+ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_rte_eth_bond_args.o := -Wno-array-bounds
+endif
+
 #
 # all source are stored in SRCS-y
 #
drivers/net/fm10k/Makefile +2 -0
index afcbd1d..d6c692d 100644
@@ -59,6 +59,8 @@ CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args
 CFLAGS_BASE_DRIVER += -Wno-unused-variable
 CFLAGS_BASE_DRIVER += -Wno-missing-field-initializers
 
+CFLAGS_fm10k_ethdev.o := -Wno-array-bounds
+
 else
 #
 # CFLAGS for gcc
drivers/net/i40e/Makefile +2 -0
index 9ffef3f..3a9e5a1 100644
@@ -60,6 +60,8 @@ CFLAGS_BASE_DRIVER += -Wno-missing-field-initializers
 CFLAGS_BASE_DRIVER += -Wno-pointer-to-int-cast
 CFLAGS_BASE_DRIVER += -Wno-format-nonliteral
 CFLAGS_BASE_DRIVER += -Wno-unused-variable
+
+CFLAGS_i40e_hmc.o += -Wno-tautological-compare
 else
 CFLAGS_BASE_DRIVER  = -Wno-sign-compare
 CFLAGS_BASE_DRIVER += -Wno-unused-value
lib/librte_cmdline/Makefile +6 -0
index 7d2d148..0af1d0a 100644
@@ -40,6 +40,12 @@ EXPORT_MAP := rte_cmdline_version.map
 
 LIBABIVER := 2
 
+ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_cmdline_cirbuf.o:= -Wno-parentheses-equality
+CFLAGS_cmdline_rdline.o:= -Wno-parentheses-equality
+CFLAGS_cmdline_parse_string.o:= -Wno-array-bounds
+endif
+
 # all source are stored in SRCS-y
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := cmdline.c
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_cirbuf.c
lib/librte_eal/linuxapp/eal/Makefile +7 -0
index 30b30f3..2ff8d62 100644
@@ -125,6 +125,13 @@ CFLAGS_eal_common_options.o := -D_GNU_SOURCE
 CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
 CFLAGS_eal_common_lcore.o := -D_GNU_SOURCE
 
+ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_eal_alarm.o += -Wno-parentheses-equality
+CFLAGS_eal_common_options.o += -Wno-array-bounds
+CFLAGS_eal_pci.o += -Wno-parentheses-equality
+CFLAGS_eal_pci.o += -Wno-array-bounds
+endif
+
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
Signature · 1 line
2.8.0.GIT
#2 lore raw

Re: [PATCH 2/2] fix building with clang-3.8.0 compiler

Quoted 6 lines · dev on behalf of Keith Wiles

Latest clang compiler 3.8.0 on latest update of Ubuntu creates a few more warnings on -Warray-bounds and extra () around 'if' expressions.

---

Quoted 9 lines
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 | 7 +++++++
7 files changed, 27 insertions(+)

self-nak: found another problem

#3 lore raw

PATCH v2 1/2 e1000:fix gcc test for clang builds

---
 drivers/net/e1000/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/e1000/Makefile +4 -1
index 5b801f5..1305163 100644
@@ -48,7 +48,7 @@ ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
 # CFLAGS for icc
 #
 CFLAGS_BASE_DRIVER = -wd177 -wd181 -wd188 -wd869 -wd2259
-else
+else ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 #
 # CFLAGS for gcc
 #
@@ -57,6 +57,9 @@ CFLAGS_BASE_DRIVER += -Wno-unused-variable
 ifeq ($(shell test $(GCC_VERSION) -ge 60 && echo 1), 1)
 CFLAGS_BASE_DRIVER += -Wno-misleading-indentation
 endif
+else
+CFLAGS_BASE_DRIVER = -Wno-uninitialized -Wno-unused-parameter
+CFLAGS_BASE_DRIVER += -Wno-unused-variable
 endif
 
 #
Signature · 1 line
2.8.0.GIT
#4 lore raw

PATCH v2 2/2 fix building with clang-3.8.0 compiler

Latest clang compiler 3.8.0 on latest update of Ubuntu creates a few more warnings on -Warray-bounds and extra () around 'if' expressions.

---
 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(+)
app/test-pmd/Makefile +3 -0
index 2a0b5a5..14ab77c 100644
@@ -59,6 +59,9 @@ SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 
 CFLAGS_cmdline.o := -D_GNU_SOURCE
+ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_cmdline.o += -Wno-array-bounds
+endif
 
 # this application needs libraries first
 DEPDIRS-y += lib drivers
app/test/Makefile +3 -0
index 2de8c7a..5593426 100644
@@ -211,6 +211,9 @@ ifeq ($(shell test $(GCC_VERSION) -ge 44 && echo 1), 1)
 CFLAGS_test_memcpy.o += -fno-var-tracking-assignments
 CFLAGS_test_memcpy_perf.o += -fno-var-tracking-assignments
 endif
+else ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_test_errno.o += -Wno-array-bounds
+CFLAGS_test_devargs.o += -Wno-array-bounds
 endif
 
 # this application needs libraries first
drivers/net/bonding/Makefile +4 -0
index 504f2e8..ee5f44a 100644
@@ -43,6 +43,10 @@ EXPORT_MAP := rte_eth_bond_version.map
 
 LIBABIVER := 1
 
+ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_rte_eth_bond_args.o := -Wno-array-bounds
+endif
+
 #
 # all source are stored in SRCS-y
 #
drivers/net/fm10k/Makefile +2 -0
index afcbd1d..d6c692d 100644
@@ -59,6 +59,8 @@ CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args
 CFLAGS_BASE_DRIVER += -Wno-unused-variable
 CFLAGS_BASE_DRIVER += -Wno-missing-field-initializers
 
+CFLAGS_fm10k_ethdev.o := -Wno-array-bounds
+
 else
 #
 # CFLAGS for gcc
drivers/net/i40e/Makefile +2 -0
index 9ffef3f..3a9e5a1 100644
@@ -60,6 +60,8 @@ CFLAGS_BASE_DRIVER += -Wno-missing-field-initializers
 CFLAGS_BASE_DRIVER += -Wno-pointer-to-int-cast
 CFLAGS_BASE_DRIVER += -Wno-format-nonliteral
 CFLAGS_BASE_DRIVER += -Wno-unused-variable
+
+CFLAGS_i40e_hmc.o += -Wno-tautological-compare
 else
 CFLAGS_BASE_DRIVER  = -Wno-sign-compare
 CFLAGS_BASE_DRIVER += -Wno-unused-value
lib/librte_cmdline/Makefile +6 -0
index 7d2d148..0af1d0a 100644
@@ -40,6 +40,12 @@ EXPORT_MAP := rte_cmdline_version.map
 
 LIBABIVER := 2
 
+ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_cmdline_cirbuf.o:= -Wno-parentheses-equality
+CFLAGS_cmdline_rdline.o:= -Wno-parentheses-equality
+CFLAGS_cmdline_parse_string.o:= -Wno-array-bounds
+endif
+
 # all source are stored in SRCS-y
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := cmdline.c
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_cirbuf.c
lib/librte_eal/linuxapp/eal/Makefile +8 -0
index 30b30f3..c771a85 100644
@@ -125,6 +125,14 @@ CFLAGS_eal_common_options.o := -D_GNU_SOURCE
 CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
 CFLAGS_eal_common_lcore.o := -D_GNU_SOURCE
 
+ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
+CFLAGS_eal_alarm.o += -Wno-parentheses-equality
+CFLAGS_eal_interrupts.o += -Wno-parentheses-equality
+CFLAGS_eal_common_options.o += -Wno-array-bounds
+CFLAGS_eal_pci.o += -Wno-parentheses-equality
+CFLAGS_eal_pci.o += -Wno-array-bounds
+endif
+
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
Signature · 1 line
2.8.0.GIT
#5 lore raw

Re: [PATCH v2 2/2] fix building with clang-3.8.0 compiler

Quoted 5 lines · Keith Wiles

Latest clang compiler 3.8.0 on latest update of Ubuntu creates a few more warnings on -Warray-bounds and extra () around 'if' expressions.

Quoted 10 lines
---
 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?

/Bruce

#6 lore raw

Re: [PATCH v2 2/2] fix building with clang-3.8.0 compiler

Quoted 16 lines · Bruce
Quoted 5 lines · Keith Wiles

Latest clang compiler 3.8.0 on latest update of Ubuntu creates a few more warnings on -Warray-bounds and extra () around 'if' expressions.

Quoted 10 lines
---
 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(+)
Quoted 3 lines

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.

Quoted 3 lines

/Bruce

#7 lore raw

Re: [PATCH v2 2/2] fix building with clang-3.8.0 compiler

Quoted 36 lines · Keith
Quoted 16 lines · Bruce
Quoted 5 lines · Keith Wiles

Latest clang compiler 3.8.0 on latest update of Ubuntu creates a few more warnings on -Warray-bounds and extra () around 'if' expressions.

Quoted 10 lines
---
 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(+)
Quoted 3 lines

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)) {

Quoted 7 lines

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.

Quoted 9 lines
Quoted 5 lines

/Bruce

#8 lore raw

Re: [PATCH v2 2/2] fix building with clang-3.8.0 compiler

Quoted 44 lines · Keith
Quoted 42 lines · Keith
Quoted 16 lines · Bruce
Quoted 5 lines · Keith Wiles

Latest clang compiler 3.8.0 on latest update of Ubuntu creates a few more warnings on -Warray-bounds and extra () around 'if' expressions.

Quoted 10 lines
---
 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(+)
Quoted 3 lines

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.

Quoted 8 lines
Quoted 1 line

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

#9 lore raw

Re: [PATCH v2 2/2] fix building with clang-3.8.0 compiler

Quoted 53 lines · Bruce
Quoted 44 lines · Keith
Quoted 42 lines · Keith
Quoted 16 lines · Bruce
Quoted 5 lines · Keith Wiles

Latest clang compiler 3.8.0 on latest update of Ubuntu creates a few more warnings on -Warray-bounds and extra () around 'if' expressions.

Quoted 10 lines
---
 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(+)
Quoted 3 lines

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.

Quoted 8 lines
Quoted 1 line

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.

Quoted 7 lines

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.

Adding the CCACHE_CPP2=yes

Cleaned up all of the compiler errors I was seeing ☺

Do we need to document this in DPDK and if so where in the docs would someone suggest it be placed?

Quoted 5 lines

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

/Bruce

#10 lore raw

Re: [PATCH v2 2/2] fix building with clang-3.8.0 compiler

2016-06-27 16:51, Wiles, Keith:

Quoted 19 lines · Bruce
Quoted 10 lines · Keith
Quoted 9 lines · On 6/27/16, 7:58 AM, on behalf of [email protected]> wrote:
Quoted 2 lines · Bruce
Quoted 1 line · Keith Wiles

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.

Quoted 7 lines

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.

Quoted 5 lines

Adding the CCACHE_CPP2=yes

Cleaned up all of the compiler errors I was seeing ☺

Do we need to document this in DPDK and if so where in the docs would someone suggest it be placed?

I do not use ccache with clang because it is not known to work. But if you are sure it can work with few configuration, I would be glad to have a complete description.
However it is not related to DPDK at all. That's why a nice email well written and explained on this ml looks enough to be found via Google. Thanks

#11 lore raw

Re: [PATCH v2 2/2] fix building with clang-3.8.0 compiler

In reply to Keith Wiles

2016-06-26 10:54, Keith Wiles:

Quoted 3 lines

Latest clang compiler 3.8.0 on latest update of Ubuntu creates a few more warnings on -Warray-bounds and extra () around 'if' expressions.

The goal of compiler checks is to fix the code. Why disabling these checks instead of fixing the code? If they are false positive, they need to be justified and limited to some compiler versions.

#12 lore raw
In reply to Keith Wiles
Quoted 25 lines · dev on behalf of Keith Wiles

---
drivers/net/e1000/Makefile | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/e1000/Makefile +0 -0
index 5b801f5..1305163 100644
@@ -48,7 +48,7 @@ ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
 # CFLAGS for icc
 #

CFLAGS_BASE_DRIVER = -wd177 -wd181 -wd188 -wd869 -wd2259

drivers/net/e1000/Makefile +1 -1
-else
+else ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)

#
# CFLAGS for gcc
#

drivers/net/e1000/Makefile +0 -0
@@ -57,6 +57,9 @@ CFLAGS_BASE_DRIVER += -Wno-unused-variable
 ifeq ($(shell test $(GCC_VERSION) -ge 60 && echo 1), 1)

CFLAGS_BASE_DRIVER += -Wno-misleading-indentation
endif

drivers/net/e1000/Makefile +3 -0
+else
+CFLAGS_BASE_DRIVER = -Wno-uninitialized -Wno-unused-parameter
+CFLAGS_BASE_DRIVER += -Wno-unused-variable
Quoted 1 line

endif

self-nak found another clang compiler problem.

Quoted 6 lines

#

Signature · 1 line
2.8.0.GIT