diff options
author | Martin Storsjo <martin@martin.st> | 2018-06-14 12:36:10 +0300 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2018-06-16 15:22:34 +0200 |
commit | 317f382ddc5839f5d65203dd749234fde2ab6d63 (patch) | |
tree | 2018ccfe69743f42b06cbfa7876ffe66bc2e210e /configure.ac | |
parent | 37f1726a5b3742f4d7ffda4b57a9de34c6eaae45 (diff) | |
download | gnutls-317f382ddc5839f5d65203dd749234fde2ab6d63.tar.gz |
configure: Pass -no_weak_imports to the linker, if supported
This avoids linking to functions that aren't available in the
lowest targeted macOS version.
If the proper header declaring a function is included, and
gnutls is built with -mmacosx-version-min or the
MACOSX_DEPLOYMENT_TARGET environment variable is set, each
reference to a function that doesn't exist in the minimum
targeted version will be made a weak reference, so that loading
the binary still works, but the function pointer will resolve
to NULL if running on a version of the platform that lacks it.
Since this project doesn't do such runtime checks for functions
it expects to have available, we should instead add this linker
option to fail on the weak references. This allows autoconf to
work as intended, detecting that these functions aren't usable.
This flag appeared in Xcode 8, so check for its availability
before using it. (Xcode 8 and the 10.12 SDK is coincidentally
the release where most relevant new functions appeared, so with
older Xcode versions, the modern platform functions we might want
to avoid don't exist.)
See issue #142.
Signed-off-by: Martin Storsjo <martin@martin.st>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index ea14cc4b4c..162f187d4d 100644 --- a/configure.ac +++ b/configure.ac @@ -125,6 +125,14 @@ case "$host" in ;; *darwin*) have_macosx=yes + save_LDFLAGS="$LDFLAGS" + dnl Try to use -no_weak_imports if available. This makes sure we + dnl error out when linking to a function that doesn't exist in the + 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([], [])], + [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); LDFLAGS="$save_LDFLAGS"]) ;; *solaris*) have_elf=yes |