All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][meta-networking] net-snmp: make it be able to be compiled by gcc5 with "-O0"
@ 2015-09-14  7:37 rongqing.li
  2015-09-14 10:07 ` Martin Jansa
  0 siblings, 1 reply; 2+ messages in thread
From: rongqing.li @ 2015-09-14  7:37 UTC (permalink / raw)
  To: openembedded-devel

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

Signed-off-by: Roy Li <rongqing.li@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@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@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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][meta-networking] net-snmp: make it be able to be compiled by gcc5 with "-O0"
  2015-09-14  7:37 [PATCH][meta-networking] net-snmp: make it be able to be compiled by gcc5 with "-O0" rongqing.li
@ 2015-09-14 10:07 ` Martin Jansa
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Jansa @ 2015-09-14 10:07 UTC (permalink / raw)
  To: openembedded-devel

[-- Attachment #1: Type: text/plain, Size: 5682 bytes --]

On Mon, Sep 14, 2015 at 03:37:28PM +0800, rongqing.li@windriver.com wrote:
> From: Roy Li <rongqing.li@windriver.com>

Upgrade to 5.7.2 was merged few days ago:

t 858d7a83cbad77eb6d0b2edadcf2269a3c85e234
Author:     Li xin <lixin.fnst@cn.fujitsu.com>
AuthorDate: Fri Aug 21 18:08:04 2015 +0800
Commit:     Joe MacDonald <joe_macdonald@mentor.com>
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.

> 
> Signed-off-by: Roy Li <rongqing.li@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@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@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
> 
> -- 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-14 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-14  7:37 [PATCH][meta-networking] net-snmp: make it be able to be compiled by gcc5 with "-O0" rongqing.li
2015-09-14 10:07 ` Martin Jansa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.