Modify the recently-added probe for -Wl,--as-needed some more, because RHEL-4

vintage Linux is even more broken than we realized: a link to libreadline
will succeed, and fail only at runtime.  It seems that an AC_TRY_RUN test
is the only reliable way to check whether this is really safe.  Per report
from Tatsuo.
This commit is contained in:
Tom Lane 2008-06-27 00:36:16 +00:00
parent 68057055f6
commit 623f8a0969
3 changed files with 67 additions and 58 deletions

View File

@ -1,5 +1,5 @@
# Macros to detect C compiler features # Macros to detect C compiler features
# $PostgreSQL: pgsql/config/c-compiler.m4,v 1.18 2008/05/20 03:30:21 tgl Exp $ # $PostgreSQL: pgsql/config/c-compiler.m4,v 1.19 2008/06/27 00:36:16 tgl Exp $
# PGAC_C_SIGNED # PGAC_C_SIGNED
@ -119,12 +119,15 @@ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
# command-line option. If it does, add the string to LDFLAGS. # command-line option. If it does, add the string to LDFLAGS.
# For reasons you'd really rather not know about, this checks whether # 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. # you can link to a particular function, not just whether you can link.
# In fact, we must actually check that the resulting program runs :-(
AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT], AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT],
[AC_MSG_CHECKING([if $CC supports $1]) [AC_MSG_CHECKING([if $CC supports $1])
pgac_save_LDFLAGS=$LDFLAGS pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS $1" LDFLAGS="$pgac_save_LDFLAGS $1"
AC_LINK_IFELSE([AC_LANG_CALL([],[$2])], AC_RUN_IFELSE([AC_LANG_PROGRAM([extern void $2 (); void (*fptr) () = $2;],[])],
AC_MSG_RESULT(yes), AC_MSG_RESULT(yes),
[LDFLAGS="$pgac_save_LDFLAGS" [LDFLAGS="$pgac_save_LDFLAGS"
AC_MSG_RESULT(no)]) AC_MSG_RESULT(no)],
[LDFLAGS="$pgac_save_LDFLAGS"
AC_MSG_RESULT(assuming no)])
])# PGAC_PROG_CC_LDFLAGS_OPT ])# PGAC_PROG_CC_LDFLAGS_OPT

108
configure vendored
View File

@ -25633,7 +25633,7 @@ fi
# If compiler will take -Wl,--as-needed then add that to LDFLAGS. # 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 # 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.) # executable. (Note that shared library links won't use this switch, though.)
# On (at least) some Red-Hat-derived systems, this switch breaks linking to # On (at least) some Red-Hat-derived systems, this switch breaks linking to
# libreadline; therefore we postpone testing it until we know what library # libreadline; therefore we postpone testing it until we know what library
# dependencies readline has. The test code will try to link with $LIBS. # dependencies readline has. The test code will try to link with $LIBS.
@ -25647,59 +25647,62 @@ if test "$PORTNAME" != "darwin"; then
echo $ECHO_N "checking if $CC supports -Wl,--as-needed... $ECHO_C" >&6; } echo $ECHO_N "checking if $CC supports -Wl,--as-needed... $ECHO_C" >&6; }
pgac_save_LDFLAGS=$LDFLAGS pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,--as-needed" LDFLAGS="$pgac_save_LDFLAGS -Wl,--as-needed"
cat >conftest.$ac_ext <<_ACEOF if test "$cross_compiling" = yes; then
LDFLAGS="$pgac_save_LDFLAGS"
{ echo "$as_me:$LINENO: result: assuming no" >&5
echo "${ECHO_T}assuming no" >&6; }
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */ /* confdefs.h. */
_ACEOF _ACEOF
cat confdefs.h >>conftest.$ac_ext cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */ /* end confdefs.h. */
extern void $link_test_func (); void (*fptr) () = $link_test_func;
/* 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 int
main () main ()
{ {
return $link_test_func ();
; ;
return 0; return 0;
} }
_ACEOF _ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext rm -f conftest$ac_exeext
if { (ac_try="$ac_link" if { (ac_try="$ac_link"
case "(($ac_try" in case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;; *) ac_try_echo=$ac_try;;
esac esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>conftest.er1 (eval "$ac_link") 2>&5
ac_status=$? ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
test -z "$ac_c_werror_flag" || { (case "(($ac_try" in
test ! -s conftest.err *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
} && test -s conftest$ac_exeext && *) ac_try_echo=$ac_try;;
$as_test_x conftest$ac_exeext; then esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
{ echo "$as_me:$LINENO: result: yes" >&5 { echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; } echo "${ECHO_T}yes" >&6; }
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
LDFLAGS="$pgac_save_LDFLAGS" ( exit $ac_status )
{ echo "$as_me:$LINENO: result: no" >&5 LDFLAGS="$pgac_save_LDFLAGS"
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; } echo "${ECHO_T}no" >&6; }
fi fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
else else
# On Darwin it's spelled -Wl,-dead_strip_dylibs, but don't try that elsewhere # On Darwin it's spelled -Wl,-dead_strip_dylibs, but don't try that elsewhere
@ -25707,59 +25710,62 @@ else
echo $ECHO_N "checking if $CC supports -Wl,-dead_strip_dylibs... $ECHO_C" >&6; } echo $ECHO_N "checking if $CC supports -Wl,-dead_strip_dylibs... $ECHO_C" >&6; }
pgac_save_LDFLAGS=$LDFLAGS pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,-dead_strip_dylibs" LDFLAGS="$pgac_save_LDFLAGS -Wl,-dead_strip_dylibs"
cat >conftest.$ac_ext <<_ACEOF if test "$cross_compiling" = yes; then
LDFLAGS="$pgac_save_LDFLAGS"
{ echo "$as_me:$LINENO: result: assuming no" >&5
echo "${ECHO_T}assuming no" >&6; }
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */ /* confdefs.h. */
_ACEOF _ACEOF
cat confdefs.h >>conftest.$ac_ext cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */ /* end confdefs.h. */
extern void $link_test_func (); void (*fptr) () = $link_test_func;
/* 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 int
main () main ()
{ {
return $link_test_func ();
; ;
return 0; return 0;
} }
_ACEOF _ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext rm -f conftest$ac_exeext
if { (ac_try="$ac_link" if { (ac_try="$ac_link"
case "(($ac_try" in case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;; *) ac_try_echo=$ac_try;;
esac esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>conftest.er1 (eval "$ac_link") 2>&5
ac_status=$? ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
test -z "$ac_c_werror_flag" || { (case "(($ac_try" in
test ! -s conftest.err *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
} && test -s conftest$ac_exeext && *) ac_try_echo=$ac_try;;
$as_test_x conftest$ac_exeext; then esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
{ echo "$as_me:$LINENO: result: yes" >&5 { echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; } echo "${ECHO_T}yes" >&6; }
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
LDFLAGS="$pgac_save_LDFLAGS" ( exit $ac_status )
{ echo "$as_me:$LINENO: result: no" >&5 LDFLAGS="$pgac_save_LDFLAGS"
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; } echo "${ECHO_T}no" >&6; }
fi fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi fi

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.562 2008/05/20 03:30:22 tgl Exp $ dnl $PostgreSQL: pgsql/configure.in,v 1.563 2008/06/27 00:36:16 tgl Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
@ -1699,7 +1699,7 @@ fi
# If compiler will take -Wl,--as-needed then add that to LDFLAGS. # 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 # 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.) # executable. (Note that shared library links won't use this switch, though.)
# On (at least) some Red-Hat-derived systems, this switch breaks linking to # On (at least) some Red-Hat-derived systems, this switch breaks linking to
# libreadline; therefore we postpone testing it until we know what library # libreadline; therefore we postpone testing it until we know what library
# dependencies readline has. The test code will try to link with $LIBS. # dependencies readline has. The test code will try to link with $LIBS.