From a6c739a0b40fb2fdd0b37efddb9e352960edeb88 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 20 Jan 2020 03:58:32 +0100 Subject: [PATCH] threadlib: Disable use of weak symbols on FreeBSD 11. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reported by Tim Rühsen in . * m4/threadlib.m4 (gl_WEAK_SYMBOLS): Require AC_CANONICAL_HOST. Test against a bug in FreeBSD 11. --- ChangeLog | 8 ++++++++ m4/threadlib.m4 | 27 ++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1f0556658c..148d15ef3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2020-01-19 Bruno Haible + + threadlib: Disable use of weak symbols on FreeBSD 11. + Reported by Tim Rühsen in + . + * m4/threadlib.m4 (gl_WEAK_SYMBOLS): Require AC_CANONICAL_HOST. Test + against a bug in FreeBSD 11. + 2020-01-19 Bruno Haible iconv_open: Improve z/OS support. diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 index e64ad6216f..94441f680f 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 < conftest2.c +#include +#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) -- 2.39.5