summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2008-06-27 00:36:16 +0000
committerTom Lane2008-06-27 00:36:16 +0000
commit623f8a0969e9e4663dd27e065bfb8f67f9508006 (patch)
tree09456605782b51d66ed3875c192d722c98fc37a3
parent68057055f687d986a4db5e5bb41ea55e1483d1cb (diff)
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.
-rw-r--r--config/c-compiler.m413
-rwxr-xr-xconfigure108
-rw-r--r--configure.in4
3 files changed, 67 insertions, 58 deletions
diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 7422f9572e..eeb2ee9494 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -1,5 +1,5 @@
# 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
@@ -119,12 +119,15 @@ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
# 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.
+# In fact, we must actually check that the resulting program runs :-(
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_CALL([],[$2])],
- AC_MSG_RESULT(yes),
- [LDFLAGS="$pgac_save_LDFLAGS"
- AC_MSG_RESULT(no)])
+AC_RUN_IFELSE([AC_LANG_PROGRAM([extern void $2 (); void (*fptr) () = $2;],[])],
+ AC_MSG_RESULT(yes),
+ [LDFLAGS="$pgac_save_LDFLAGS"
+ AC_MSG_RESULT(no)],
+ [LDFLAGS="$pgac_save_LDFLAGS"
+ AC_MSG_RESULT(assuming no)])
])# PGAC_PROG_CC_LDFLAGS_OPT
diff --git a/configure b/configure
index f493808442..ed1e4b0b95 100755
--- a/configure
+++ b/configure
@@ -25633,7 +25633,7 @@ 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.)
+# 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
# libreadline; therefore we postpone testing it until we know what library
# 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; }
pgac_save_LDFLAGS=$LDFLAGS
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. */
_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 ();
+extern void $link_test_func (); void (*fptr) () = $link_test_func;
int
main ()
{
-return $link_test_func ();
+
;
return 0;
}
_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f 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
+ (eval "$ac_link") 2>&5
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
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (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_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
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
- LDFLAGS="$pgac_save_LDFLAGS"
- { echo "$as_me:$LINENO: result: no" >&5
+( exit $ac_status )
+LDFLAGS="$pgac_save_LDFLAGS"
+ { echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
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
# 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; }
pgac_save_LDFLAGS=$LDFLAGS
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. */
_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 ();
+extern void $link_test_func (); void (*fptr) () = $link_test_func;
int
main ()
{
-return $link_test_func ();
+
;
return 0;
}
_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f 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
+ (eval "$ac_link") 2>&5
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
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (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_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
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
- LDFLAGS="$pgac_save_LDFLAGS"
- { echo "$as_me:$LINENO: result: no" >&5
+( exit $ac_status )
+LDFLAGS="$pgac_save_LDFLAGS"
+ { echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
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
diff --git a/configure.in b/configure.in
index c5b27a149e..2c73e03db4 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
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 Developers, please strive to achieve this order:
dnl
@@ -1699,7 +1699,7 @@ 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.)
+# 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
# libreadline; therefore we postpone testing it until we know what library
# dependencies readline has. The test code will try to link with $LIBS.