Skip to contentSkip to conversation

netplug: add two patches to fix musl build issues

PATCH New Thomas Petazzoni 2 participants 3 messages Aug 5, 2016 – Aug 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netplug: add two patches to fix musl build issues

This commit adds two patches to netplug that are needed for this package to build with musl:

- One patch to add a missing header inclusion
- One patch to fix a conflicting prototype on __assert_fail().

Fixes:

http://autobuild.buildroot.net/results/c2a5dfedba46cc8eb3d0c5c43f1f76fe0bb1805f/

---
 .../netplug/0002-add-missing-time-include.patch    | 20 +++++++++
 package/netplug/0003-remove-assert-fail.patch      | 51 ++++++++++++++++++++++
 2 files changed, 71 insertions(+)
 create mode 100644 package/netplug/0002-add-missing-time-include.patch
 create mode 100644 package/netplug/0003-remove-assert-fail.patch
package/netplug/0002-add-missing-time-include.patch new file +20 -0
new file mode 100644
index 0000000..f204c92
@@ -0,0 +1,20 @@
+Add missing <time.h> include
+
+netplug.h uses time_t, so it must include <time.h>. This fixes a build
+issue with the musl C library.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+Index: b/netplug.h
+===================================================================
+--- a/netplug.h
++++ b/netplug.h
+@@ -20,7 +20,7 @@
+ #ifndef __netplug_h
+ #define __netplug_h
+ 
+-
++#include <time.h>
+ #include <asm/types.h>
+ #include <sys/socket.h>
+ #include <linux/netlink.h>
package/netplug/0003-remove-assert-fail.patch new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 netplug: add two patches to fix musl build issues

Thomas, All,

On 2016-08-05 22:52 +0200, Thomas Petazzoni spake thusly:

Quoted 11 lines

This commit adds two patches to netplug that are needed for this package to build with musl:

- One patch to add a missing header inclusion
- One patch to fix a conflicting prototype on __assert_fail().

Fixes:

http://autobuild.buildroot.net/results/c2a5dfedba46cc8eb3d0c5c43f1f76fe0bb1805f/

Regards,
Yann E. MORIN.

Quoted 97 lines
---
 .../netplug/0002-add-missing-time-include.patch    | 20 +++++++++
 package/netplug/0003-remove-assert-fail.patch      | 51 ++++++++++++++++++++++
 2 files changed, 71 insertions(+)
 create mode 100644 package/netplug/0002-add-missing-time-include.patch
 create mode 100644 package/netplug/0003-remove-assert-fail.patch
package/netplug/0002-add-missing-time-include.patch new file +20 -0
new file mode 100644
index 0000000..f204c92
@@ -0,0 +1,20 @@
+Add missing <time.h> include
+
+netplug.h uses time_t, so it must include <time.h>. This fixes a build
+issue with the musl C library.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+Index: b/netplug.h
+===================================================================
+--- a/netplug.h
++++ b/netplug.h
+@@ -20,7 +20,7 @@
+ #ifndef __netplug_h
+ #define __netplug_h
+ 
+-
++#include <time.h>
+ #include <asm/types.h>
+ #include <sys/socket.h>
+ #include <linux/netlink.h>
package/netplug/0003-remove-assert-fail.patch new file +51 -0
new file mode 100644
index 0000000..635c462
@@ -0,0 +1,51 @@
+Remove __assert_fail()
+
+The netplug code uses the assert() macro in various places. In glibc
+internally, assert() uses a function called __assert_fail() to print a
+message and abort. Relying on internal glibc details, netplug
+re-defines __assert_fail() in the hope that it will get called instead
+of glibc internal version.
+
+This attempt:
+
+ * Doesn't work with uClibc, which doesn't use any __assert_fail()
+   function at all. It doesn't fail to build, but it is entirely
+   useless.
+
+ * Fails to build with musl, which also defines __assert_fail(), but
+   with a different prototype.
+
+We simply remove the __assert_fail() implementation, so that the C
+library implementation of assert() just does its normal work. The only
+functionality lost is that the message is displayed on the standard
+output rather than in netplug's logs (and this was only working with
+glibc anyway).
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+Index: b/lib.c
+===================================================================
+--- a/lib.c
++++ b/lib.c
+@@ -199,21 +199,6 @@
+     return x;
+ }
+ 
+-
+-void
+-__assert_fail(const char *assertion, const char *file,
+-              unsigned int line, const char *function)
+-{
+-    do_log(LOG_CRIT, "%s:%u: %s%sAssertion `%s' failed",
+-           file, line,
+-           function ? function : "",
+-           function ? ": " : "",
+-           assertion);
+-
+-    abort();
+-}
+-
+-
+ /*
+  * Local variables:
+  * c-file-style: "stroustrup"
Signature · 6 lines
2.7.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
author Applied
#2 lore raw

PATCH 1/1 netplug: add two patches to fix musl build issues

In reply to Thomas Petazzoni

Hello,

Quoted 10 lines · Thomas Petazzoni

This commit adds two patches to netplug that are needed for this package to build with musl:

- One patch to add a missing header inclusion
- One patch to fix a conflicting prototype on __assert_fail().

Fixes:

http://autobuild.buildroot.net/results/c2a5dfedba46cc8eb3d0c5c43f1f76fe0bb1805f/

Quoted 7 lines
---
 .../netplug/0002-add-missing-time-include.patch    | 20 +++++++++
 package/netplug/0003-remove-assert-fail.patch      | 51 ++++++++++++++++++++++
 2 files changed, 71 insertions(+)
 create mode 100644 package/netplug/0002-add-missing-time-include.patch
 create mode 100644 package/netplug/0003-remove-assert-fail.patch

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com