mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Fix configure's AC_CHECK_DECLS tests to work correctly with clang.
The test case that Autoconf uses to discover whether a function has been declared doesn't work reliably with clang, because clang reports a warning not an error if the name is a known built-in function. On some platforms, this results in a lot of compile-time warnings about strlcpy and related functions not having been declared. There is a fix for this (by Noah Misch) in the upstream Autoconf sources, but since they've not made a release in years and show no indication of doing so anytime soon, let's just absorb their fix directly. We can revert this when and if we update to a newer Autoconf release. Back-patch to all supported branches. Discussion: https://postgr.es/m/26819.1542515567@sss.pgh.pa.us
This commit is contained in:
100
configure
vendored
100
configure
vendored
@ -2304,13 +2304,16 @@ rm -f conftest.val
|
||||
ac_fn_c_check_decl ()
|
||||
{
|
||||
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
|
||||
as_decl_name=`echo $2|sed 's/ *(.*//'`
|
||||
# Initialize each $ac_[]_AC_LANG_ABBREV[]_decl_warn_flag once.
|
||||
as_decl_name=`echo $2|sed 's/ *(.*//'`
|
||||
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
|
||||
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
|
||||
if eval \${$3+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_save_werror_flag=$ac_c_werror_flag
|
||||
ac_c_werror_flag="$ac_c_decl_warn_flag$ac_c_werror_flag"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
$4
|
||||
@ -2335,6 +2338,7 @@ else
|
||||
eval "$3=no"
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
ac_c_werror_flag=$ac_save_werror_flag
|
||||
fi
|
||||
eval ac_res=\$$3
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
|
||||
@ -13262,7 +13266,96 @@ esac
|
||||
# posix_fadvise() is a no-op on Solaris, so don't incur function overhead
|
||||
# by calling it, 2009-04-02
|
||||
# http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/posix_fadvise.c
|
||||
if test "$PORTNAME" != "solaris"; then
|
||||
# The Clang compiler raises a warning for an undeclared identifier that matches
|
||||
# a compiler builtin function. All extant Clang versions are affected, as of
|
||||
# Clang 3.6.0. Test a builtin known to every version. This problem affects the
|
||||
# C and Objective C languages, but Clang does report an error under C++ and
|
||||
# Objective C++.
|
||||
#
|
||||
# Passing -fno-builtin to the compiler would suppress this problem. That
|
||||
# strategy would have the advantage of being insensitive to stray warnings, but
|
||||
# it would make tests less realistic.
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how $CC reports undeclared, standard C functions" >&5
|
||||
$as_echo_n "checking how $CC reports undeclared, standard C functions... " >&6; }
|
||||
if ${ac_cv_c_decl_report+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
(void) strchr;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
if test -s conftest.err; then :
|
||||
# For AC_CHECK_DECL to react to warnings, the compiler must be silent on
|
||||
# valid AC_CHECK_DECL input. No library function is consistently available
|
||||
# on freestanding implementations, so test against a dummy declaration.
|
||||
# Include always-available headers on the off chance that they somehow
|
||||
# elicit warnings.
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
extern void ac_decl (int, char *);
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
(void) ac_decl ((int) 0, (char *) 0);
|
||||
(void) ac_decl;
|
||||
#else
|
||||
(void) ac_decl;
|
||||
#endif
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
if test -s conftest.err; then :
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
as_fn_error $? "cannot detect from compiler exit status or warnings
|
||||
See \`config.log' for more details" "$LINENO" 5; }
|
||||
else
|
||||
ac_cv_c_decl_report=warning
|
||||
fi
|
||||
else
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
as_fn_error $? "cannot compile a simple declaration test
|
||||
See \`config.log' for more details" "$LINENO" 5; }
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
else
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
as_fn_error $? "compiler does not report undeclared identifiers
|
||||
See \`config.log' for more details" "$LINENO" 5; }
|
||||
fi
|
||||
else
|
||||
ac_cv_c_decl_report=error
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_decl_report" >&5
|
||||
$as_echo "$ac_cv_c_decl_report" >&6; }
|
||||
|
||||
case $ac_cv_c_decl_report in
|
||||
warning) ac_c_decl_warn_flag=yes ;;
|
||||
*) ac_c_decl_warn_flag= ;;
|
||||
esac
|
||||
|
||||
if test "$PORTNAME" != "solaris"; then :
|
||||
|
||||
for ac_func in posix_fadvise
|
||||
do :
|
||||
ac_fn_c_check_func "$LINENO" "posix_fadvise" "ac_cv_func_posix_fadvise"
|
||||
@ -13286,7 +13379,8 @@ cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_DECL_POSIX_FADVISE $ac_have_decl
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
fi # fi
|
||||
|
||||
ac_fn_c_check_decl "$LINENO" "fdatasync" "ac_cv_have_decl_fdatasync" "#include <unistd.h>
|
||||
"
|
||||
|
Reference in New Issue
Block a user