]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
configure: Remove -no_weak_links from LDFLAGS after detecting function availability
authorMartin Storsjo <martin@martin.st>
Thu, 7 Jan 2021 11:41:12 +0000 (13:41 +0200)
committerMartin Storsjo <martin@martin.st>
Fri, 8 Jan 2021 17:49:48 +0000 (19:49 +0200)
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>
configure.ac

index 76d414b868a220aeda618af7e836ec800d549ff1..2d889c53ab9400ec8feebd277b7acbe535c4c2e0 100644 (file)
@@ -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",