[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FreeBSD 11.2: glthread build failure
From: |
Bruno Haible |
Subject: |
Re: FreeBSD 11.2: glthread build failure |
Date: |
Mon, 20 Jan 2020 04:01:05 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-171-generic; KDE/5.18.0; x86_64; ; ) |
Hi Tim,
> > FreeBSD 11.2-RELEASE-p4 (with clang 6.0):
> >
> > CCLD wget2
Please make it a habit to use "make V=1" when submitting a report.
I don't want to see "CCLD wget2"; I want to see the actual link
command line.
> > /usr/bin/ld: undefined reference to symbol
> > `pthread_mutexattr_gettype@@FBSD_1.0' (try adding -lthr)
> > //lib/libthr.so.3: could not read symbols: Bad value
> > clang: error: linker command failed with exit code 1 (use -v to see
> > invocation)
> > gmake[2]: *** [Makefile:1697: wget2] Error 1
I reproduce the issue
- with a wget2-1.99.2.tar.gz tarball downloaded from
https://gitlab.com/gnuwget/wget2/pipelines
- when configuring with --disable-shared
- on FreeBSD 11, NOT on FreeBSD 12,
- NOT when configuring with --disable-shared --without-lzma
The problem is that, somehow, weak symbols don't work well when linking
with a library that has a dependency to libpthread.so (-> libthr.so)
- liblzma.so in this case.
Since gnulib cannot forbid any package from linking with liblzma, gnulib
has to avoid using weak symbols in this case.
This patch should fix the problem.
2020-01-19 Bruno Haible <address@hidden>
threadlib: Disable use of weak symbols on FreeBSD 11.
Reported by Tim Rühsen <address@hidden> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-01/msg00061.html>.
* m4/threadlib.m4 (gl_WEAK_SYMBOLS): Require AC_CANONICAL_HOST. Test
against a bug in FreeBSD 11.
diff --git a/m4/threadlib.m4 b/m4/threadlib.m4
index e64ad62..94441f6 100644
--- a/m4/threadlib.m4
+++ b/m4/threadlib.m4
@@ -1,4 +1,4 @@
-# threadlib.m4 serial 26
+# threadlib.m4 serial 27
dnl Copyright (C) 2005-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -81,6 +81,7 @@ dnl Checks whether the compiler and linker support weak
declarations of symbols.
AC_DEFUN([gl_WEAK_SYMBOLS],
[
+ AC_REQUIRE([AC_CANONICAL_HOST])
AC_CACHE_CHECK([whether imported symbols can be declared weak],
[gl_cv_have_weak],
[gl_cv_have_weak=no
@@ -119,6 +120,30 @@ int main ()
case " $LDFLAGS " in
*" -static "*) gl_cv_have_weak=no ;;
esac
+ dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak
+ dnl symbol and linking against a shared library that has a dependency on
+ dnl the shared library that defines the symbol.
+ case "$gl_cv_have_weak" in
+ *yes)
+ case "$host_os" in
+ freebsd* | dragonfly*)
+ : > conftest1.c
+ $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so
conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1
+ cat <<EOF > conftest2.c
+#include <pthread.h>
+#pragma weak pthread_mutexattr_gettype
+int main ()
+{
+ return (pthread_mutexattr_gettype != NULL);
+}
+EOF
+ $CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c
libempty.so >&AS_MESSAGE_LOG_FD 2>&1 \
+ || gl_cv_have_weak=no
+ rm -f conftest1.c libempty.so conftest2.c conftest
+ ;;
+ esac
+ ;;
+ esac
])
case "$gl_cv_have_weak" in
*yes)