From edf183f7fd40d0ca1f67605944eb5a3ef838fdec Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Tue, 4 Aug 2020 09:48:35 +0200 Subject: [PATCH] Fix underlinking of libpthread --- gnutls-3.6.14-pthreads.patch | 50 ++++++++++++++++++++++++++++++++++++ gnutls.spec | 7 ++++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 gnutls-3.6.14-pthreads.patch diff --git a/gnutls-3.6.14-pthreads.patch b/gnutls-3.6.14-pthreads.patch new file mode 100644 index 0000000..c69d97d --- /dev/null +++ b/gnutls-3.6.14-pthreads.patch @@ -0,0 +1,50 @@ +From f15c02b1fb9faf3e06db2c51196a27b0f9d72672 Mon Sep 17 00:00:00 2001 +From: James Bottomley +Date: Sun, 28 Jun 2020 21:33:09 +0200 +Subject: [PATCH] build: use $(LIBPTHREAD) rather than non-existent + $(LTLIBPTHREAD) + +On a very recent openSUSE build, libgnutls is getting built without +libpthread. This caused a thread related error when trying to load a +pkcs11 module that uses threading. The reason is rather convoluted: +glibc actually controls all the pthread_ function calls, but it +returns success without doing anything unless -lpthread is in the link +list. What's happening is that gnutls_system_mutex_init() is being +called on _gnutls_pkcs11_mutex before library pthreading is +initialized, so the pthread_mutex_init ends up being a nop. Then, when +the pkcs11 module is loaded, pthreads get initialized and the call to +pthread_mutex_lock is real, but errors out on the uninitialized mutex. + +The problem seems to be that nothing in the gnulib macros gnutls +relies on for threading support detection actually sets LTLIBPTHREAD, +they only set LIBPTHREAD. The fix is to use LIBPTHREAD in +lib/Makefile.in + +Signed-off-by: James Bottomley +--- + bootstrap.conf | 4 ++-- + lib/Makefile.am | 8 +++++++- + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/lib/Makefile.am b/lib/Makefile.am +index fa47ac5e6..02504d8d1 100644 +--- a/lib/Makefile.am ++++ b/lib/Makefile.am +@@ -168,7 +168,13 @@ libgnutls_la_LIBADD += accelerated/libaccelerated.la + endif + + if !WINDOWS +-thirdparty_libadd += $(LTLIBPTHREAD) ++# p11-kit does not work without threading support: ++# https://github.com/p11-glue/p11-kit/pull/183 ++if ENABLE_PKCS11 ++thirdparty_libadd += $(LIBPMULTITHREAD) ++else ++thirdparty_libadd += $(LIBPTHREAD) ++endif + endif + + if NEEDS_LIBRT +-- +2.26.2 + diff --git a/gnutls.spec b/gnutls.spec index 82965fd..8767ccc 100644 --- a/gnutls.spec +++ b/gnutls.spec @@ -1,10 +1,11 @@ # This spec file has been automatically updated Version: 3.6.14 -Release: 5%{?dist} +Release: 6%{?dist} Patch1: gnutls-3.6.7-no-now-guile.patch Patch2: gnutls-3.2.7-rpath.patch Patch3: gnutls-3.6.14-fix-iovec-memory-leak.patch Patch4: gnutls-3.6.14-configure-fix-soname-detection.patch +Patch5: gnutls-3.6.14-pthreads.patch %bcond_without dane %if 0%{?rhel} %bcond_with guile @@ -145,6 +146,7 @@ This package contains Guile bindings for the library. gpgv2 --keyring %{SOURCE2} %{SOURCE1} %{SOURCE0} %autosetup -p1 +autoreconf -fi sed -i -e 's|sys_lib_dlsearch_path_spec="/lib /usr/lib|sys_lib_dlsearch_path_spec="/lib /usr/lib %{_libdir}|g' configure rm -f lib/minitasn1/*.c lib/minitasn1/*.h @@ -280,6 +282,9 @@ make check %{?_smp_mflags} GNUTLS_SYSTEM_PRIORITY_FILE=/dev/null %endif %changelog +* Tue Aug 4 2020 Daiki Ueno - 3.6.14-6 +- Fix underlinking of libpthread + * Sat Aug 01 2020 Fedora Release Engineering - 3.6.14-5 - Second attempt - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild