Do not let external specification of CFLAGS stop us from adding
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 2 Feb 2004 04:08:12 +0000 (04:08 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 2 Feb 2004 04:08:12 +0000 (04:08 +0000)
-fno-strict-aliasing.

config/c-compiler.m4
configure
configure.in

index 5171e1e6d978130b40ad1b5186f6de63ac79baa0..f02243ded0c372eb920e33011f2ae8bb2816a506 100644 (file)
@@ -1,5 +1,5 @@
 # Macros to detect C compiler features
-# $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.5 2002/03/29 17:32:53 petere Exp $
+# $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.5.2.1 2004/02/02 04:08:02 tgl Exp $
 
 
 # PGAC_C_SIGNED
@@ -92,3 +92,32 @@ AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$1),
                    [$AS_TR_SH([pgac_cv_alignof_$1])],
                    [The alignment requirement of a `$1'])
 ])# PGAC_CHECK_ALIGNOF
+
+
+# PGAC_PROG_CC_NO_STRICT_ALIASING
+# -------------------------------
+# Find out how to turn off strict aliasing in the C compiler.
+AC_DEFUN([PGAC_PROG_CC_NO_STRICT_ALIASING],
+[AC_CACHE_CHECK([how to turn off strict aliasing in $CC],
+                pgac_cv_prog_cc_no_strict_aliasing,
+[pgac_save_CFLAGS=$CFLAGS
+if test "$GCC" = yes; then
+  pgac_try="-fno-strict-aliasing"
+else
+  # Maybe fill in later...
+  pgac_try=
+fi
+
+for pgac_flag in $pgac_try; do
+  CFLAGS="$pgac_save_CFLAGS $pgac_flag"
+  _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+                     [pgac_cv_prog_cc_no_strict_aliasing=$pgac_try
+break])
+done
+
+CFLAGS=$pgac_save_CFLAGS
+])
+
+if test x"$pgac_cv_prog_cc_no_strict_aliasing" != x""; then
+  CFLAGS="$CFLAGS $pgac_cv_prog_cc_no_strict_aliasing"
+fi])# PGAC_PROG_CC_NO_STRICT_ALIASING
index e076bc43c5e24684e59d481d553daa7e3af22ea0..118562c49736cce1b79201c0bdc112cd05f8ee94 100755 (executable)
--- a/configure
+++ b/configure
@@ -2437,6 +2437,73 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 if test "$ac_env_CFLAGS_set" = set; then
   CFLAGS=$ac_env_CFLAGS_value
 fi
+
+# Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
+echo "$as_me:$LINENO: checking how to turn off strict aliasing in $CC" >&5
+echo $ECHO_N "checking how to turn off strict aliasing in $CC... $ECHO_C" >&6
+if test "${pgac_cv_prog_cc_no_strict_aliasing+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  pgac_save_CFLAGS=$CFLAGS
+if test "$GCC" = yes; then
+  pgac_try="-fno-strict-aliasing"
+else
+  # Maybe fill in later...
+  pgac_try=
+fi
+
+for pgac_flag in $pgac_try; do
+  CFLAGS="$pgac_save_CFLAGS $pgac_flag"
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  pgac_cv_prog_cc_no_strict_aliasing=$pgac_try
+break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+
+CFLAGS=$pgac_save_CFLAGS
+
+fi
+echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_no_strict_aliasing" >&5
+echo "${ECHO_T}$pgac_cv_prog_cc_no_strict_aliasing" >&6
+
+if test x"$pgac_cv_prog_cc_no_strict_aliasing" != x""; then
+  CFLAGS="$CFLAGS $pgac_cv_prog_cc_no_strict_aliasing"
+fi
+
+# supply -g if --enable-debug
 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
   CFLAGS="$CFLAGS -g"
 fi
index 154cbf90430536a82d0766095e7bf1609bd34e29..54ad53fbd4bfe1126a3ef5c64a1361ceddfaa81f 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.217.2.11 2003/12/02 16:23:03 tgl Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.217.2.12 2004/02/02 04:08:12 tgl Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -249,6 +249,11 @@ AC_PROG_CC([$pgac_cc_list])
 if test "$ac_env_CFLAGS_set" = set; then
   CFLAGS=$ac_env_CFLAGS_value
 fi
+
+# Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
+PGAC_PROG_CC_NO_STRICT_ALIASING
+
+# supply -g if --enable-debug
 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
   CFLAGS="$CFLAGS -g"
 fi