threadlib.m4 (bison-3.8.1.tar.xz) | : | threadlib.m4 (bison-3.8.2.tar.xz) | ||
---|---|---|---|---|
# threadlib.m4 serial 31 | # threadlib.m4 serial 32 | |||
dnl Copyright (C) 2005-2021 Free Software Foundation, Inc. | dnl Copyright (C) 2005-2021 Free Software Foundation, Inc. | |||
dnl This file is free software; the Free Software Foundation | dnl This file is free software; the Free Software Foundation | |||
dnl gives unlimited permission to copy and/or distribute it, | dnl gives unlimited permission to copy and/or distribute it, | |||
dnl with or without modifications, as long as this notice is preserved. | dnl with or without modifications, as long as this notice is preserved. | |||
dnl From Bruno Haible. | dnl From Bruno Haible. | |||
AC_PREREQ([2.60]) | AC_PREREQ([2.60]) | |||
dnl The general structure of the multithreading modules in gnulib is that we | dnl The general structure of the multithreading modules in gnulib is that we | |||
skipping to change at line 87 | skipping to change at line 87 | |||
fi | fi | |||
]) | ]) | |||
dnl Checks whether the compiler and linker support weak declarations of symbols. | dnl Checks whether the compiler and linker support weak declarations of symbols. | |||
AC_DEFUN([gl_WEAK_SYMBOLS], | AC_DEFUN([gl_WEAK_SYMBOLS], | |||
[ | [ | |||
AC_REQUIRE([AC_CANONICAL_HOST]) | AC_REQUIRE([AC_CANONICAL_HOST]) | |||
AC_CACHE_CHECK([whether imported symbols can be declared weak], | AC_CACHE_CHECK([whether imported symbols can be declared weak], | |||
[gl_cv_have_weak], | [gl_cv_have_weak], | |||
[gl_cv_have_weak=no | [case "$host_os" in | |||
dnl First, test whether the compiler accepts it syntactically. | cygwin*) | |||
AC_LINK_IFELSE( | dnl On Cygwin 3.2.0 with gcc 10.2, the test below would succeed, but | |||
[AC_LANG_PROGRAM( | dnl programs that use pthread_in_use() with weak symbol references | |||
[[extern void xyzzy (); | dnl crash miserably at runtime. | |||
gl_cv_have_weak="guessing no" | ||||
;; | ||||
*) | ||||
gl_cv_have_weak=no | ||||
dnl First, test whether the compiler accepts it syntactically. | ||||
AC_LINK_IFELSE( | ||||
[AC_LANG_PROGRAM( | ||||
[[extern void xyzzy (); | ||||
#pragma weak xyzzy]], | #pragma weak xyzzy]], | |||
[[xyzzy();]])], | [[xyzzy();]])], | |||
[gl_cv_have_weak=maybe]) | [gl_cv_have_weak=maybe]) | |||
if test $gl_cv_have_weak = maybe; then | if test $gl_cv_have_weak = maybe; then | |||
dnl Second, test whether it actually works. On Cygwin 1.7.2, with | dnl Second, test whether it actually works. On Cygwin 1.7.2, with | |||
dnl gcc 4.3, symbols declared weak always evaluate to the address 0. | dnl gcc 4.3, symbols declared weak always evaluate to the address 0. | |||
AC_RUN_IFELSE( | AC_RUN_IFELSE( | |||
[AC_LANG_SOURCE([[ | [AC_LANG_SOURCE([[ | |||
#include <stdio.h> | #include <stdio.h> | |||
#pragma weak fputs | #pragma weak fputs | |||
int main () | int main () | |||
{ | { | |||
return (fputs == NULL); | return (fputs == NULL); | |||
}]])], | }]])], | |||
[gl_cv_have_weak=yes], | [gl_cv_have_weak=yes], | |||
[gl_cv_have_weak=no], | [gl_cv_have_weak=no], | |||
[dnl When cross-compiling, assume that only ELF platforms support | [dnl When cross-compiling, assume that only ELF platforms support | |||
dnl weak symbols. | dnl weak symbols. | |||
AC_EGREP_CPP([Extensible Linking Format], | AC_EGREP_CPP([Extensible Linking Format], | |||
[#ifdef __ELF__ | [#ifdef __ELF__ | |||
Extensible Linking Format | Extensible Linking Format | |||
#endif | #endif | |||
], | ], | |||
[gl_cv_have_weak="guessing yes"], | [gl_cv_have_weak="guessing yes"], | |||
[gl_cv_have_weak="guessing no"]) | [gl_cv_have_weak="guessing no"]) | |||
]) | ]) | |||
fi | fi | |||
;; | ||||
esac | ||||
dnl But when linking statically, weak symbols don't work. | dnl But when linking statically, weak symbols don't work. | |||
case " $LDFLAGS " in | case " $LDFLAGS " in | |||
*" -static "*) gl_cv_have_weak=no ;; | *" -static "*) gl_cv_have_weak=no ;; | |||
esac | esac | |||
dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak | 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 symbol and linking against a shared library that has a dependency on | |||
dnl the shared library that defines the symbol. | dnl the shared library that defines the symbol. | |||
case "$gl_cv_have_weak" in | case "$gl_cv_have_weak" in | |||
*yes) | *yes) | |||
case "$host_os" in | case "$host_os" in | |||
End of changes. 4 change blocks. | ||||
26 lines changed or deleted | 36 lines changed or added |