2 dnl Check if the target supports weak.
3 AC_DEFUN([GCC_CHECK_ATTRIBUTE_WEAK], [
4 AC_CACHE_CHECK([whether the target supports weak],
5 ac_cv_have_attribute_weak, [
6 weakref_m4_saved_CFLAGS="$CFLAGS"
7 CFLAGS="$CFLAGS -Werror"
8 AC_TRY_COMPILE([void __attribute__((weak)) foo(void) { }],
9 [], ac_cv_have_attribute_weak=yes,
10 ac_cv_have_attribute_weak=no)
11 CFLAGS="$weakref_m4_saved_CFLAGS"])
12 if test x"$ac_cv_have_attribute_weak" = xyes; then
13 AC_DEFINE(HAVE_ATTRIBUTE_WEAK, 1,
14 [Define to 1 if the target supports __attribute__((weak)).])
17 dnl Check whether weak refs work like the ELF ones.
18 dnl This means that the weak reference works without having to satify
19 dnl linkage for the item.
20 dnl There are targets (at least Darwin) where we have fully functional
21 dnl weakrefs at runtime, but must supply the referenced item at link time.
22 AC_DEFUN([GCC_CHECK_ELF_STYLE_WEAKREF], [
23 AC_CACHE_CHECK([whether weak refs work like ELF],
24 ac_cv_have_elf_style_weakref, [
25 weakref_m4_saved_CFLAGS="$CFLAGS"
27 *-apple-darwin*) CFLAGS="$CFLAGS -Wl,-undefined,dynamic_lookup" ;;
30 AC_RUN_IFELSE([AC_LANG_SOURCE([[
31 extern void fNotToBeFound(void) __attribute__((weak));
39 ]])], ac_cv_have_elf_style_weakref=yes, ac_cv_have_elf_style_weakref=no, [
41 alpha*-dec-osf*) ac_cv_have_elf_style_weakref=no ;;
42 *-apple-darwin[[89]]*) ac_cv_have_elf_style_weakref=no ;;
43 *) ac_cv_have_elf_style_weakref=yes;;
44 esac])CFLAGS="$weakref_m4_saved_CFLAGS"])
45 if test x"$ac_cv_have_elf_style_weakref" = xyes; then
46 AC_DEFINE(HAVE_ELF_STYLE_WEAKREF, 1, [Define to 1 if target has a weakref that works like the ELF one.])