<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">It seems like libcap wants to support use of pthread by the linking application without mandating it, so we can’t pass -pthread, and I’m not sure a configure check would help, unless it wants to pull in pthread unconditionally. But I may be misunderstanding the libcap commits, and am *definitely* not a threading expert :)</div>
</div>
<div name="messageReplySection">On Nov 25, 2019, 3:27 PM -0700, Khem Raj <raj.khem@gmail.com>, wrote:<br />
<blockquote type="cite" class="spark_quote" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;">On Mon, Nov 25, 2019 at 2:13 PM Christopher Larson <kergoth@gmail.com> wrote:<br />
<blockquote type="cite" class="spark_quote" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;"><br />
From: Christopher Larson <chris_larson@mentor.com><br />
<br />
The libcap-ng build doesn't pass -pthread and can fail to link.<br />
<br /></blockquote>
<br />
perhaps, adding a configure time check for pthread.h would be possible<br />
<br />
AC_CHECK_HEADERS(pthread.h, [], [AC_MSG_WARN(pthread.h not found,<br />
pthread_atfork disabled.)])<br />
<br />
then include pthread.h inside conditional like below in source files.<br />
<br />
#ifdef HAVE_PTHREAD_H<br />
#endif<br />
<br />
<br />
<br />
<blockquote type="cite" class="spark_quote" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">Signed-off-by: Christopher Larson <chris_larson@mentor.com><br />
---<br />
meta/recipes-support/libcap-ng/libcap-ng.inc | 1 +<br />
.../libcap-ng/revert-pthread_atfork-fix.patch | 56 ++++++++++++++++++++++<br />
2 files changed, 57 insertions(+)<br />
create mode 100644 meta/recipes-support/libcap-ng/libcap-ng/revert-pthread_atfork-fix.patch<br />
<br />
diff --git a/meta/recipes-support/libcap-ng/libcap-ng.inc b/meta/recipes-support/libcap-ng/libcap-ng.inc<br />
index aec83896e4..46d37e6807 100644<br />
--- a/meta/recipes-support/libcap-ng/libcap-ng.inc<br />
+++ b/meta/recipes-support/libcap-ng/libcap-ng.inc<br />
@@ -9,6 +9,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \<br />
<br />
SRC_URI = "http://people.redhat.com/sgrubb/libcap-ng/libcap-ng-${PV}.tar.gz \<br />
file://python.patch \<br />
+ file://revert-pthread_atfork-fix.patch \<br />
"<br />
<br />
SRC_URI[md5sum] = "57dc267e2949cdecb651a929f9206572"<br />
diff --git a/meta/recipes-support/libcap-ng/libcap-ng/revert-pthread_atfork-fix.patch b/meta/recipes-support/libcap-ng/libcap-ng/revert-pthread_atfork-fix.patch<br />
new file mode 100644<br />
index 0000000000..d3f7790b1e<br />
--- /dev/null<br />
+++ b/meta/recipes-support/libcap-ng/libcap-ng/revert-pthread_atfork-fix.patch<br />
@@ -0,0 +1,56 @@<br />
+From 81dc82393fae9851397fa5d94094434aa1d5c3d1 Mon Sep 17 00:00:00 2001<br />
+From: Christopher Larson <chris_larson@mentor.com><br />
+Date: Thu, 14 Nov 2019 21:13:24 +0500<br />
+Subject: [PATCH] Revert "Fix usage of pthread_atfork a whole different way"<br />
+<br />
+This reverts commit 08a09cba90f3d960c080a20833fb8c0908f1cea6.<br />
+<br />
+The fix was breaking builds with some toolchains.<br />
+<br />
+Signed-off-by: Christopher Larson <chris_larson@mentor.com><br />
+---<br />
+ src/Makefile.am | 2 +-<br />
+ src/cap-ng.c | 12 +++++++++++-<br />
+ 2 files changed, 12 insertions(+), 2 deletions(-)<br />
+<br />
+diff --git a/src/Makefile.am b/src/Makefile.am<br />
+index 5a66d4e..d46d02b 100644<br />
+--- a/src/Makefile.am<br />
++++ b/src/Makefile.am<br />
+@@ -34,5 +34,5 @@ noinst_HEADERS = captab.h<br />
+ libcap_ng_la_SOURCES = cap-ng.c lookup_table.c<br />
+ libcap_ng_la_LIBADD =<br />
+ libcap_ng_la_DEPENDENCIES = $(libcap_ng_la_SOURCES) ../config.h<br />
+-libcap_ng_la_LDFLAGS = -Wl,-z,relro<br />
++libcap_ng_la_LDFLAGS = -Wl,-z,relro -Wl,-z,nodelete<br />
+<br />
+diff --git a/src/cap-ng.c b/src/cap-ng.c<br />
+index 35fcd7a..ed31afa 100644<br />
+--- a/src/cap-ng.c<br />
++++ b/src/cap-ng.c<br />
+@@ -155,6 +155,15 @@ static __thread struct cap_ng m = { 1,<br />
+ CAPNG_NEW,<br />
+ {0, 0} };<br />
+<br />
++<br />
++/*<br />
++ * The pthread_atfork function is being made weak so that we can use it<br />
++ * if the program is linked with pthreads and not requiring it for<br />
++ * everything that uses libcap-ng.<br />
++ */<br />
++extern int __attribute__((weak)) pthread_atfork(void (*prepare)(void),<br />
++ void (*parent)(void), void (*child)(void));<br />
++<br />
+ /*<br />
+ * Reset the state so that init gets called to erase everything<br />
+ */<br />
+@@ -166,7 +175,8 @@ static void deinit(void)<br />
+ static void init_lib(void) __attribute__ ((constructor));<br />
+ static void init_lib(void)<br />
+ {<br />
+- pthread_atfork(NULL, NULL, deinit);<br />
++ if (pthread_atfork)<br />
++ pthread_atfork(NULL, NULL, deinit);<br />
+ }<br />
+<br />
+ static void init(void)<br />
--<br />
2.11.1<br />
<br />
--<br />
_______________________________________________<br />
Openembedded-core mailing list<br />
Openembedded-core@lists.openembedded.org<br />
http://lists.openembedded.org/mailman/listinfo/openembedded-core<br /></blockquote>
</blockquote>
</div>
</body>
</html>