Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] libknet1: musl fix
@ 2019-09-04 22:01 voidlinux-github
  2019-09-04 22:31 ` [PR PATCH] [Updated] " voidlinux-github
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-04 22:01 UTC (permalink / raw)
  To: ml

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

There is a new pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 9230 bytes --]

From e5c58446d5eaef748e8196ba7e1ab557865fb4fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  17 +-
 2 files changed, 219 insertions(+), 8 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..3be80dbc070 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -2,15 +2,14 @@
 # only library and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
 hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
 makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+ libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,11 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+#if [ "$XBPS_TARGET_LIBC" = musl ]; then
+#	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
+#fi
+
+patch_args='-Np1'
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
  2019-09-04 22:31 ` [PR PATCH] [Updated] " voidlinux-github
@ 2019-09-04 22:31 ` voidlinux-github
  2019-09-04 23:05 ` voidlinux-github
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-04 22:31 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11010 bytes --]

From 4abae06f0fb9a202c66b89ac973dbf27452ba6af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  51 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 248 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..73a48c9876c 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
-# Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# Template file for 'libknet1' and 'libnozzle1' libraries
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
 hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,11 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+#if [ "$XBPS_TARGET_LIBC" = musl ]; then
+#	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
+#fi
+
+patch_args='-Np1'
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +32,29 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="userland wrapper around kernel tap devices"
+	pkg_install() {
+		vdoc README	
+		vmove "usr/include/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
@ 2019-09-04 22:31 ` voidlinux-github
  2019-09-04 22:31 ` voidlinux-github
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-04 22:31 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11010 bytes --]

From 4abae06f0fb9a202c66b89ac973dbf27452ba6af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  51 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 248 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..73a48c9876c 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
-# Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# Template file for 'libknet1' and 'libnozzle1' libraries
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
 hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,11 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+#if [ "$XBPS_TARGET_LIBC" = musl ]; then
+#	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
+#fi
+
+patch_args='-Np1'
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +32,29 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="userland wrapper around kernel tap devices"
+	pkg_install() {
+		vdoc README	
+		vmove "usr/include/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
  2019-09-04 22:31 ` [PR PATCH] [Updated] " voidlinux-github
  2019-09-04 22:31 ` voidlinux-github
@ 2019-09-04 23:05 ` voidlinux-github
  2019-09-04 23:05 ` voidlinux-github
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-04 23:05 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11089 bytes --]

From 67a15a8122fdbdcedd1b25ddf9d8a32e49633485 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  56 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 253 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..a070f41a6b2 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,16 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+#if [ "$XBPS_TARGET_LIBC" = musl ]; then
+#	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
+#fi
+
+patch_args='-Np1'
+
+pre_configure() {
+	aclocal --install -Im4
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +37,29 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vdoc README
+		vmove "usr/include/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (2 preceding siblings ...)
  2019-09-04 23:05 ` voidlinux-github
@ 2019-09-04 23:05 ` voidlinux-github
  2019-09-04 23:37 ` voidlinux-github
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-04 23:05 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11089 bytes --]

From 67a15a8122fdbdcedd1b25ddf9d8a32e49633485 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  56 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 253 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..a070f41a6b2 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,16 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+#if [ "$XBPS_TARGET_LIBC" = musl ]; then
+#	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
+#fi
+
+patch_args='-Np1'
+
+pre_configure() {
+	aclocal --install -Im4
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +37,29 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vdoc README
+		vmove "usr/include/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (4 preceding siblings ...)
  2019-09-04 23:37 ` voidlinux-github
@ 2019-09-04 23:37 ` voidlinux-github
  2019-09-05  9:11 ` voidlinux-github
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-04 23:37 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11090 bytes --]

From e39b439c77cb68475dfb1ef1434f792eda41d95f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  56 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 253 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..bfb6d477504 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,16 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+#if [ "$XBPS_TARGET_LIBC" = musl ]; then
+#	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
+#fi
+
+patch_args='-Np1'
+
+pre_configure() {
+#	aclocal --install -Im4
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +37,29 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vdoc README
+		vmove "usr/include/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (3 preceding siblings ...)
  2019-09-04 23:05 ` voidlinux-github
@ 2019-09-04 23:37 ` voidlinux-github
  2019-09-04 23:37 ` voidlinux-github
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-04 23:37 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11090 bytes --]

From e39b439c77cb68475dfb1ef1434f792eda41d95f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  56 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 253 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..bfb6d477504 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,16 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+#if [ "$XBPS_TARGET_LIBC" = musl ]; then
+#	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
+#fi
+
+patch_args='-Np1'
+
+pre_configure() {
+#	aclocal --install -Im4
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +37,29 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vdoc README
+		vmove "usr/include/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (5 preceding siblings ...)
  2019-09-04 23:37 ` voidlinux-github
@ 2019-09-05  9:11 ` voidlinux-github
  2019-09-05  9:11 ` voidlinux-github
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-05  9:11 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11098 bytes --]

From cffffe58950cf7ce64dddd925a8748941fa60d8f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  56 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 253 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..ea87c510409 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libtool libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,16 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+#if [ "$XBPS_TARGET_LIBC" = musl ]; then
+#	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
+#fi
+
+patch_args='-Np1'
+
+pre_configure() {
+#	aclocal --install -Im4
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +37,29 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vdoc README
+		vmove "usr/include/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (6 preceding siblings ...)
  2019-09-05  9:11 ` voidlinux-github
@ 2019-09-05  9:11 ` voidlinux-github
  2019-09-05 10:26 ` voidlinux-github
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-05  9:11 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11098 bytes --]

From cffffe58950cf7ce64dddd925a8748941fa60d8f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  56 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 253 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..ea87c510409 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libtool libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,16 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+#if [ "$XBPS_TARGET_LIBC" = musl ]; then
+#	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
+#fi
+
+patch_args='-Np1'
+
+pre_configure() {
+#	aclocal --install -Im4
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +37,29 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vdoc README
+		vmove "usr/include/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (8 preceding siblings ...)
  2019-09-05 10:26 ` voidlinux-github
@ 2019-09-05 10:26 ` voidlinux-github
  2019-09-05 10:58 ` voidlinux-github
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-05 10:26 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 10940 bytes --]

From 761e7f78ab917f476aca1871b12861d239dee13d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  50 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 247 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..819ea5e0a12 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libtool libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,11 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+patch_args='-Np1'
+
+pre_configure() {
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +32,28 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vmove "usr/lib/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (7 preceding siblings ...)
  2019-09-05  9:11 ` voidlinux-github
@ 2019-09-05 10:26 ` voidlinux-github
  2019-09-05 10:26 ` voidlinux-github
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-05 10:26 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 10940 bytes --]

From 761e7f78ab917f476aca1871b12861d239dee13d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  50 ++++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 4 files changed, 247 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..819ea5e0a12 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libtool libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,11 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+patch_args='-Np1'
+
+pre_configure() {
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +32,28 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vmove "usr/lib/libnozzle.so.*"
+	}
+}
+
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (9 preceding siblings ...)
  2019-09-05 10:26 ` voidlinux-github
@ 2019-09-05 10:58 ` voidlinux-github
  2019-09-05 10:58 ` voidlinux-github
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-05 10:58 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

I also "enabled" building of libnozzle libraries from kronosnet, so it does not diverge from other distros.

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11318 bytes --]

From 39b2066a55eecdcb628dd01112914cb3ea4ec4d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 common/shlibs                             |   1 +
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  49 +++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 5 files changed, 247 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/common/shlibs b/common/shlibs
index 57f7025459d..5ba121dc2fd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3507,3 +3507,4 @@ libknet.so.1 libknet1-1.11_1
 libdrumstick-file.so.1 drumstick-1.1.2_1
 libdrumstick-alsa.so.1 drumstick-1.1.2_1
 libdrumstick-rt.so.1 drumstick-1.1.2_1
+libnozzle.so.1 libnozzle1-1.11_2
diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..cb2b377182e 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libtool libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,11 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+patch_args='-Np1'
+
+pre_configure() {
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +32,27 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vmove "usr/lib/libnozzle.so.*"
+	}
+}
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: [PR PATCH] [Updated] libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (10 preceding siblings ...)
  2019-09-05 10:58 ` voidlinux-github
@ 2019-09-05 10:58 ` voidlinux-github
  2019-09-05 11:26 ` voidlinux-github
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-05 10:58 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by jirib against master on the void-packages repository

https://github.com/jirib/void-packages libknet1
https://github.com/void-linux/void-packages/pull/14215

libknet1: musl fix
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

I also "enabled" building of libnozzle libraries from kronosnet, so it does not diverge from other distros.

A patch file from https://github.com/void-linux/void-packages/pull/14215.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libknet1-14215.patch --]
[-- Type: text/x-diff, Size: 11318 bytes --]

From 39b2066a55eecdcb628dd01112914cb3ea4ec4d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blka?= <jirib79@gmail.com>
Date: Wed, 4 Sep 2019 23:59:15 +0200
Subject: [PATCH] libknet1: musl fix

---
 common/shlibs                             |   1 +
 srcpkgs/libknet1/patches/01_musl_fix.diff | 210 ++++++++++++++++++++++
 srcpkgs/libknet1/template                 |  49 +++--
 srcpkgs/libnozzle1                        |   1 +
 srcpkgs/libnozzle1-devel                  |   1 +
 5 files changed, 247 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/libknet1/patches/01_musl_fix.diff
 create mode 120000 srcpkgs/libnozzle1
 create mode 120000 srcpkgs/libnozzle1-devel

diff --git a/common/shlibs b/common/shlibs
index 57f7025459d..5ba121dc2fd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3507,3 +3507,4 @@ libknet.so.1 libknet1-1.11_1
 libdrumstick-file.so.1 drumstick-1.1.2_1
 libdrumstick-alsa.so.1 drumstick-1.1.2_1
 libdrumstick-rt.so.1 drumstick-1.1.2_1
+libnozzle.so.1 libnozzle1-1.11_2
diff --git a/srcpkgs/libknet1/patches/01_musl_fix.diff b/srcpkgs/libknet1/patches/01_musl_fix.diff
new file mode 100644
index 00000000000..f636c79bb8d
--- /dev/null
+++ b/srcpkgs/libknet1/patches/01_musl_fix.diff
@@ -0,0 +1,210 @@
+https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be
+
+diff --git a/configure.ac b/configure.ac
+index 778b12a5..e430aeb8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -205,6 +205,10 @@ AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
+ AC_SUBST([dl_LIBS], [$LIBS])
+ LIBS="$saved_LIBS"
+ 
++# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
++AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
++    [define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
++
+ # OS detection
+ 
+ AC_MSG_CHECKING([for os in ${host_os}])
+diff --git a/libknet/common.c b/libknet/common.c
+index 00907c91..ed8ac899 100644
+--- a/libknet/common.c
++++ b/libknet/common.c
+@@ -12,6 +12,8 @@
+ #include <fcntl.h>
+ #include <dlfcn.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <link.h>
+ #include <string.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+@@ -54,6 +56,30 @@ int _fdset_nonblock(int fd)
+ 	return 0;
+ }
+ 
++static int get_lib_dir(void *lib_handle, char dir[MAXPATHLEN])
++{
++	int res;
++#ifndef HAVE_RTLD_DI_ORIGIN
++	struct link_map *lm;
++	char l_name[MAXPATHLEN];
++#endif
++
++#ifdef HAVE_RTLD_DI_ORIGIN
++	res = dlinfo(lib_handle, RTLD_DI_ORIGIN, dir);
++#else
++	/*
++	 * musl libc doesn't support RTLD_DI_ORIGIN
++	 */
++	res = dlinfo(lib_handle, RTLD_DI_LINKMAP, &lm);
++	if (res == 0) {
++		snprintf(l_name, sizeof(l_name), "%s", lm->l_name);
++		snprintf(dir, MAXPATHLEN, "%s", dirname(l_name));
++	}
++#endif
++
++	return res;
++}
++
+ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags)
+ {
+ 	void *ret = NULL;
+@@ -81,7 +107,7 @@ static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags
+ 	memset(dir, 0, sizeof(dir));
+ 	memset(link, 0, sizeof(link));
+ 	memset(path, 0, sizeof(path));
+-	if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) {
++	if (get_lib_dir(ret, dir) < 0) {
+ 		/*
+ 		 * should we dlclose and return error?
+ 		 */
+diff --git a/libknet/compat.c b/libknet/compat.c
+index e808f332..2e73c9fc 100644
+--- a/libknet/compat.c
++++ b/libknet/compat.c
+@@ -22,7 +22,7 @@
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+ 
+ static int32_t
+ _poll_to_filter_(int32_t event)
+diff --git a/libknet/crypto.c b/libknet/crypto.c
+index afa4f88c..2c4d5f5c 100644
+--- a/libknet/crypto.c
++++ b/libknet/crypto.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+diff --git a/libknet/handle.c b/libknet/handle.c
+index fcb129a7..6ecc91f7 100644
+--- a/libknet/handle.c
++++ b/libknet/handle.c
+@@ -456,9 +456,24 @@ static void _close_epolls(knet_handle_t knet_h)
+ static int _start_threads(knet_handle_t knet_h)
+ {
+ 	int savederrno = 0;
++	pthread_attr_t attr;
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_PMTUD, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0,
++
++	savederrno = pthread_attr_init(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to init pthread attributes: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++	savederrno = pthread_attr_setstacksize(&attr, KNET_THREAD_STACK_SIZE);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to set stack size attribute: %s",
++			strerror(savederrno));
++		goto exit_fail;
++	}
++
++	savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, &attr,
+ 				    _handle_pmtud_link_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s",
+@@ -467,7 +482,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_DST_LINK, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0,
++	savederrno = pthread_create(&knet_h->dst_link_handler_thread, &attr,
+ 				    _handle_dst_link_handler_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s",
+@@ -476,7 +491,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_TX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->send_to_links_thread, 0,
++	savederrno = pthread_create(&knet_h->send_to_links_thread, &attr,
+ 				    _handle_send_to_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s",
+@@ -485,7 +500,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_RX, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->recv_from_links_thread, 0,
++	savederrno = pthread_create(&knet_h->recv_from_links_thread, &attr,
+ 				    _handle_recv_from_links_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s",
+@@ -494,7 +509,7 @@ static int _start_threads(knet_handle_t knet_h)
+ 	}
+ 
+ 	set_thread_status(knet_h, KNET_THREAD_HB, KNET_THREAD_REGISTERED);
+-	savederrno = pthread_create(&knet_h->heartbt_thread, 0,
++	savederrno = pthread_create(&knet_h->heartbt_thread, &attr,
+ 				    _handle_heartbt_thread, (void *) knet_h);
+ 	if (savederrno) {
+ 		log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s",
+@@ -502,6 +517,15 @@ static int _start_threads(knet_handle_t knet_h)
+ 		goto exit_fail;
+ 	}
+ 
++	savederrno = pthread_attr_destroy(&attr);
++	if (savederrno) {
++		log_err(knet_h, KNET_SUB_HANDLE, "Unable to destroy pthread attributes: %s",
++			strerror(savederrno));
++		/*
++		 * Do not return error code. Error is not critical.
++		 */
++	}
++
+ 	return 0;
+ 
+ exit_fail:
+diff --git a/libknet/internals.h b/libknet/internals.h
+index 3911b847..13530687 100644
+--- a/libknet/internals.h
++++ b/libknet/internals.h
+@@ -37,6 +37,14 @@
+ 
+ #define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX
+ 
++/*
++ * Size of threads stack. Value is choosen by experimenting, how much is needed
++ * to sucesfully finish test suite, and at the time of writing patch it was
++ * ~300KiB. To have some room for future enhancement it is increased
++ * by factor of 3 and rounded.
++ */
++#define KNET_THREAD_STACK_SIZE (1024 * 1024)
++
+ typedef void *knet_transport_link_t; /* per link transport handle */
+ typedef void *knet_transport_t;      /* per knet_h transport handle */
+ struct  knet_transport_ops;          /* Forward because of circular dependancy */
+diff --git a/libknet/onwire.c b/libknet/onwire.c
+index 143ac4b7..e3fd293b 100644
+--- a/libknet/onwire.c
++++ b/libknet/onwire.c
+@@ -8,7 +8,7 @@
+ 
+ #include "config.h"
+ 
+-#include <sys/errno.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/srcpkgs/libknet1/template b/srcpkgs/libknet1/template
index 95cd2b8bef2..cb2b377182e 100644
--- a/srcpkgs/libknet1/template
+++ b/srcpkgs/libknet1/template
@@ -1,16 +1,15 @@
 # Template file for 'libknet1'
-# only library and development files now, if interested in kronosnetd update!
+# only libraries and development files now, if interested in kronosnetd update!
 pkgname=libknet1
 version=1.11
-revision=1
+revision=2
 wrksrc=kronosnet-${version}
 build_style=gnu-configure
-configure_args="--disable-crypto-nss --disable-dependency-tracking
- --disable-libknet-sctp --disable-libnozzle --disable-kronosnetd --disable-poc
- --disable-static"
-hostmakedepends="doxygen libxml2-devel pkg-config libqb-devel"
-makedepends="bzip2-devel liblz4-devel liblzma-devel libqb-devel libressl-devel
- libxml2-devel libzstd-devel lzo-devel zlib-devel"
+configure_args="--disable-dependency-tracking --disable-libknet-sctp
+ --disable-kronosnetd --disable-poc --disable-static"
+hostmakedepends="automake doxygen libtool libxml2-devel pkg-config libqb-devel"
+makedepends="bzip2-devel liblz4-devel liblzma-devel libnl3-devel libqb-devel
+ libressl-devel libxml2-devel libzstd-devel lzo-devel nss-devel zlib-devel"
 short_desc="Kronosnet core switching implementation (libraries)"
 maintainer="Jiří Bělka <jirib79@gmail.com>"
 license="GPL-2.0-or-later, LGPL-2.1-only"
@@ -18,9 +17,11 @@ homepage="https://www.kronosnet.org"
 distfiles="https://kronosnet.org/releases/kronosnet-${version}.tar.bz2"
 checksum=c2ee20a9b5b0791ed5379b38b0b51d549603933925a839f045455553f03e6114
 
-if [ "$XBPS_TARGET_LIBC" = musl ]; then
-	broken="Uses dlinfo RTLD_DI_ORIGIN and other runtime issues"
-fi
+patch_args='-Np1'
+
+pre_configure() {
+	autoreconf -fi
+}
 
 post_install() {
 	rm -rf ${DESTDIR}/usr/share/doc/kronosnet
@@ -31,9 +32,27 @@ libknet1-devel_package() {
 	depends="libknet1>=${version}_${revision}"
 	short_desc="Kronosnet core switching implementation (development files)"
 	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.so"
-		vmove "usr/lib/pkgconfig"
-		vmove usr/share/man/man3
+		vmove usr/include/libknet.h
+		vmove usr/lib/libknet.so
+		vmove usr/lib/pkgconfig/libknet.pc
+		vmove "usr/share/man/man3/knet*"
+	}
+}
+
+libnozzle1_package() {
+	short_desc="Userland wrapper around kernel tap devices"
+	pkg_install() {
+		vmove "usr/lib/libnozzle.so.*"
+	}
+}
+
+libnozzle1-devel_package() {
+	depends="libnozzle1>=${version}_${revision}"
+	short_desc="Userland wrapper around kernel tap devices (development files)"
+	pkg_install() {
+		vmove usr/include/libnozzle.h
+		vmove usr/lib/libnozzle.so
+		vmove usr/lib/pkgconfig/libnozzle.pc
+		vmove "usr/share/man/man3/nozzle*"
 	}
 }
diff --git a/srcpkgs/libnozzle1 b/srcpkgs/libnozzle1
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file
diff --git a/srcpkgs/libnozzle1-devel b/srcpkgs/libnozzle1-devel
new file mode 120000
index 00000000000..0dca2d60545
--- /dev/null
+++ b/srcpkgs/libnozzle1-devel
@@ -0,0 +1 @@
+libknet1
\ No newline at end of file

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

* Re: libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (11 preceding siblings ...)
  2019-09-05 10:58 ` voidlinux-github
@ 2019-09-05 11:26 ` voidlinux-github
  2019-09-05 12:11 ` voidlinux-github
  2019-09-05 17:42 ` [PR PATCH] [Merged]: " voidlinux-github
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-05 11:26 UTC (permalink / raw)
  To: ml

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

New comment by jirib on void-packages repository

https://github.com/void-linux/void-packages/pull/14215#issuecomment-528319716

Comment:
@Hoshpak , @Johnnynator , @q66, ok?

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

* Re: libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (12 preceding siblings ...)
  2019-09-05 11:26 ` voidlinux-github
@ 2019-09-05 12:11 ` voidlinux-github
  2019-09-05 17:42 ` [PR PATCH] [Merged]: " voidlinux-github
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-05 12:11 UTC (permalink / raw)
  To: ml

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

New comment by Johnnynator on void-packages repository

https://github.com/void-linux/void-packages/pull/14215#issuecomment-528334172

Comment:
@jirib did you run the test suite of it? `./xbps-src pkg libknet1 -Q` (and ofc `-m whatever-your-musl-masterdir-is`). I had a similar patch locally and it seemed to break some tests on musl.

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

* Re: [PR PATCH] [Merged]: libknet1: musl fix
  2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
                   ` (13 preceding siblings ...)
  2019-09-05 12:11 ` voidlinux-github
@ 2019-09-05 17:42 ` voidlinux-github
  14 siblings, 0 replies; 16+ messages in thread
From: voidlinux-github @ 2019-09-05 17:42 UTC (permalink / raw)
  To: ml

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

There's a merged pull request on the void-packages repository

libknet1: musl fix
https://github.com/void-linux/void-packages/pull/14215

Description:
Upstream provided musl fix, I took diff and applied to latest release, see https://github.com/kronosnet/kronosnet/commit/512e433b0b3d8bf14818dcb8c8eb7748d7e899be

I also "enabled" building of libnozzle libraries from kronosnet, so it does not diverge from other distros.

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

end of thread, other threads:[~2019-09-05 17:42 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04 22:01 [PR PATCH] libknet1: musl fix voidlinux-github
2019-09-04 22:31 ` [PR PATCH] [Updated] " voidlinux-github
2019-09-04 22:31 ` voidlinux-github
2019-09-04 23:05 ` voidlinux-github
2019-09-04 23:05 ` voidlinux-github
2019-09-04 23:37 ` voidlinux-github
2019-09-04 23:37 ` voidlinux-github
2019-09-05  9:11 ` voidlinux-github
2019-09-05  9:11 ` voidlinux-github
2019-09-05 10:26 ` voidlinux-github
2019-09-05 10:26 ` voidlinux-github
2019-09-05 10:58 ` voidlinux-github
2019-09-05 10:58 ` voidlinux-github
2019-09-05 11:26 ` voidlinux-github
2019-09-05 12:11 ` voidlinux-github
2019-09-05 17:42 ` [PR PATCH] [Merged]: " voidlinux-github

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).