1*883529b6Schristos 2*883529b6Schristosdnl Check if the target supports weak. 3*883529b6SchristosAC_DEFUN([GCC_CHECK_ATTRIBUTE_WEAK], [ 4*883529b6Schristos AC_CACHE_CHECK([whether the target supports weak], 5*883529b6Schristos ac_cv_have_attribute_weak, [ 6*883529b6Schristos weakref_m4_saved_CFLAGS="$CFLAGS" 7*883529b6Schristos CFLAGS="$CFLAGS -Werror" 8*883529b6Schristos AC_TRY_COMPILE([void __attribute__((weak)) foo(void) { }], 9*883529b6Schristos [], ac_cv_have_attribute_weak=yes, 10*883529b6Schristos ac_cv_have_attribute_weak=no) 11*883529b6Schristos CFLAGS="$weakref_m4_saved_CFLAGS"]) 12*883529b6Schristos if test x"$ac_cv_have_attribute_weak" = xyes; then 13*883529b6Schristos AC_DEFINE(HAVE_ATTRIBUTE_WEAK, 1, 14*883529b6Schristos [Define to 1 if the target supports __attribute__((weak)).]) 15*883529b6Schristos fi]) 16*883529b6Schristos 17*883529b6Schristosdnl Check whether weak refs work like the ELF ones. 18*883529b6Schristosdnl This means that the weak reference works without having to satify 19*883529b6Schristosdnl linkage for the item. 20*883529b6Schristosdnl There are targets (at least Darwin) where we have fully functional 21*883529b6Schristosdnl weakrefs at runtime, but must supply the referenced item at link time. 22*883529b6SchristosAC_DEFUN([GCC_CHECK_ELF_STYLE_WEAKREF], [ 23*883529b6Schristos AC_CACHE_CHECK([whether weak refs work like ELF], 24*883529b6Schristos ac_cv_have_elf_style_weakref, [ 25*883529b6Schristos weakref_m4_saved_CFLAGS="$CFLAGS" 26*883529b6Schristos case "${host}" in 27*883529b6Schristos *-apple-darwin*) CFLAGS="$CFLAGS -Wl,-undefined,dynamic_lookup" ;; 28*883529b6Schristos *) ;; 29*883529b6Schristos esac 30*883529b6Schristos AC_RUN_IFELSE([AC_LANG_SOURCE([[ 31*883529b6Schristosextern void fNotToBeFound(void) __attribute__((weak)); 32*883529b6Schristosint main () 33*883529b6Schristos{ 34*883529b6Schristos if (fNotToBeFound) 35*883529b6Schristos return 1; 36*883529b6Schristos else 37*883529b6Schristos return 0; 38*883529b6Schristos} 39*883529b6Schristos]])], ac_cv_have_elf_style_weakref=yes, ac_cv_have_elf_style_weakref=no, [ 40*883529b6Schristoscase "${host}" in 41*883529b6Schristos *-apple-darwin[[89]]*) ac_cv_have_elf_style_weakref=no ;; 42*883529b6Schristos *) ac_cv_have_elf_style_weakref=yes;; 43*883529b6Schristosesac])CFLAGS="$weakref_m4_saved_CFLAGS"]) 44*883529b6Schristosif test x"$ac_cv_have_elf_style_weakref" = xyes; then 45*883529b6Schristos AC_DEFINE(HAVE_ELF_STYLE_WEAKREF, 1, [Define to 1 if target has a weakref that works like the ELF one.]) 46*883529b6Schristosfi]) 47*883529b6Schristos 48