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.
This commit is contained in:
Tom Lane 2007-08-05 15:43:00 +00:00
parent c8b7e811f3
commit df9ea6a1f1
2 changed files with 115 additions and 65 deletions

141
configure vendored
View File

@ -2818,39 +2818,9 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
unset CFLAGS
#
# Read the template
#
. "$srcdir/src/template/$template" || exit
# CFLAGS are selected so:
# If the user specifies something in the environment, that is used.
# else: If the template file set something, that is used.
# else: If the compiler is GCC, then we use -O2.
# else: If the compiler is something else, then we use -0.
if test "$ac_env_CFLAGS_set" = set; then
CFLAGS=$ac_env_CFLAGS_value
elif test "${CFLAGS+set}" = set; then
: # (keep what template set)
elif test "$GCC" = yes; then
CFLAGS="-O2"
else
# if the user selected debug mode, don't use -O
if test "$enable_debug" != yes; then
CFLAGS="-O"
fi
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.
# 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. */
@ -2900,10 +2870,40 @@ ICC=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
if test "$ICC" = no; then
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith -Winline"
unset CFLAGS
echo "$as_me:$LINENO: checking if $CC supports -Wdeclaration-after-statement" >&5
#
# Read the template
#
. "$srcdir/src/template/$template" || exit
# CFLAGS are selected so:
# If the user specifies something in the environment, that is used.
# else: If the template file set something, that is used.
# else: If the compiler is GCC, then we use -O2.
# else: If the compiler is something else, then we use -0.
if test "$ac_env_CFLAGS_set" = set; then
CFLAGS=$ac_env_CFLAGS_value
elif test "${CFLAGS+set}" = set; then
: # (keep what template set)
elif test "$GCC" = yes; then
CFLAGS="-O2"
else
# if the user selected debug mode, don't use -O
if test "$enable_debug" != yes; then
CFLAGS="-O"
fi
fi
# Some versions of GCC support some additional useful warning flags.
# Check whether they are supported, and add them to CFLAGS if so.
# ICC pretends to be GCC but it's lying; it doesn't support these options.
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"
@ -2956,7 +2956,7 @@ 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 "$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 -Wendif-labels"
@ -3009,11 +3009,64 @@ 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
# 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 -fno-strict-aliasing"
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
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
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
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
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

View File

@ -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])