summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-04-26 14:54:57 +0200
committerDave Barach <openvpp@barachs.net>2016-04-26 16:16:44 +0000
commite39a7b8347b1055cca6e9cfadcfeca23f8236eb9 (patch)
tree0113d89f6faaf4013266f46c5e520735063b63f5
parent1dabaafcebb02699cae1ebd2b58e34dfe6b0f064 (diff)
Fix compile errors reported by clang
For using clang as a compiler it is enough to specify CC=clang in the make command line Change-Id: I06f1c1d418b68768f8119de5bdc8748c51f90c02 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--dpdk/Makefile13
-rw-r--r--dpdk/dpdk-16.04_patches/0010-Fix-O0-clang-build.patch32
-rw-r--r--vlib/vlib/pci/pci_config.h2
-rw-r--r--vlib/vlib/unix/pci.c2
-rw-r--r--vnet/vnet/ip/adj_alloc.c2
-rw-r--r--vnet/vnet/lisp-cp/packets.c2
-rw-r--r--vnet/vnet/lisp-gpe/decap.c2
-rw-r--r--vnet/vnet/lisp-gpe/lisp_gpe.c2
-rw-r--r--vnet/vnet/vcgn/cnat_global.c2
-rw-r--r--vnet/vnet/vcgn/cnat_ipv4_udp_outside_input.c4
-rw-r--r--vnet/vnet/vcgn/cnat_logging.c2
-rw-r--r--vnet/vnet/vcgn/cnat_ports.c2
-rw-r--r--vnet/vnet/vcgn/cnat_syslog.c2
-rw-r--r--vpp/vnet/main.c2
14 files changed, 55 insertions, 16 deletions
diff --git a/dpdk/Makefile b/dpdk/Makefile
index 398fc60f9c1..fadbb26831e 100644
--- a/dpdk/Makefile
+++ b/dpdk/Makefile
@@ -31,7 +31,14 @@ DPDK_2.1.0_TARBALL_MD5_CKSUM := 205a0d12bfd6eb717d57506272f43519
DPDK_2.2.0_TARBALL_MD5_CKSUM := 22e2fd68cd5504f43fe9a5a6fd6dd938
DPDK_16.04_TARBALL_MD5_CKSUM := 0728d506d7f56eb64233e824fa3c098a
DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
-DPDK_TARGET := x86_64-native-linuxapp-gcc
+
+ifneq (,$(findstring clang,$(CC)))
+DPDK_CC=clang
+else
+DPDK_CC=gcc
+endif
+
+DPDK_TARGET := x86_64-native-linuxapp-$(DPDK_CC)
JOBS := $(shell grep processor /proc/cpuinfo | wc -l)
# compiler/linker custom arguments
@@ -40,9 +47,9 @@ DPDK_CPU_LDFLAGS :=
DPDK_EXTRA_LDFLAGS := -g
ifeq ($(DPDK_DEBUG),n)
-DPDK_EXTRA_CFLAGS := -g
+DPDK_EXTRA_CFLAGS := -g
else
-DPDK_EXTRA_CFLAGS := -g -O0
+DPDK_EXTRA_CFLAGS := -g -O0
endif
# translate gcc march values to DPDK arch
diff --git a/dpdk/dpdk-16.04_patches/0010-Fix-O0-clang-build.patch b/dpdk/dpdk-16.04_patches/0010-Fix-O0-clang-build.patch
new file mode 100644
index 00000000000..2ce0e7c856b
--- /dev/null
+++ b/dpdk/dpdk-16.04_patches/0010-Fix-O0-clang-build.patch
@@ -0,0 +1,32 @@
+From 2b82c248638bba6e98ecf388c6e0b1f5f0b44028 Mon Sep 17 00:00:00 2001
+From: Damjan Marion <damarion@cisco.com>
+Date: Tue, 26 Apr 2016 12:36:52 +0200
+Subject: [PATCH] Fix -O0 clang build
+
+Signed-off-by: Damjan Marion <damarion@cisco.com>
+---
+ lib/librte_eal/common/include/arch/x86/rte_rtm.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/lib/librte_eal/common/include/arch/x86/rte_rtm.h b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
+index d935641..30c1969 100644
+--- a/lib/librte_eal/common/include/arch/x86/rte_rtm.h
++++ b/lib/librte_eal/common/include/arch/x86/rte_rtm.h
+@@ -50,11 +50,14 @@ void rte_xend(void)
+ asm volatile(".byte 0x0f,0x01,0xd5" ::: "memory");
+ }
+
++#define rte_xabort(x) asm volatile(".byte 0xc6,0xf8,%P0" :: "i" (x) : "memory")
++#if 0
+ static __attribute__((__always_inline__)) inline
+ void rte_xabort(const unsigned int status)
+ {
+ asm volatile(".byte 0xc6,0xf8,%P0" :: "i" (status) : "memory");
+ }
++#endif
+
+ static __attribute__((__always_inline__)) inline
+ int rte_xtest(void)
+--
+2.7.4
+
diff --git a/vlib/vlib/pci/pci_config.h b/vlib/vlib/pci/pci_config.h
index 38215d82e95..9cada51c3ef 100644
--- a/vlib/vlib/pci/pci_config.h
+++ b/vlib/vlib/pci/pci_config.h
@@ -417,7 +417,7 @@ pci_config_find_capability (pci_config_type0_regs_t * t, int cap_type)
while (ttl-- && next_offset >= 0x40)
{
c = (void *) t + (next_offset &~ 3);
- if (c->type == 0xff)
+ if ((u8) c->type == 0xff)
break;
if (c->type == cap_type)
return c;
diff --git a/vlib/vlib/unix/pci.c b/vlib/vlib/unix/pci.c
index 75241f3f1c6..b28b542b42e 100644
--- a/vlib/vlib/unix/pci.c
+++ b/vlib/vlib/unix/pci.c
@@ -420,7 +420,7 @@ u8 * format_os_pci_handle (u8 * s, va_list * va)
l->bus_address.slot, l->bus_address.function);
}
-static inline pci_device_registration_t *
+pci_device_registration_t * __attribute__((unused))
pci_device_next_registered (pci_device_registration_t * r)
{
uword i;
diff --git a/vnet/vnet/ip/adj_alloc.c b/vnet/vnet/ip/adj_alloc.c
index 56104207363..3ae7a199f19 100644
--- a/vnet/vnet/ip/adj_alloc.c
+++ b/vnet/vnet/ip/adj_alloc.c
@@ -51,7 +51,7 @@ aa_alloc (ip_adjacency_t * adjs, ip_adjacency_t **blockp, u32 n)
aa_header_t * ah = aa_header (adjs);
ip_adjacency_t * adj_block;
u32 freelist_length;
- int need_barrier_sync;
+ int need_barrier_sync = 0;
ASSERT(os_get_cpu_number() == 0);
ASSERT (clib_mem_is_heap_object (_vec_find(ah)));
diff --git a/vnet/vnet/lisp-cp/packets.c b/vnet/vnet/lisp-cp/packets.c
index aa246a9dc3d..28471b9a82d 100644
--- a/vnet/vnet/lisp-cp/packets.c
+++ b/vnet/vnet/lisp-cp/packets.c
@@ -225,7 +225,7 @@ pkt_push_udp_and_ip (vlib_main_t * vm, vlib_buffer_t *b, u16 sp, u16 dp,
udpsum = udp_checksum (uh, clib_net_to_host_u16 (uh->length), ih,
ip_addr_version(sip));
- if (udpsum == -1)
+ if (udpsum == (u16) ~0)
{
clib_warning("Failed UDP checksum! Discarding");
return 0;
diff --git a/vnet/vnet/lisp-gpe/decap.c b/vnet/vnet/lisp-gpe/decap.c
index 5d88462b416..d0848ab56f4 100644
--- a/vnet/vnet/lisp-gpe/decap.c
+++ b/vnet/vnet/lisp-gpe/decap.c
@@ -104,7 +104,7 @@ lisp_gpe_input (vlib_main_t * vm, vlib_node_runtime_t * node,
u32 bi0, bi1;
vlib_buffer_t * b0, * b1;
ip4_udp_lisp_gpe_header_t * iul0, * iul1;
- u32 next0, next1, error0, error1;
+ u32 next0, next1, error0 = 0, error1 = 0;
uword * si0, * si1;
next0 = next1 = LISP_GPE_INPUT_NEXT_IP4_INPUT;
diff --git a/vnet/vnet/lisp-gpe/lisp_gpe.c b/vnet/vnet/lisp-gpe/lisp_gpe.c
index fd1e1a4608e..a1d4b6fb2ee 100644
--- a/vnet/vnet/lisp-gpe/lisp_gpe.c
+++ b/vnet/vnet/lisp-gpe/lisp_gpe.c
@@ -721,7 +721,7 @@ add_del_negative_fwd_entry (lisp_gpe_main_t * lgm,
/* TODO insert tunnel that always sends map-request */
case DROP:
/* for drop fwd entries, just add route, no need to add encap tunnel */
- adj.lookup_next_index = LGPE_IP4_LOOKUP_NEXT_DROP;
+ adj.lookup_next_index = (u16) LGPE_IP4_LOOKUP_NEXT_DROP;
/* add/delete route for prefix */
return ip4_sd_fib_add_del_route (lgm, dpref, spref, a->table_id, &adj,
diff --git a/vnet/vnet/vcgn/cnat_global.c b/vnet/vnet/vcgn/cnat_global.c
index 9ab89eeaf05..7177083466e 100644
--- a/vnet/vnet/vcgn/cnat_global.c
+++ b/vnet/vnet/vcgn/cnat_global.c
@@ -57,7 +57,7 @@ dslite_table_entry_t *dslite_table_db_ptr;
*/
/* TOBE_PORTED: Following is in cnat_util.c */
-always_inline
+always_inline __attribute__((unused))
void ipv4_decr_ttl_n_calc_csum(ipv4_header *ipv4)
{
u32 checksum;
diff --git a/vnet/vnet/vcgn/cnat_ipv4_udp_outside_input.c b/vnet/vnet/vcgn/cnat_ipv4_udp_outside_input.c
index f6ffd4efa7e..5a24a111f75 100644
--- a/vnet/vnet/vcgn/cnat_ipv4_udp_outside_input.c
+++ b/vnet/vnet/vcgn/cnat_ipv4_udp_outside_input.c
@@ -137,8 +137,8 @@ is_static_dest_nat_enabled(u16 vrf)
return CNAT_NO_CONFIG;
}*/
-static inline void swap_ip_dst(ipv4_header *ip,
- cnat_main_db_entry_t *db, u16 vrf)
+static inline void __attribute__((unused))
+swap_ip_dst(ipv4_header *ip, cnat_main_db_entry_t *db, u16 vrf)
{
CNAT_UPDATE_L3_CHECKSUM_DECLARE
diff --git a/vnet/vnet/vcgn/cnat_logging.c b/vnet/vnet/vcgn/cnat_logging.c
index d404c590c26..50805d118ae 100644
--- a/vnet/vnet/vcgn/cnat_logging.c
+++ b/vnet/vnet/vcgn/cnat_logging.c
@@ -2668,7 +2668,7 @@ void cnat_nfv9_ds_lite_log_session_delete(
*/
-static inline
+static inline __attribute__((unused))
void handle_vrfid_name_mapping(void)
{
cnat_nfv9_logging_info_t *nfv9_logging_info = NULL;
diff --git a/vnet/vnet/vcgn/cnat_ports.c b/vnet/vnet/vcgn/cnat_ports.c
index 4437865aaee..943fb3ed38c 100644
--- a/vnet/vnet/vcgn/cnat_ports.c
+++ b/vnet/vnet/vcgn/cnat_ports.c
@@ -623,7 +623,7 @@ cnat_dynamic_port_alloc_v2 (
for (i = 0; i < max_trys_to_find_port; i++) {
/* start_bit is only a u16.. so it can rollover and become zero */
- if (PREDICT_FALSE((start_bit >= BITS_PER_INST) ||
+ if (PREDICT_FALSE( /* (start_bit >= BITS_PER_INST) || FIXME u16 cannot be >= 65536 */
(start_bit < static_port_range))) {
start_bit = static_port_range;
#ifndef NO_BULK_LOGGING
diff --git a/vnet/vnet/vcgn/cnat_syslog.c b/vnet/vnet/vcgn/cnat_syslog.c
index 65fde4caf30..91758f141a9 100644
--- a/vnet/vnet/vcgn/cnat_syslog.c
+++ b/vnet/vnet/vcgn/cnat_syslog.c
@@ -361,7 +361,7 @@ byte_to_ascii_decimal_unaligned(
* in to the space provided and
* returns the number of bytes copied
*/
-inline static int
+inline static int __attribute__((unused))
copy_ipv4_addr(unsigned char *ptr, u32 ipv4)
{
unsigned char *temp = ptr;
diff --git a/vpp/vnet/main.c b/vpp/vnet/main.c
index 4659440fed1..2e08aa530f7 100644
--- a/vpp/vnet/main.c
+++ b/vpp/vnet/main.c
@@ -67,7 +67,7 @@ int main (int argc, char * argv[])
u32 size;
void vlib_set_get_handoff_structure_cb (void *cb);
-#if __x86_64__
+#if __x86_64__ && !defined(__clang__)
__builtin_cpu_init ();
const char * msg = "ERROR: This binary requires CPU with %s extensions.\n";
#define _(a,b) \