Skip to contentSkip to conversation

net-snmp: make it be able to be compiled by gcc5 with "-O0"

PATCH Superseded [email protected] 2 participants 2 messages Sep 14, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net-snmp: make it be able to be compiled by gcc5 with "-O0"

From: Roy Li <[email protected]>

---
 ...-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
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get-inline-functions-work-with-both-gnu11-and-gnu89.patch new file +85 -0
new file mode 100644
index 0000000..2d7ba57
@@ -0,0 +1,85 @@
+From 6f319d981ee190c7e858a4b0382617c469cfa77a Mon Sep 17 00:00:00 2001
+From: Roy Li <[email protected]>
+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 <[email protected]>
+---
+ 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
+
meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb +1 -0
index 464473e..f3fa3ba 100644
@@ -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"
Signature · 1 line
1.9.1
#1 lore raw
Quoted 1 line · On Mon, Sep 14, 2015 at 03:37:28PM +0800, [email protected] wrote:

From: Roy Li <[email protected]>

Upgrade to 5.7.2 was merged few days ago:

t 858d7a83cbad77eb6d0b2edadcf2269a3c85e234

Author:     Li xin <[email protected]>
AuthorDate: Fri Aug 21 18:08:04 2015 +0800
Commit:     Joe MacDonald <[email protected]>
CommitDate: Fri Sep 11 11:52:15 2015 -0400
    net-snmp: upgrade 5.7.2.1 -> 5.7.3

Check if this is still needed and next time please always rebase the patches before sending them.

Quoted 119 lines
---
 ...-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
meta-networking/recipes-protocols/net-snmp/net-snmp/0001-get-inline-functions-work-with-both-gnu11-and-gnu89.patch new file +85 -0
new file mode 100644
index 0000000..2d7ba57
@@ -0,0 +1,85 @@
+From 6f319d981ee190c7e858a4b0382617c469cfa77a Mon Sep 17 00:00:00 2001
+From: Roy Li <[email protected]>
+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 <[email protected]>
+---
+ 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
+
meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb +1 -0
index 464473e..f3fa3ba 100644
@@ -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"
Signature · 7 lines
1.9.1

-- 
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]