]> Savannah Git Hosting - gnulib.git/commitdiff
threadlib: Disable use of weak symbols on FreeBSD 11.
authorBruno Haible <bruno@clisp.org>
Mon, 20 Jan 2020 02:58:32 +0000 (03:58 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 20 Jan 2020 02:58:32 +0000 (03:58 +0100)
Reported by Tim Rühsen <tim.ruehsen@gmx.de> 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.

ChangeLog
m4/threadlib.m4

index 1f0556658ce21381d3f46f44be967e54f8ce43a8..148d15ef3fe8436cba71380644e405b83c1ef825 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-01-19  Bruno Haible  <bruno@clisp.org>
+
+       threadlib: Disable use of weak symbols on FreeBSD 11.
+       Reported by Tim Rühsen <tim.ruehsen@gmx.de> 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.
+
 2020-01-19  Bruno Haible  <bruno@clisp.org>
 
        iconv_open: Improve z/OS support.
index e64ad6216ff2f1b60fc1c14383db72ba45e83c24..94441f680f5f39ef510d959e14bc66d0237cc678 100644 (file)
@@ -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)