libgpg-error 1.44 fails to build on FreeBSD 11

Roman Bogorodskiy bogorodskiy at gmail.com
Sun Mar 27 04:40:16 CEST 2022


Hi,

libgpg-error 1.44 fails to build on FreeBSD 11 with:

libtool: link: ranlib .libs/libgpg-error.a
libtool: link: ( cd ".libs" && rm -f "libgpg-error.la" && ln -s "../libgpg-error.la" "libgpg-error.la" )
/bin/sh ../libtool  --tag=CC    --mode=link cc  -O2 -pipe  -DLIBICONV_PLUG -fstack-protector-strong -fno-strict-aliasing  -Wall -Wpointer-arith -fvisibility=hidden   -fstack-protector-strong  -L/usr/local/lib -o gpg-error gpg_error-strsource-sym.o  gpg_error-strerror-sym.o gpg_error-gpg-error.o libgpg-error.la -L/usr/local/lib -lintl -R/usr/local/lib
libtool: link: cc -O2 -pipe -DLIBICONV_PLUG -fstack-protector-strong -fno-strict-aliasing -Wall -Wpointer-arith -fvisibility=hidden -fstack-protector-strong -o .libs/gpg-error gpg_error-strsource-sym.o gpg_error-strerror-sym.o gpg_error-gpg-error.o  -L/usr/local/lib ./.libs/libgpg-error.so -lintl -Wl,-rpath -Wl,/usr/local/lib
./.libs/libgpg-error.so: undefined reference to `pthread_create'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.
make[4]: stopped in /wrkdirs/usr/ports/security/libgpg-error/work/libgpg-error-1.44/src
*** Error code 1

However, it builds fine on newer FreeBSD versions.

Looks like m4/threadlib.m4 has some special handling for FreeBSD weak
symbol related bug, which in combination with other checks leads to
having PTHREAD_IN_USE_DETECTION_HARD defined, which unlocks the code in
src/posix-lock.c which uses pthread_create(), but doesn't link any
threading libraries. And that's not the case for the newer FreeBSD
versions.

The following patch appears to fix the issue:

diff --git a/src/Makefile.am b/src/Makefile.am
index 34e0476..cfcbe16 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -215,7 +215,7 @@ nodist_libgpg_error_la_SOURCES = gpg-error.h
 # without the extra_cppflags because they may include am -idirafter
 # which is not supported by the RC compiler.
 libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
-libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(socklibs) $(LIBTHREAD)
+libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(socklibs) $(LIBMULTITHREAD)
 
 gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c
 gpg_error_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" \

Not sure that's the right fix though, because with this change on a
newer FreeBSD versions it gets linked with an extra library:

$ ldd ./src/.libs/libgpg-error.so
./src/.libs/libgpg-error.so:
        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x2e55e4e7e000)
        libthr.so.3 => /lib/libthr.so.3 (0x2e55e5e16000)
        libc.so.7 => /lib/libc.so.7 (0x2e55e30fd000)

Which is apparently not required as before the change it was:

$ ldd ./src/.libs/libgpg-error.so
./src/.libs/libgpg-error.so:
        libintl.so.8 => /usr/local/lib/libintl.so.8 (0xead5df6c000)
        libc.so.7 => /lib/libc.so.7 (0xead5c797000)

Any ideas what would be the right fix?

Thanks,

Roman Bogorodskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20220327/b2dbc831/attachment-0001.sig>


More information about the Gnupg-devel mailing list