Skip to contentSkip to conversation

package/socat: fix build issue

PATCH New Romain Naour 2 participants 3 messages Aug 28, 2016 – Sep 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/socat: fix build issue

Fix two build issue when socat is build with musl:
- Set NETDB_INTERNAL locally since it's not provided by musl
- remove if_tun.h kernel header

Fixes:
http://autobuild.buildroot.net/results/029/02977d3844ef62b1e9cbfbab244593632757c5e2

---
 package/socat/0003-compat-set-NETDB_INTERNAL.patch | 35 +++++++++
 ...004-xio-tun-remove-if_tun.h-kernel-header.patch | 91 ++++++++++++++++++++++
 2 files changed, 126 insertions(+)
 create mode 100644 package/socat/0003-compat-set-NETDB_INTERNAL.patch
 create mode 100644 package/socat/0004-xio-tun-remove-if_tun.h-kernel-header.patch
package/socat/0003-compat-set-NETDB_INTERNAL.patch new file +35 -0
new file mode 100644
index 0000000..da31073
@@ -0,0 +1,35 @@
+From e7804d1750652e39c7a5803d360b29b2637a695f Mon Sep 17 00:00:00 2001
+From: Romain Naour <[email protected]>
+Date: Sun, 28 Aug 2016 21:04:01 +0200
+Subject: [PATCH] compat: set NETDB_INTERNAL
+
+Musl doesn't provide NETDB_INTERNAL which is defined in resolv/netdb.h
+in Glibc [1].
+
+Set NETDB_INTERNAL to -1 locally if not already defined.
+Based on [2].
+
+[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=resolv/netdb.h;h=3aba530932c7a62a4f23e3193e9186da677f552b;hb=fdfc9260b61d3d72541f18104d24c7bcb0ce5ca2#l74
+[2] http://git.alpinelinux.org/cgit/aports/tree/main/socat/netdb-internal.patch?id=5a45173b50892cb634197c30b3506ebff98d3b7d
+
+Signed-off-by: Romain Naour <[email protected]>
+---
+ compat.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/compat.h b/compat.h
+index 19a929f..4f5ee6d 100644
+--- a/compat.h
++++ b/compat.h
+@@ -666,6 +666,8 @@ typedef int sig_atomic_t;
+ 
+ #if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
+ #  define NETDB_INTERNAL h_NETDB_INTERNAL
++#elif !defined(NETDB_INTERNAL)
++#  define NETDB_INTERNAL (-1)
+ #endif
+ 
+ #ifndef INET_ADDRSTRLEN
+-- 
+2.5.5
+
package/socat/0004-xio-tun-remove-if_tun.h-kernel-header.patch new file +91 -0

91 lines not on this page · raw message

Signature · 1 line
2.5.5
#1 lore raw

PATCH 1/1 package/socat: fix build issue

Hello,

Quoted 26 lines · Romain Naour
package/socat/0003-compat-set-NETDB_INTERNAL.patch new file +20 -0
new file mode 100644
index 0000000..da31073
@@ -0,0 +1,35 @@
+From e7804d1750652e39c7a5803d360b29b2637a695f Mon Sep 17 00:00:00 2001
+From: Romain Naour <[email protected]>
+Date: Sun, 28 Aug 2016 21:04:01 +0200
+Subject: [PATCH] compat: set NETDB_INTERNAL
+
+Musl doesn't provide NETDB_INTERNAL which is defined in resolv/netdb.h
+in Glibc [1].
+
+Set NETDB_INTERNAL to -1 locally if not already defined.
+Based on [2].
+
+[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=resolv/netdb.h;h=3aba530932c7a62a4f23e3193e9186da677f552b;hb=fdfc9260b61d3d72541f18104d24c7bcb0ce5ca2#l74
+[2] http://git.alpinelinux.org/cgit/aports/tree/main/socat/netdb-internal.patch?id=5a45173b50892cb634197c30b3506ebff98d3b7d
+
+Signed-off-by: Romain Naour <[email protected]>
+---
+ compat.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/compat.h b/compat.h

package/socat/0003-compat-set-NETDB_INTERNAL.patch line 30

Quoted 10 lines
package/socat/0003-compat-set-NETDB_INTERNAL.patch new file +10 -0
+index 19a929f..4f5ee6d 100644
+--- a/compat.h
++++ b/compat.h
+@@ -666,6 +666,8 @@ typedef int sig_atomic_t;
+ 
+ #if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
+ #  define NETDB_INTERNAL h_NETDB_INTERNAL
++#elif !defined(NETDB_INTERNAL)
++#  define NETDB_INTERNAL (-1)
+ #endif

I am not a big fan of this solution, as it's really a hack: musl will never set h_errno to NETDB_INTERNAL, so it's a bit weird to define it to -1.

But maybe that's the easiest solution. Have you tried talking with upstream about this?

package/socat/0003-compat-set-NETDB_INTERNAL.patch

Quoted 6 lines
package/socat/0003-compat-set-NETDB_INTERNAL.patch new file +6 -0
++/* TUNSETIFF flags from if_tun.h kernel header */
++#define IFF_TUN		0x0001
++#define IFF_TAP		0x0002
++#define IFF_NO_PI	0x1000
++
++#define TUNSETIFF	_IOW('T', 202, int)

I know doing this is what the musl developers recommend, but it is _really_ silly that we have to duplicate stuff from the kernel headers, while the kernel headers (and specifically their uapi part) are part of the toolchain headers... precisely for the purpose of allowing userspace to use the types/definitions of the kernel to userspace interface.

Thanks,

Thomas

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

PATCH 1/1 package/socat: fix build issue

In reply to Romain Naour

Hello,

Quoted 7 lines · Romain Naour

Fix two build issue when socat is build with musl:
- Set NETDB_INTERNAL locally since it's not provided by musl
- remove if_tun.h kernel header

Fixes:
http://autobuild.buildroot.net/results/029/02977d3844ef62b1e9cbfbab244593632757c5e2

Quoted 7 lines
---
 package/socat/0003-compat-set-NETDB_INTERNAL.patch | 35 +++++++++
 ...004-xio-tun-remove-if_tun.h-kernel-header.patch | 91 ++++++++++++++++++++++
 2 files changed, 126 insertions(+)
 create mode 100644 package/socat/0003-compat-set-NETDB_INTERNAL.patch
 create mode 100644 package/socat/0004-xio-tun-remove-if_tun.h-kernel-header.patch

Even though I am not too happy with the solutions, it's probably the simplest we can do, so I've applied. Could you try to submit them upstream?

Thanks!

Thomas

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