On Mon, Nov 25, 2019 at 2:13 PM Christopher Larson <kerg...@gmail.com> wrote: > > From: Christopher Larson <chris_lar...@mentor.com> > > The libcap-ng build doesn't pass -pthread and can fail to link. >
perhaps, adding a configure time check for pthread.h would be possible AC_CHECK_HEADERS(pthread.h, [], [AC_MSG_WARN(pthread.h not found, pthread_atfork disabled.)]) then include pthread.h inside conditional like below in source files. #ifdef HAVE_PTHREAD_H #endif > Signed-off-by: Christopher Larson <chris_lar...@mentor.com> > --- > meta/recipes-support/libcap-ng/libcap-ng.inc | 1 + > .../libcap-ng/revert-pthread_atfork-fix.patch | 56 > ++++++++++++++++++++++ > 2 files changed, 57 insertions(+) > create mode 100644 > meta/recipes-support/libcap-ng/libcap-ng/revert-pthread_atfork-fix.patch > > diff --git a/meta/recipes-support/libcap-ng/libcap-ng.inc > b/meta/recipes-support/libcap-ng/libcap-ng.inc > index aec83896e4..46d37e6807 100644 > --- a/meta/recipes-support/libcap-ng/libcap-ng.inc > +++ b/meta/recipes-support/libcap-ng/libcap-ng.inc > @@ -9,6 +9,7 @@ LIC_FILES_CHKSUM = > "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \ > > SRC_URI = "http://people.redhat.com/sgrubb/libcap-ng/libcap-ng-${PV}.tar.gz \ > file://python.patch \ > + file://revert-pthread_atfork-fix.patch \ > " > > SRC_URI[md5sum] = "57dc267e2949cdecb651a929f9206572" > 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 > new file mode 100644 > index 0000000000..d3f7790b1e > --- /dev/null > +++ b/meta/recipes-support/libcap-ng/libcap-ng/revert-pthread_atfork-fix.patch > @@ -0,0 +1,56 @@ > +From 81dc82393fae9851397fa5d94094434aa1d5c3d1 Mon Sep 17 00:00:00 2001 > +From: Christopher Larson <chris_lar...@mentor.com> > +Date: Thu, 14 Nov 2019 21:13:24 +0500 > +Subject: [PATCH] Revert "Fix usage of pthread_atfork a whole different way" > + > +This reverts commit 08a09cba90f3d960c080a20833fb8c0908f1cea6. > + > +The fix was breaking builds with some toolchains. > + > +Signed-off-by: Christopher Larson <chris_lar...@mentor.com> > +--- > + src/Makefile.am | 2 +- > + src/cap-ng.c | 12 +++++++++++- > + 2 files changed, 12 insertions(+), 2 deletions(-) > + > +diff --git a/src/Makefile.am b/src/Makefile.am > +index 5a66d4e..d46d02b 100644 > +--- a/src/Makefile.am > ++++ b/src/Makefile.am > +@@ -34,5 +34,5 @@ noinst_HEADERS = captab.h > + libcap_ng_la_SOURCES = cap-ng.c lookup_table.c > + libcap_ng_la_LIBADD = > + libcap_ng_la_DEPENDENCIES = $(libcap_ng_la_SOURCES) ../config.h > +-libcap_ng_la_LDFLAGS = -Wl,-z,relro > ++libcap_ng_la_LDFLAGS = -Wl,-z,relro -Wl,-z,nodelete > + > +diff --git a/src/cap-ng.c b/src/cap-ng.c > +index 35fcd7a..ed31afa 100644 > +--- a/src/cap-ng.c > ++++ b/src/cap-ng.c > +@@ -155,6 +155,15 @@ static __thread struct cap_ng m = { 1, > + CAPNG_NEW, > + {0, 0} }; > + > ++ > ++/* > ++ * The pthread_atfork function is being made weak so that we can use it > ++ * if the program is linked with pthreads and not requiring it for > ++ * everything that uses libcap-ng. > ++ */ > ++extern int __attribute__((weak)) pthread_atfork(void (*prepare)(void), > ++ void (*parent)(void), void (*child)(void)); > ++ > + /* > + * Reset the state so that init gets called to erase everything > + */ > +@@ -166,7 +175,8 @@ static void deinit(void) > + static void init_lib(void) __attribute__ ((constructor)); > + static void init_lib(void) > + { > +- pthread_atfork(NULL, NULL, deinit); > ++ if (pthread_atfork) > ++ pthread_atfork(NULL, NULL, deinit); > + } > + > + static void init(void) > -- > 2.11.1 > > -- > _______________________________________________ > Openembedded-core mailing list > Openembedded-core@lists.openembedded.org > http://lists.openembedded.org/mailman/listinfo/openembedded-core -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core