summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2021-01-07 13:41:12 +0200
committerMartin Storsjo <martin@martin.st>2021-01-08 19:49:48 +0200
commit52f8617e705bfb05d2abd597fbdcd9594f4b04c3 (patch)
tree8f2c9a2023e080075f059d2e06eb908f6e0386cb
parent45baab1a79cfcdf5fd12b1c1564716d047701635 (diff)
downloadgnutls-52f8617e705bfb05d2abd597fbdcd9594f4b04c3.tar.gz
configure: Remove -no_weak_links from LDFLAGS after detecting function availability
This reverts commit 945a48993dcdd9ead17216e55c59db209923ea5e and fixes the original issue (#966) differently. This makes sure that when targeting a version of macOS less than 10.12, we won't pick up and unconditionally use functions that only appeared later, when building with Xcode 11.4 or newer. (With Xcode 11.4 or newer, the fix from 945a48993dcdd9 caused -no_weak_links not be added, affecting the function availability tests.) Signed-off-by: Martin Storsjo <martin@martin.st>
-rw-r--r--configure.ac19
1 files changed, 18 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 76d414b868..2d889c53ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,7 +145,7 @@ case "$host" in
dnl intended minimum runtime version.
LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
AC_MSG_CHECKING([whether the linker supports -Wl,-no_weak_imports])
- AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/select.h>], [fd_set rfds; FD_ZERO(&rfds); FD_SET(0, &rfds);])],
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); LDFLAGS="$save_LDFLAGS"])
;;
*solaris*)
@@ -415,6 +415,23 @@ if test "$ac_cv_func_clock_gettime" != "yes";then
gnutls_needs_librt=yes
fi
+if test "$have_macosx" = "yes";then
+ dnl Remove -no_weak_imports from LDFLAGS after testing for function
+ dnl availability; keeping it included later breaks code that uses
+ dnl FD_SET, which since Xcode 11.4 implicitly adds a call to the
+ dnl weakly linked function __darwin_check_fd_set_overflow. We only
+ dnl need it above to make sure that we don't detect functions that
+ dnl are linked weakly (and can end up null at runtime) unless
+ dnl we check for their availability at runtime.
+ new_LDFLAGS=""
+ for f in $LDFLAGS; do
+ if test "$f" != "-Wl,-no_weak_imports"; then
+ new_LDFLAGS="$new_LDFLAGS $f"
+ fi
+ done
+ LDFLAGS="$new_LDFLAGS"
+fi
+
AC_ARG_WITH(included-unistring, AS_HELP_STRING([--with-included-unistring],
[disable linking with system libunistring]),
included_unistring="$withval",