aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-08-05 15:43:00 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-08-05 15:43:00 +0000
commitdf9ea6a1f1c283b342d1b6e80968fc09310a2f67 (patch)
treebe5e9dc1c43db8f05583c1398f0c4edbdb6f05f2
parentc8b7e811f397cd784bfd3f9bb874bb0616c889f6 (diff)
downloadpostgresql-df9ea6a1f1c283b342d1b6e80968fc09310a2f67.tar.gz
postgresql-df9ea6a1f1c283b342d1b6e80968fc09310a2f67.zip
Adjust configure so that it sets CFLAGS properly for Intel's icc
even if the compiler is not defining __GNUC__. Per report from Dirk Tilger that it is possible for icc to not do that.
-rwxr-xr-xconfigure103
-rw-r--r--configure.in39
2 files changed, 96 insertions, 46 deletions
diff --git a/configure b/configure
index 0ee9dac06ba..1a1c8890f43 100755
--- a/configure
+++ b/configure
@@ -2818,6 +2818,58 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+# Check if it's Intel's compiler, which (usually) pretends to be gcc,
+# but has idiosyncrasies of its own. We assume icc will define
+# __INTEL_COMPILER regardless of CFLAGS.
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __INTEL_COMPILER
+choke me
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 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); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (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); }; } &&
+ { 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
+ ICC=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ICC=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
unset CFLAGS
#
@@ -2846,12 +2898,15 @@ fi
# Some versions of GCC support some additional useful warning flags.
# Check whether they are supported, and add them to CFLAGS if so.
-
-if test "$GCC" = yes; then
-
# ICC pretends to be GCC but it's lying; it doesn't support these options.
-# So we have to check if "GCC" is really ICC.
+if test "$GCC" = yes -a "$ICC" = no; then
+ CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith -Winline"
+ # These work in some but not all gcc versions
+ echo "$as_me:$LINENO: checking if $CC supports -Wdeclaration-after-statement" >&5
+echo $ECHO_N "checking if $CC supports -Wdeclaration-after-statement... $ECHO_C" >&6
+pgac_save_CFLAGS=$CFLAGS
+CFLAGS="$pgac_save_CFLAGS -Wdeclaration-after-statement"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -2862,9 +2917,7 @@ cat >>conftest.$ac_ext <<_ACEOF
int
main ()
{
-#ifndef __INTEL_COMPILER
-choke me
-#endif
+
;
return 0;
}
@@ -2891,22 +2944,22 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ICC=yes
+ 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
-ICC=no
+CFLAGS="$pgac_save_CFLAGS"
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- if test "$ICC" = no; then
- CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith -Winline"
-
- echo "$as_me:$LINENO: checking if $CC supports -Wdeclaration-after-statement" >&5
-echo $ECHO_N "checking if $CC supports -Wdeclaration-after-statement... $ECHO_C" >&6
+ echo "$as_me:$LINENO: checking if $CC supports -Wendif-labels" >&5
+echo $ECHO_N "checking if $CC supports -Wendif-labels... $ECHO_C" >&6
pgac_save_CFLAGS=$CFLAGS
-CFLAGS="$pgac_save_CFLAGS -Wdeclaration-after-statement"
+CFLAGS="$pgac_save_CFLAGS -Wendif-labels"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -2956,10 +3009,11 @@ echo "${ECHO_T}no" >&6
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- echo "$as_me:$LINENO: checking if $CC supports -Wendif-labels" >&5
-echo $ECHO_N "checking if $CC supports -Wendif-labels... $ECHO_C" >&6
+ # Disable strict-aliasing rules; needed for gcc 3.3+
+ echo "$as_me:$LINENO: checking if $CC supports -fno-strict-aliasing" >&5
+echo $ECHO_N "checking if $CC supports -fno-strict-aliasing... $ECHO_C" >&6
pgac_save_CFLAGS=$CFLAGS
-CFLAGS="$pgac_save_CFLAGS -Wendif-labels"
+CFLAGS="$pgac_save_CFLAGS -fno-strict-aliasing"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -3009,11 +3063,10 @@ echo "${ECHO_T}no" >&6
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- else
- # Intel compiler has a bug/misoptimization in checking for
- # division by NAN (NaN == 0), -mp1 fixes it, so add it to the
- # CFLAGS.
- echo "$as_me:$LINENO: checking if $CC supports -mp1" >&5
+elif test "$ICC" = yes; then
+ # Intel's compiler has a bug/misoptimization in checking for
+ # division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
+ echo "$as_me:$LINENO: checking if $CC supports -mp1" >&5
echo $ECHO_N "checking if $CC supports -mp1... $ECHO_C" >&6
pgac_save_CFLAGS=$CFLAGS
CFLAGS="$pgac_save_CFLAGS -mp1"
@@ -3066,9 +3119,7 @@ echo "${ECHO_T}no" >&6
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- fi
-
- # Disable strict-aliasing rules; needed for gcc 3.3+
+ # Not clear if this is needed, but seems like a good idea
echo "$as_me:$LINENO: checking if $CC supports -fno-strict-aliasing" >&5
echo $ECHO_N "checking if $CC supports -fno-strict-aliasing... $ECHO_C" >&6
pgac_save_CFLAGS=$CFLAGS
diff --git a/configure.in b/configure.in
index 157ea944979..5f7cd886f1e 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.522 2007/07/19 17:15:30 tgl Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.523 2007/08/05 15:43:00 tgl Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
@@ -243,6 +243,13 @@ esac
AC_PROG_CC([$pgac_cc_list])
+# Check if it's Intel's compiler, which (usually) pretends to be gcc,
+# but has idiosyncrasies of its own. We assume icc will define
+# __INTEL_COMPILER regardless of CFLAGS.
+AC_TRY_COMPILE([], [@%:@ifndef __INTEL_COMPILER
+choke me
+@%:@endif], [ICC=[yes]], [ICC=[no]])
+
unset CFLAGS
#
@@ -271,29 +278,21 @@ fi
# Some versions of GCC support some additional useful warning flags.
# Check whether they are supported, and add them to CFLAGS if so.
-
-if test "$GCC" = yes; then
-
# ICC pretends to be GCC but it's lying; it doesn't support these options.
-# So we have to check if "GCC" is really ICC.
-AC_TRY_COMPILE([], [@%:@ifndef __INTEL_COMPILER
-choke me
-@%:@endif], [ICC=[yes]], [ICC=[no]])
-
- if test "$ICC" = no; then
- CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith -Winline"
-
- PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
- PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
- else
- # Intel compiler has a bug/misoptimization in checking for
- # division by NAN (NaN == 0), -mp1 fixes it, so add it to the
- # CFLAGS.
- PGAC_PROG_CC_CFLAGS_OPT([-mp1])
- fi
+if test "$GCC" = yes -a "$ICC" = no; then
+ CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith -Winline"
+ # These work in some but not all gcc versions
+ PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
+ PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
# Disable strict-aliasing rules; needed for gcc 3.3+
PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
+elif test "$ICC" = yes; then
+ # Intel's compiler has a bug/misoptimization in checking for
+ # division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
+ PGAC_PROG_CC_CFLAGS_OPT([-mp1])
+ # Not clear if this is needed, but seems like a good idea
+ PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
elif test x"${CC}" = x"xlc"; then
# AIX xlc has to have strict aliasing turned off too
PGAC_PROG_CC_CFLAGS_OPT([-qnoansialias])