diff options
author | Benoît Ganne <bganne@cisco.com> | 2019-02-12 13:35:08 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2019-02-14 17:18:36 +0000 |
commit | 47727c02df4c79c21c6ceffaff65222c32cf6996 (patch) | |
tree | ff56da0094b29da6d07746b08574dfb194ed9113 /src | |
parent | 8f6c1dda355b6e4d00dc4e41e65a25e1fd1507ee (diff) |
Add -fno-common compile option
-fno-common makes sure we do not have multiple declarations of the same
global symbol across compilation units. It helps debug nasty linkage
bugs by guaranteeing that all reference to a global symbol use the same
underlying object.
It also helps avoiding benign mistakes such as declaring enum as global
objects instead of types in headers (hence the minor fixes scattered
across the source).
Change-Id: I55c16406dc54ff8a6860238b90ca990fa6b179f1
Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src')
27 files changed, 34 insertions, 22 deletions
diff --git a/src/cmake/cpu.cmake b/src/cmake/cpu.cmake index b2af1aa0926..60cf3b9dcf0 100644 --- a/src/cmake/cpu.cmake +++ b/src/cmake/cpu.cmake @@ -93,7 +93,7 @@ macro(vpp_library_set_multiarch_sources lib) set(l ${lib}_${VARIANT}) add_library(${l} OBJECT ${ARGN}) set_target_properties(${l} PROPERTIES POSITION_INDEPENDENT_CODE ON) - target_compile_options(${l} PUBLIC "-DCLIB_MARCH_VARIANT=${VARIANT}") + target_compile_options(${l} PUBLIC "-DCLIB_MARCH_VARIANT=${VARIANT}" -Wall -fno-common) separate_arguments(VARIANT_FLAGS) target_compile_options(${l} PUBLIC ${VARIANT_FLAGS}) target_sources(${lib} PRIVATE $<TARGET_OBJECTS:${l}>) diff --git a/src/cmake/library.cmake b/src/cmake/library.cmake index 984d6eb8d75..747aeb4705f 100644 --- a/src/cmake/library.cmake +++ b/src/cmake/library.cmake @@ -20,7 +20,7 @@ macro(add_vpp_library lib) ) add_library(${lib} SHARED ${ARG_SOURCES}) - target_compile_options(${lib} PRIVATE -Wall) + target_compile_options(${lib} PRIVATE -Wall -fno-common) if(VPP_LIB_VERSION) set_target_properties(${lib} PROPERTIES SOVERSION ${VPP_LIB_VERSION}) endif() diff --git a/src/plugins/acl/fa_node.h b/src/plugins/acl/fa_node.h index 83a1984c22f..c969377ded7 100644 --- a/src/plugins/acl/fa_node.h +++ b/src/plugins/acl/fa_node.h @@ -241,7 +241,7 @@ typedef enum { } acl_fa_next_t; -enum +typedef enum { ACL_FA_CLEANER_RESCHEDULE = 1, ACL_FA_CLEANER_DELETE_BY_SW_IF_INDEX, diff --git a/src/plugins/avf/avf.h b/src/plugins/avf/avf.h index b79a22b073f..9836451e012 100644 --- a/src/plugins/avf/avf.h +++ b/src/plugins/avf/avf.h @@ -168,7 +168,7 @@ typedef struct #define AVF_RX_VECTOR_SZ VLIB_FRAME_SIZE -enum +typedef enum { AVF_PROCESS_EVENT_START = 1, AVF_PROCESS_EVENT_STOP = 2, diff --git a/src/plugins/memif/private.h b/src/plugins/memif/private.h index 2aa1f5a0cdc..4613512041d 100644 --- a/src/plugins/memif/private.h +++ b/src/plugins/memif/private.h @@ -255,7 +255,7 @@ extern memif_main_t memif_main; extern vnet_device_class_t memif_device_class; extern vlib_node_registration_t memif_input_node; -enum +typedef enum { MEMIF_PROCESS_EVENT_START = 1, MEMIF_PROCESS_EVENT_STOP = 2, diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h index d55ecd4c72d..f77d4479e41 100644 --- a/src/vcl/vcl_private.h +++ b/src/vcl/vcl_private.h @@ -115,7 +115,7 @@ typedef struct vcl_session_msg u32 flags; } vcl_session_msg_t; -enum +typedef enum { VCL_SESS_ATTR_SERVER, VCL_SESS_ATTR_CUT_THRU, diff --git a/src/vnet/bfd/bfd_main.h b/src/vnet/bfd/bfd_main.h index c587c86801f..9f072e11837 100644 --- a/src/vnet/bfd/bfd_main.h +++ b/src/vnet/bfd/bfd_main.h @@ -345,7 +345,7 @@ typedef struct u8 data[400]; } bfd_input_trace_t; -enum +typedef enum { BFD_EVENT_RESCHEDULE = 1, BFD_EVENT_NEW_SESSION, diff --git a/src/vnet/bier/bier_fmask.h b/src/vnet/bier/bier_fmask.h index 0666605c23f..2317a5094aa 100644 --- a/src/vnet/bier/bier_fmask.h +++ b/src/vnet/bier/bier_fmask.h @@ -171,7 +171,7 @@ extern void bier_fmask_encode (index_t bfmi, /* * provided for fast data-path access */ -bier_fmask_t *bier_fmask_pool; +extern bier_fmask_t *bier_fmask_pool; static inline bier_fmask_t * bier_fmask_get (u32 index) diff --git a/src/vnet/bonding/node.c b/src/vnet/bonding/node.c index 80013428101..636146f8449 100644 --- a/src/vnet/bonding/node.c +++ b/src/vnet/bonding/node.c @@ -21,7 +21,9 @@ #include <vnet/snap/snap.h> #include <vnet/bonding/node.h> +#ifndef CLIB_MARCH_VARIANT bond_main_t bond_main; +#endif /* CLIB_MARCH_VARIANT */ #define foreach_bond_input_error \ _(NONE, "no error") \ diff --git a/src/vnet/bonding/node.h b/src/vnet/bonding/node.h index 15640071aa8..9a194b8db0b 100644 --- a/src/vnet/bonding/node.h +++ b/src/vnet/bonding/node.h @@ -70,7 +70,7 @@ typedef enum #undef _ } bond_load_balance_t; -enum +typedef enum { BOND_SEND_GARP_NA = 1, } bond_send_garp_na_process_event_t; diff --git a/src/vnet/devices/pipe/pipe_api.c b/src/vnet/devices/pipe/pipe_api.c index cb67d1f0404..1dcb8bc76c6 100644 --- a/src/vnet/devices/pipe/pipe_api.c +++ b/src/vnet/devices/pipe/pipe_api.c @@ -36,7 +36,7 @@ #undef vl_printfun #include <vlibapi/api_helper_macros.h> -vpe_api_main_t vpe_api_main; +extern vpe_api_main_t vpe_api_main; #define foreach_vpe_api_msg \ _(PIPE_CREATE, pipe_create) \ diff --git a/src/vnet/devices/virtio/vhost_user_input.c b/src/vnet/devices/virtio/vhost_user_input.c index 3c3d48e9ef4..286fa7ed744 100644 --- a/src/vnet/devices/virtio/vhost_user_input.c +++ b/src/vnet/devices/virtio/vhost_user_input.c @@ -65,7 +65,7 @@ */ #define VHOST_USER_RX_COPY_THRESHOLD 64 -vlib_node_registration_t vhost_user_input_node; +extern vlib_node_registration_t vhost_user_input_node; #define foreach_vhost_user_input_func_error \ _(NO_ERROR, "no error") \ diff --git a/src/vnet/devices/virtio/vhost_user_output.c b/src/vnet/devices/virtio/vhost_user_output.c index 4fbd63ea708..c0c54d1b13a 100644 --- a/src/vnet/devices/virtio/vhost_user_output.c +++ b/src/vnet/devices/virtio/vhost_user_output.c @@ -53,7 +53,7 @@ */ #define VHOST_USER_TX_COPY_THRESHOLD (VHOST_USER_COPY_ARRAY_N - 40) -vnet_device_class_t vhost_user_device_class; +extern vnet_device_class_t vhost_user_device_class; #define foreach_vhost_user_tx_func_error \ _(NONE, "no error") \ diff --git a/src/vnet/dpo/dvr_dpo.c b/src/vnet/dpo/dvr_dpo.c index 4b440f81c59..a362d23e890 100644 --- a/src/vnet/dpo/dvr_dpo.c +++ b/src/vnet/dpo/dvr_dpo.c @@ -18,6 +18,8 @@ #include <vnet/ip/ip.h> #include <vnet/ethernet/ethernet.h> +dvr_dpo_t *dvr_dpo_pool; + /** * The 'DB' of DVR DPOs. * There is one per-interface per-L3 proto, so this is a per-interface vector diff --git a/src/vnet/dpo/dvr_dpo.h b/src/vnet/dpo/dvr_dpo.h index 15fe113c596..669c49201c8 100644 --- a/src/vnet/dpo/dvr_dpo.h +++ b/src/vnet/dpo/dvr_dpo.h @@ -54,7 +54,7 @@ extern void dvr_dpo_module_init(void); /** * @brief pool of all interface DPOs */ -dvr_dpo_t *dvr_dpo_pool; +extern dvr_dpo_t *dvr_dpo_pool; static inline dvr_dpo_t * dvr_dpo_get (index_t index) diff --git a/src/vnet/dpo/interface_rx_dpo.c b/src/vnet/dpo/interface_rx_dpo.c index 82767e73fc7..90868b953ca 100644 --- a/src/vnet/dpo/interface_rx_dpo.c +++ b/src/vnet/dpo/interface_rx_dpo.c @@ -17,6 +17,8 @@ #include <vnet/fib/fib_node.h> #include <vnet/l2/l2_input.h> +interface_rx_dpo_t *interface_rx_dpo_pool; + /* * The 'DB' of interface DPOs. * There is only one per-interface per-protocol, so this is a per-interface diff --git a/src/vnet/dpo/interface_rx_dpo.h b/src/vnet/dpo/interface_rx_dpo.h index edecce08675..d3406a22387 100644 --- a/src/vnet/dpo/interface_rx_dpo.h +++ b/src/vnet/dpo/interface_rx_dpo.h @@ -58,7 +58,7 @@ extern void interface_rx_dpo_module_init(void); /** * @brief pool of all interface DPOs */ -interface_rx_dpo_t *interface_rx_dpo_pool; +extern interface_rx_dpo_t *interface_rx_dpo_pool; static inline interface_rx_dpo_t * interface_rx_dpo_get (index_t index) diff --git a/src/vnet/dpo/l3_proxy_dpo.h b/src/vnet/dpo/l3_proxy_dpo.h index fcc28b3bf97..3a578e29924 100644 --- a/src/vnet/dpo/l3_proxy_dpo.h +++ b/src/vnet/dpo/l3_proxy_dpo.h @@ -52,7 +52,7 @@ extern void l3_proxy_dpo_module_init(void); /** * @brief pool of all l3_proxy DPOs */ -l3_proxy_dpo_t *l3_proxy_dpo_pool; +extern l3_proxy_dpo_t *l3_proxy_dpo_pool; static inline l3_proxy_dpo_t * l3_proxy_dpo_get (index_t index) diff --git a/src/vnet/dpo/receive_dpo.h b/src/vnet/dpo/receive_dpo.h index ee3c7836aff..9459fbcc279 100644 --- a/src/vnet/dpo/receive_dpo.h +++ b/src/vnet/dpo/receive_dpo.h @@ -59,7 +59,7 @@ extern void receive_dpo_module_init(void); /** * @brief pool of all receive DPOs */ -receive_dpo_t *receive_dpo_pool; +extern receive_dpo_t *receive_dpo_pool; static inline receive_dpo_t * receive_dpo_get (index_t index) diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index 5fc2552f5ca..b3ae29a2790 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -900,7 +900,9 @@ ip4_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add) VNET_SW_INTERFACE_ADD_DEL_FUNCTION (ip4_sw_interface_add_del); /* Global IP4 main. */ +#ifndef CLIB_MARCH_VARIANT ip4_main_t ip4_main; +#endif /* CLIB_MARCH_VARIANT */ static clib_error_t * ip4_lookup_init (vlib_main_t * vm) diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c index 57fd6081af5..2c3879b13d1 100644 --- a/src/vnet/ip/ip6_forward.c +++ b/src/vnet/ip/ip6_forward.c @@ -2074,7 +2074,9 @@ VLIB_REGISTER_NODE (ip6_mcast_midchain_node) = /* * Hop-by-Hop handling */ +#ifndef CLIB_MARCH_VARIANT ip6_hop_by_hop_main_t ip6_hop_by_hop_main; +#endif /* CLIB_MARCH_VARIANT */ #define foreach_ip6_hop_by_hop_error \ _(PROCESSED, "pkts with ip6 hop-by-hop options") \ @@ -2102,7 +2104,7 @@ typedef struct u8 option_data[256]; } ip6_hop_by_hop_trace_t; -vlib_node_registration_t ip6_hop_by_hop_node; +extern vlib_node_registration_t ip6_hop_by_hop_node; static char *ip6_hop_by_hop_error_strings[] = { #define _(sym,string) string, diff --git a/src/vnet/ipsec/esp_encrypt.c b/src/vnet/ipsec/esp_encrypt.c index 4b325e08b5f..e1690439c88 100644 --- a/src/vnet/ipsec/esp_encrypt.c +++ b/src/vnet/ipsec/esp_encrypt.c @@ -23,7 +23,9 @@ #include <vnet/ipsec/ipsec.h> #include <vnet/ipsec/esp.h> +#ifndef CLIB_MARCH_VARIANT ipsec_proto_main_t ipsec_proto_main; +#endif /* CLIB_MARCH_VARIANT */ #define foreach_esp_encrypt_next \ _(DROP, "error-drop") \ diff --git a/src/vnet/l2/l2_learn.h b/src/vnet/l2/l2_learn.h index c1071450852..58e19babc6e 100644 --- a/src/vnet/l2/l2_learn.h +++ b/src/vnet/l2/l2_learn.h @@ -52,7 +52,7 @@ extern l2learn_main_t l2learn_main; extern vlib_node_registration_t l2fib_mac_age_scanner_process_node; -enum +typedef enum { L2_MAC_AGE_PROCESS_EVENT_START = 1, L2_MAC_AGE_PROCESS_EVENT_STOP = 2, diff --git a/src/vnet/l2/l2_patch.c b/src/vnet/l2/l2_patch.c index e2d2a679662..54286c23d72 100644 --- a/src/vnet/l2/l2_patch.c +++ b/src/vnet/l2/l2_patch.c @@ -49,7 +49,7 @@ format_l2_patch_trace (u8 * s, va_list * args) return s; } -l2_patch_main_t l2_patch_main; +static l2_patch_main_t l2_patch_main; static vlib_node_registration_t l2_patch_node; diff --git a/src/vnet/lldp/lldp_node.h b/src/vnet/lldp/lldp_node.h index eca1d12e169..f9bc9599827 100644 --- a/src/vnet/lldp/lldp_node.h +++ b/src/vnet/lldp/lldp_node.h @@ -131,7 +131,7 @@ typedef struct u8 data[400]; } lldp_input_trace_t; -enum +typedef enum { LLDP_EVENT_RESCHEDULE = 1, } lldp_process_event_t; diff --git a/src/vnet/mpls/mpls_lookup.h b/src/vnet/mpls/mpls_lookup.h index 95558e05a4e..17f9468f0ac 100644 --- a/src/vnet/mpls/mpls_lookup.h +++ b/src/vnet/mpls/mpls_lookup.h @@ -23,7 +23,7 @@ /** * The arc/edge from the MPLS lookup node to the MPLS replicate node */ -u32 mpls_lookup_to_replicate_edge; +extern u32 mpls_lookup_to_replicate_edge; /** * Enum of statically configred MPLS lookup next nodes diff --git a/src/vnet/session/session_lookup.h b/src/vnet/session/session_lookup.h index c45794dfe71..8d7701da19e 100644 --- a/src/vnet/session/session_lookup.h +++ b/src/vnet/session/session_lookup.h @@ -96,7 +96,7 @@ void session_lookup_dump_rules_table (u32 fib_index, u8 fib_proto, void session_lookup_dump_local_rules_table (u32 fib_index, u8 fib_proto, u8 transport_proto); -enum _session_rule_scope +typedef enum _session_rule_scope { SESSION_RULE_SCOPE_GLOBAL = 1, SESSION_RULE_SCOPE_LOCAL = 2, |