[oe] [PATCH][meta-networking] net-snmp: make it be able to be compiled by gcc5 with "-O0"

rongqing.li at windriver.com rongqing.li at windriver.com
Mon Sep 14 07:37:28 UTC 2015


From: Roy Li <rongqing.li at windriver.com>

Signed-off-by: Roy Li <rongqing.li at windriver.com>
---
 ...-functions-work-with-both-gnu11-and-gnu89.patch | 85 ++++++++++++++++++++++
 .../recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb |  1 +
 2 files changed, 86 insertions(+)
 create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get-inline-functions-work-with-both-gnu11-and-gnu89.patch

diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get-inline-functions-work-with-both-gnu11-and-gnu89.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get-inline-functions-work-with-both-gnu11-and-gnu89.patch
new file mode 100644
index 0000000..2d7ba57
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get-inline-functions-work-with-both-gnu11-and-gnu89.patch
@@ -0,0 +1,85 @@
+From 6f319d981ee190c7e858a4b0382617c469cfa77a Mon Sep 17 00:00:00 2001
+From: Roy Li <rongqing.li at windriver.com>
+Date: Mon, 14 Sep 2015 13:52:12 +0800
+Subject: [PATCH] get inline functions work with both gnu11 and gnu89
+
+Upstream-status: Pending
+
+After gcc upgraded to gcc5, and if the codes are compiled without optimization(-O0),
+and the below error will happen:
+
+./.libs/libnetsnmpagent.so: undefined reference to `netsnmp_subtree_change_prev'
+./.libs/libnetsnmpagent.so: undefined reference to `netsnmp_table_dataset_delete_data'
+./.libs/libnetsnmpagent.so: undefined reference to `netsnmp_subtree_change_next'
+collect2: error: ld returned 1 exit status
+
+gcc5 defaults to -std=gnu11 instead of -std=gnu89, and it requires that exactly one C
+source file has the callable copy of the inline function. Consider the following
+program:
+
+  inline int
+  foo (void)
+  {
+    return 42;
+  }
+
+  int
+  main (void)
+  {
+    return foo ();
+  }
+
+The program above will not link with the C99 inline semantics, because no out-of-line
+function foo is generated. To fix this, either mark the function foo as static, or
+add the following declaration:
+  static inline int foo (void);
+
+more information refer to: https://gcc.gnu.org/gcc-5/porting_to.html;
+
+but the use of "extern inline" will lead to the compilation issue if gcc is not
+gcc5, so replace inline with "static inline"
+
+Signed-off-by: Roy Li <rongqing.li at windriver.com>
+---
+ agent/agent_registry.c        | 4 ++--
+ agent/helpers/table_dataset.c | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/agent/agent_registry.c b/agent/agent_registry.c
+index 1e2482a..3f0aa12 100644
+--- a/agent/agent_registry.c
++++ b/agent/agent_registry.c
+@@ -528,7 +528,7 @@ netsnmp_subtree_deepcopy(netsnmp_subtree *a)
+ /** @private
+  *  Replaces next subtree pointer in given subtree.
+  */
+-NETSNMP_INLINE void
++NETSNMP_STATIC_INLINE void
+ netsnmp_subtree_change_next(netsnmp_subtree *ptr, netsnmp_subtree *thenext)
+ {
+     ptr->next = thenext;
+@@ -543,7 +543,7 @@ netsnmp_subtree_change_next(netsnmp_subtree *ptr, netsnmp_subtree *thenext)
+ /** @private
+  *  Replaces previous subtree pointer in given subtree.
+  */
+-NETSNMP_INLINE void
++NETSNMP_STATIC_INLINE void
+ netsnmp_subtree_change_prev(netsnmp_subtree *ptr, netsnmp_subtree *theprev)
+ {
+     ptr->prev = theprev;
+diff --git a/agent/helpers/table_dataset.c b/agent/helpers/table_dataset.c
+index 0949a8a..d993993 100644
+--- a/agent/helpers/table_dataset.c
++++ b/agent/helpers/table_dataset.c
+@@ -107,7 +107,7 @@ netsnmp_init_table_dataset(void) {
+ /** deletes a single dataset table data.
+  *  returns the (possibly still good) next pointer of the deleted data object.
+  */
+-NETSNMP_INLINE netsnmp_table_data_set_storage *
++NETSNMP_STATIC_INLINE netsnmp_table_data_set_storage *
+ netsnmp_table_dataset_delete_data(netsnmp_table_data_set_storage *data)
+ {
+     netsnmp_table_data_set_storage *nextPtr = NULL;
+-- 
+1.9.1
+
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb
index 464473e..f3fa3ba 100644
--- a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb
@@ -23,6 +23,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.zip \
         file://0001-Fix-CVE-2014-2285.patch \
         file://dont-return-incompletely-parsed-varbinds.patch \
         file://net-snmp-5.7.2-fix-mib-timeout-values.patch \
+        file://0001-get-inline-functions-work-with-both-gnu11-and-gnu89.patch \
 "
 
 SRC_URI[md5sum] = "a2c83518648b0f2a5d378625e45c0e18"
-- 
1.9.1




More information about the Openembedded-devel mailing list