Use -no-undefined on macOS to avoid "-undefined dynamic_lookup" warnings.

Starting with macOS 13, the linker warns when "-undefined dynamic_lookup"
is used.  This is added by libtool by default on macOS but we can
suppress it by passing -no-undefined to libtool.
This commit is contained in:
Todd C. Miller
2023-04-14 13:02:28 -06:00
parent 62a2d9f94c
commit ae12d18ff0
2 changed files with 91 additions and 39 deletions

46
configure vendored
View File

@@ -9201,6 +9201,8 @@ fi
printf "%s\n" "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
EGREP_TRADITIONAL=$EGREP
ac_cv_path_EGREP_TRADITIONAL=$EGREP
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
printf %s "checking for fgrep... " >&6; }
@@ -20055,6 +20057,48 @@ fi
if test -n "$GCC" -a X"${enable_sanitizer}${enable_fuzzer}" = X"nono"
then :
case $host_os in #(
darwin*) :
# On macOS 13, using "-undefined dynamic_lookup" produces a
# warning. Use the -no-undefined libtool option to avoid this.
if test ${LT_LDFLAGS+y}
then :
case " $LT_LDFLAGS " in #(
*" -no-undefined "*) :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LT_LDFLAGS already contains -no-undefined"; } >&5
(: LT_LDFLAGS already contains -no-undefined) 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } ;; #(
*) :
as_fn_append LT_LDFLAGS " -no-undefined"
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LT_LDFLAGS=\"\$LT_LDFLAGS\""; } >&5
(: LT_LDFLAGS="$LT_LDFLAGS") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
else case e in #(
e)
LT_LDFLAGS=-no-undefined
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : LT_LDFLAGS=\"\$LT_LDFLAGS\""; } >&5
(: LT_LDFLAGS="$LT_LDFLAGS") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
;;
esac
fi
;; #(
*) :
# On FreeBSD and Dragonfly, environ is filled in by the dynamic loader
# so -Wl,--no-undefined causes a link error when environ is used.
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263265
@@ -20137,6 +20181,8 @@ fi
fi
;;
esac
fi

View File

@@ -2410,6 +2410,11 @@ AC_INCLUDES_DEFAULT
# We must set this *before* the library tests.
#
AS_IF([test -n "$GCC" -a X"${enable_sanitizer}${enable_fuzzer}" = X"nono"], [
AS_CASE([$host_os], [darwin*], [
# On macOS 13, using "-undefined dynamic_lookup" produces a
# warning. Use the -no-undefined libtool option to avoid this.
AX_APPEND_FLAG([-no-undefined], [LT_LDFLAGS])
], [
# On FreeBSD and Dragonfly, environ is filled in by the dynamic loader
# so -Wl,--no-undefined causes a link error when environ is used.
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263265
@@ -2434,6 +2439,7 @@ extern char **environ;]], [[int ret = ((long)environ & 0xff) + errno; return ret
AX_APPEND_FLAG([-Wl,--no-undefined], [LDFLAGS])
])
])
])
#
# HP-UX may need to define _XOPEN_SOURCE_EXTENDED to expose MSG_WAITALL.