Adjust -Wl,--asneeded test to avoid using the switch if it breaks

libreadline.  What we will do for compatibility :-(
This commit is contained in:
Tom Lane 2008-05-20 03:30:22 +00:00
parent 9f19470966
commit 1ac1bea076
3 changed files with 172 additions and 136 deletions

View File

@ -1,5 +1,5 @@
# Macros to detect C compiler features
# $PostgreSQL: pgsql/config/c-compiler.m4,v 1.17 2008/05/18 20:13:12 tgl Exp $
# $PostgreSQL: pgsql/config/c-compiler.m4,v 1.18 2008/05/20 03:30:21 tgl Exp $
# PGAC_C_SIGNED
@ -117,11 +117,13 @@ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
# ------------------------
# Given a string, check if the compiler supports the string as a
# command-line option. If it does, add the string to LDFLAGS.
# For reasons you'd really rather not know about, this checks whether
# you can link to a particular function, not just whether you can link.
AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT],
[AC_MSG_CHECKING([if $CC supports $1])
pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS $1"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
AC_LINK_IFELSE([AC_LANG_CALL([],[$2])],
AC_MSG_RESULT(yes),
[LDFLAGS="$pgac_save_LDFLAGS"
AC_MSG_RESULT(no)])

260
configure vendored
View File

@ -3977,9 +3977,6 @@ echo "$as_me: error: --enable-profiling is supported only when using GCC" >&2;}
fi
fi
{ echo "$as_me:$LINENO: using CFLAGS=$CFLAGS" >&5
echo "$as_me: using CFLAGS=$CFLAGS" >&6;}
# We already have this in Makefile.win32, but configure needs it too
if test "$PORTNAME" = "win32"; then
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
@ -4318,116 +4315,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# If compiler will take -Wl,--as-needed then add that to LDFLAGS.
# This is much easier than trying to filter LIBS to the minimum for each
# executable. (Note that shared libraries won't use this switch, though.)
# On Darwin it's spelled -Wl,-dead_strip_dylibs, but don't try that elsewhere
if test "$PORTNAME" != "darwin"; then
{ echo "$as_me:$LINENO: checking if $CC supports -Wl,--as-needed" >&5
echo $ECHO_N "checking if $CC supports -Wl,--as-needed... $ECHO_C" >&6; }
pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,--as-needed"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
LDFLAGS="$pgac_save_LDFLAGS"
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
else
{ echo "$as_me:$LINENO: checking if $CC supports -Wl,-dead_strip_dylibs" >&5
echo $ECHO_N "checking if $CC supports -Wl,-dead_strip_dylibs... $ECHO_C" >&6; }
pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,-dead_strip_dylibs"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
LDFLAGS="$pgac_save_LDFLAGS"
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
# Create compiler version string
if test x"$GCC" = x"yes" ; then
cc_string="GCC `${CC} --version | sed q`"
@ -5596,11 +5483,6 @@ rm -f conftest*
CPPFLAGS="$CPPFLAGS $INCLUDES"
LDFLAGS="$LDFLAGS $LIBDIRS"
{ echo "$as_me:$LINENO: using CPPFLAGS=$CPPFLAGS" >&5
echo "$as_me: using CPPFLAGS=$CPPFLAGS" >&6;}
{ echo "$as_me:$LINENO: using LDFLAGS=$LDFLAGS" >&5
echo "$as_me: using LDFLAGS=$LDFLAGS" >&6;}
@ -25749,6 +25631,148 @@ echo "$as_me: WARNING: *** skipping thread test on Win32" >&2;}
fi
fi
# If compiler will take -Wl,--as-needed then add that to LDFLAGS.
# This is much easier than trying to filter LIBS to the minimum for each
# executable. (Note that shared libraries won't use this switch, though.)
# On (at least) some Red-Hat-derived systems, this switch breaks linking to
# libreadline; therefore we postpone testing it until we know what library
# dependencies readline has. The test code will try to link with $LIBS.
if test "$with_readline" = yes; then
link_test_func=readline
else
link_test_func=exit
fi
if test "$PORTNAME" != "darwin"; then
{ echo "$as_me:$LINENO: checking if $CC supports -Wl,--as-needed" >&5
echo $ECHO_N "checking if $CC supports -Wl,--as-needed... $ECHO_C" >&6; }
pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,--as-needed"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* 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 $link_test_func ();
int
main ()
{
return $link_test_func ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
LDFLAGS="$pgac_save_LDFLAGS"
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
else
# On Darwin it's spelled -Wl,-dead_strip_dylibs, but don't try that elsewhere
{ echo "$as_me:$LINENO: checking if $CC supports -Wl,-dead_strip_dylibs" >&5
echo $ECHO_N "checking if $CC supports -Wl,-dead_strip_dylibs... $ECHO_C" >&6; }
pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,-dead_strip_dylibs"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* 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 $link_test_func ();
int
main ()
{
return $link_test_func ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
LDFLAGS="$pgac_save_LDFLAGS"
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
# Begin output steps
{ echo "$as_me:$LINENO: using CFLAGS=$CFLAGS" >&5
echo "$as_me: using CFLAGS=$CFLAGS" >&6;}
{ echo "$as_me:$LINENO: using CPPFLAGS=$CPPFLAGS" >&5
echo "$as_me: using CPPFLAGS=$CPPFLAGS" >&6;}
{ echo "$as_me:$LINENO: using LDFLAGS=$LDFLAGS" >&5
echo "$as_me: using LDFLAGS=$LDFLAGS" >&6;}
# prepare build tree if outside source tree
# Note 1: test -ef might not exist, but it's more reliable than `pwd`.
# Note 2: /bin/pwd might be better than shell's built-in at getting

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.561 2008/05/18 20:13:12 tgl Exp $
dnl $PostgreSQL: pgsql/configure.in,v 1.562 2008/05/20 03:30:22 tgl Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
@ -426,8 +426,6 @@ if test "$enable_profiling" = yes && test "$ac_cv_prog_cc_g" = yes; then
fi
fi
AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
# We already have this in Makefile.win32, but configure needs it too
if test "$PORTNAME" = "win32"; then
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
@ -450,16 +448,6 @@ fi
AC_PROG_CPP
AC_SUBST(GCC)
# If compiler will take -Wl,--as-needed then add that to LDFLAGS.
# This is much easier than trying to filter LIBS to the minimum for each
# executable. (Note that shared libraries won't use this switch, though.)
# On Darwin it's spelled -Wl,-dead_strip_dylibs, but don't try that elsewhere
if test "$PORTNAME" != "darwin"; then
PGAC_PROG_CC_LDFLAGS_OPT([-Wl,--as-needed])
else
PGAC_PROG_CC_LDFLAGS_OPT([-Wl,-dead_strip_dylibs])
fi
# Create compiler version string
if test x"$GCC" = x"yes" ; then
cc_string="GCC `${CC} --version | sed q`"
@ -773,9 +761,6 @@ AC_SUBST(ELF_SYS)
CPPFLAGS="$CPPFLAGS $INCLUDES"
LDFLAGS="$LDFLAGS $LIBDIRS"
AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
AC_ARG_VAR(LDFLAGS_SL)
PGAC_PROG_LD
@ -1712,6 +1697,31 @@ AC_MSG_WARN([*** skipping thread test on Win32])
fi
fi
# If compiler will take -Wl,--as-needed then add that to LDFLAGS.
# This is much easier than trying to filter LIBS to the minimum for each
# executable. (Note that shared libraries won't use this switch, though.)
# On (at least) some Red-Hat-derived systems, this switch breaks linking to
# libreadline; therefore we postpone testing it until we know what library
# dependencies readline has. The test code will try to link with $LIBS.
if test "$with_readline" = yes; then
link_test_func=readline
else
link_test_func=exit
fi
if test "$PORTNAME" != "darwin"; then
PGAC_PROG_CC_LDFLAGS_OPT([-Wl,--as-needed], $link_test_func)
else
# On Darwin it's spelled -Wl,-dead_strip_dylibs, but don't try that elsewhere
PGAC_PROG_CC_LDFLAGS_OPT([-Wl,-dead_strip_dylibs], $link_test_func)
fi
# Begin output steps
AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
# prepare build tree if outside source tree
# Note 1: test -ef might not exist, but it's more reliable than `pwd`.
# Note 2: /bin/pwd might be better than shell's built-in at getting