Replace obsolete AC_LANG_FUNC_LINK_TRY autoconf macro.

The version of this macro used in autoconf 2.59 is capable of incorrectly
succeeding (ie, reporting that a library function is available when it
isn't), if the compiler performs link-time optimization and decides that
it can optimize the function reference away entirely.  Replace it with the
coding used in autoconf 2.61 and later, which forces the program result to
depend on the function's result so that it cannot be optimized away.  This
should fix build failures currently being seen on buildfarm member anchovy.

This patch affects the 8.2 and 8.3 branches only, since later branches are
using autoconf versions that don't have this problem.
This commit is contained in:
Tom Lane 2011-08-29 19:52:13 -04:00
parent a2d9f9478e
commit cbd51548dc
2 changed files with 298 additions and 325 deletions

View File

@ -297,3 +297,72 @@ int main()
])dnl AC_CACHE_VAL
AC_MSG_RESULT([$pgac_cv_printf_arg_control])
])# PGAC_FUNC_PRINTF_ARG_CONTROL
# backport improved FUNC_LINK_TRY test from Autoconf 2.61, cf
# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=f50d0bd4c7d92fbabcd9169920a23889524790e7
# This is needed to avoid incorrect results when compiler does link-time
# optimization.
# AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
# -----------------------------------
# Avoid conflicting decl of main.
m4_define([AC_LANG_CALL(C)],
[AC_LANG_PROGRAM([$1
m4_if([$2], [main], ,
[/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();])], [return $2 ();])])
# AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
# ----------------------------------
# Don't include <ctype.h> because on OSF/1 3.0 it includes
# <sys/types.h> which includes <sys/select.h> which contains a
# prototype for select. Similarly for bzero.
#
# This test used to merely assign f=$1 in main(), but that was
# optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
# presumably on the basis that there's no need to do that store if the
# program is about to exit. Conversely, the AIX linker optimizes an
# unused external declaration that initializes f=$1. So this test
# program has both an external initialization of f, and a use of f in
# main that affects the exit status.
#
m4_define([AC_LANG_FUNC_LINK_TRY(C)],
[AC_LANG_PROGRAM(
[/* Define $1 to an innocuous variant, in case <limits.h> declares $1.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define $1 innocuous_$1
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $1 (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef $1
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $1 ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$1 || defined __stub___$1
choke me
#endif
], [return $1 ();])])

554
configure vendored

File diff suppressed because it is too large Load Diff