提交 381e1675 编写于 作者: J Jesse Zhang

Stop deriving C++ flags from CFLAGS.

Commit 2e387d0e "Disable aggressive loop optimizations in GCC 4.8+"
created a precedent of using autoconf to manipulate CXXFLAGS. We've then
been getting more flags by stealing them wholesale (modulo checking for
compiler support) from CFLAGS since commit 9e2dab0a "Derive CXXFLAGS
from CFLAGS.". This was neat in that it was low-maintenance, and it has
practically served us well for the past 3 years. However, our current
simplistic CXXFLAGS manipulation leaves a lot to be desired:

1. It's implicit, giving us very little control over what flags to *not*
include in CXXFLAGS. To wit, -Wmissing-prototypes is inapplicable to C++
but still included in CXXFLAGS.

2. Negative flags are not well supported. Some compilers -- notably GCC
-- do not reject a negative warning flag (e.g. -Wno-fff). Compiler
detection for such flags needs to be done in the positive form before
adding the negative flag.

3. It neglects CXXFLAGS the user specifies (either in the environment or
as an argument to configure)

This patch replaces the implicit derivation with explicit setting of
CXXFLAGS. I've tested that this maintains behavior parity (modulo losing
-Wmissing-prototypes, which is intentional). I've preserved the
Greenplum idiosyncrasy of defaulting O3.

[resolves #9979]

Note that sooner or later we're gonna merge with upstream Postgres 11
where C++ support is added to configure. The macro name
PGAC_PROG_CXX_CXXFLAGS_OPT is deliberately (or it might have been a
happenstance) chosen to be *different* from the upstream macro name so
as to make "git blame" more useful and make it easier to wholesale take
the upstream changes when the merge happens.
上级 e42dae7d
......@@ -12,12 +12,12 @@ ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
AC_LANG_PUSH(C++)
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
[eval Ac_cachevar=yes],
[eval Ac_cachevar=no])
[Ac_cachevar=yes],
[Ac_cachevar=no])
AC_LANG_POP([C++])
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"])
if eval test x"$Ac_cachevar" = x"yes"; then
if test x"$Ac_cachevar" = x"yes"; then
$1="${$1} $2"
fi
undefine([Ac_cachevar])dnl
......
......@@ -4896,6 +4896,21 @@ else
fi
fi
if test "$ac_env_CXXFLAGS_set" = set; then
CXXFLAGS=$ac_env_CXXFLAGS_value
elif test "${CXXFLAGS+set}" = set; then
: # (keep what template set)
elif test "$enable_coverage" = yes; then
: # no optimization by default
elif test "$GCC" = yes; then
CXXFLAGS="-O3"
else
# if the user selected debug mode, don't use -O
if test "$enable_debug" != yes; then
CXXFLAGS="-O"
fi
fi
# For GPDB, Use C99, rather than C89, compile rules
#
#
......@@ -5156,6 +5171,7 @@ fi
if test "$GCC" = yes -a "$ICC" = no; then
CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith"
CXXFLAGS="-Wall -Wpointer-arith"
# These work in some but not all gcc versions
# GPDB code is full of declarations after statement.
#PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
......@@ -5194,6 +5210,53 @@ if test x"$pgac_cv_prog_cc_cflags__Wendif_labels" = x"yes"; then
CFLAGS="$CFLAGS -Wendif-labels"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports -Wendif-labels" >&5
$as_echo_n "checking whether $CXX supports -Wendif-labels... " >&6; }
if ${pgac_cv_prog_cxx_cxxflags__Wendif_labels+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$pgac_save_CXXFLAGS -Wendif-labels"
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
pgac_cv_prog_cxx_cxxflags__Wendif_labels=yes
else
pgac_cv_prog_cxx_cxxflags__Wendif_labels=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cxx_cxxflags__Wendif_labels" >&5
$as_echo "$pgac_cv_prog_cxx_cxxflags__Wendif_labels" >&6; }
if test x"$pgac_cv_prog_cxx_cxxflags__Wendif_labels" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -Wendif-labels"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wmissing-format-attribute" >&5
$as_echo_n "checking whether $CC supports -Wmissing-format-attribute... " >&6; }
if ${pgac_cv_prog_cc_cflags__Wmissing_format_attribute+:} false; then :
......@@ -5229,6 +5292,53 @@ if test x"$pgac_cv_prog_cc_cflags__Wmissing_format_attribute" = x"yes"; then
CFLAGS="$CFLAGS -Wmissing-format-attribute"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports -Wmissing-format-attribute" >&5
$as_echo_n "checking whether $CXX supports -Wmissing-format-attribute... " >&6; }
if ${pgac_cv_prog_cxx_cxxflags__Wmissing_format_attribute+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$pgac_save_CXXFLAGS -Wmissing-format-attribute"
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
pgac_cv_prog_cxx_cxxflags__Wmissing_format_attribute=yes
else
pgac_cv_prog_cxx_cxxflags__Wmissing_format_attribute=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cxx_cxxflags__Wmissing_format_attribute" >&5
$as_echo "$pgac_cv_prog_cxx_cxxflags__Wmissing_format_attribute" >&6; }
if test x"$pgac_cv_prog_cxx_cxxflags__Wmissing_format_attribute" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -Wmissing-format-attribute"
fi
# This was included in -Wall/-Wformat in older GCC versions
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-security" >&5
$as_echo_n "checking whether $CC supports -Wformat-security... " >&6; }
......@@ -5265,6 +5375,53 @@ if test x"$pgac_cv_prog_cc_cflags__Wformat_security" = x"yes"; then
CFLAGS="$CFLAGS -Wformat-security"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports -Wformat-security" >&5
$as_echo_n "checking whether $CXX supports -Wformat-security... " >&6; }
if ${pgac_cv_prog_cxx_cxxflags__Wformat_security+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$pgac_save_CXXFLAGS -Wformat-security"
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
pgac_cv_prog_cxx_cxxflags__Wformat_security=yes
else
pgac_cv_prog_cxx_cxxflags__Wformat_security=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cxx_cxxflags__Wformat_security" >&5
$as_echo "$pgac_cv_prog_cxx_cxxflags__Wformat_security" >&6; }
if test x"$pgac_cv_prog_cxx_cxxflags__Wformat_security" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -Wformat-security"
fi
# Disable strict-aliasing rules; needed for gcc 3.3+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fno-strict-aliasing" >&5
$as_echo_n "checking whether $CC supports -fno-strict-aliasing... " >&6; }
......@@ -5301,6 +5458,53 @@ if test x"$pgac_cv_prog_cc_cflags__fno_strict_aliasing" = x"yes"; then
CFLAGS="$CFLAGS -fno-strict-aliasing"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports -fno-strict-aliasing" >&5
$as_echo_n "checking whether $CXX supports -fno-strict-aliasing... " >&6; }
if ${pgac_cv_prog_cxx_cxxflags__fno_strict_aliasing+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$pgac_save_CXXFLAGS -fno-strict-aliasing"
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
pgac_cv_prog_cxx_cxxflags__fno_strict_aliasing=yes
else
pgac_cv_prog_cxx_cxxflags__fno_strict_aliasing=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cxx_cxxflags__fno_strict_aliasing" >&5
$as_echo "$pgac_cv_prog_cxx_cxxflags__fno_strict_aliasing" >&6; }
if test x"$pgac_cv_prog_cxx_cxxflags__fno_strict_aliasing" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
fi
# Disable optimizations that assume no overflow; needed for gcc 4.3+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fwrapv" >&5
$as_echo_n "checking whether $CC supports -fwrapv... " >&6; }
......@@ -5337,6 +5541,53 @@ if test x"$pgac_cv_prog_cc_cflags__fwrapv" = x"yes"; then
CFLAGS="$CFLAGS -fwrapv"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports -fwrapv" >&5
$as_echo_n "checking whether $CXX supports -fwrapv... " >&6; }
if ${pgac_cv_prog_cxx_cxxflags__fwrapv+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$pgac_save_CXXFLAGS -fwrapv"
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
pgac_cv_prog_cxx_cxxflags__fwrapv=yes
else
pgac_cv_prog_cxx_cxxflags__fwrapv=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cxx_cxxflags__fwrapv" >&5
$as_echo "$pgac_cv_prog_cxx_cxxflags__fwrapv" >&6; }
if test x"$pgac_cv_prog_cxx_cxxflags__fwrapv" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -fwrapv"
fi
# Disable FP optimizations that cause various errors on gcc 4.5+ or maybe 4.6+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fexcess-precision=standard" >&5
$as_echo_n "checking whether $CC supports -fexcess-precision=standard... " >&6; }
......@@ -5373,6 +5624,53 @@ if test x"$pgac_cv_prog_cc_cflags__fexcess_precision_standard" = x"yes"; then
CFLAGS="$CFLAGS -fexcess-precision=standard"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports -fexcess-precision=standard" >&5
$as_echo_n "checking whether $CXX supports -fexcess-precision=standard... " >&6; }
if ${pgac_cv_prog_cxx_cxxflags__fexcess_precision_standard+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$pgac_save_CXXFLAGS -fexcess-precision=standard"
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
pgac_cv_prog_cxx_cxxflags__fexcess_precision_standard=yes
else
pgac_cv_prog_cxx_cxxflags__fexcess_precision_standard=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cxx_cxxflags__fexcess_precision_standard" >&5
$as_echo "$pgac_cv_prog_cxx_cxxflags__fexcess_precision_standard" >&6; }
if test x"$pgac_cv_prog_cxx_cxxflags__fexcess_precision_standard" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -fexcess-precision=standard"
fi
# We rely on /* fallthrough */ comments to signal explicit fallthrough, but
# some compilers (clang) don't recognize those and give spurious errors. Make
......@@ -5894,74 +6192,6 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
# Since PostgreSQL is written in pure C, all the tests in this file
# add necessary flags to CFLAGS only. We have some C++ code in
# src/backend/gpopt, so we must also configure CXXFLAGS in the same way.
# However, some CFLAGS might not be applicable to C++, so we cannot just
# use CFLAGS as is with the C++ compiler. Derive CXXFLAGS from CFLAGS,
# by picking those CFLAGS that also work with the C++ compiler.
#
# This assumes that the C++ compiler is roughly compatible with the C
# compiler, and accepts the same flags. While we test that each flag works
# with the C++ compiler, we would miss any flags that we would need for
# the C++ compiler, but not for the C compiler. For example, if you tried
# to use CC=clang and CXX=g++, we would not know to apply flags that are
# needed for g++, but not by clang. So don't mix and match compiler
# families!
# Loop over all options in CFLAGS, and check if they also work with CXX.
# Add to CXXFLAGS those that do.
for cflag in $CFLAGS; do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports $cflag" >&5
$as_echo_n "checking whether $CXX supports $cflag... " >&6; }
if { as_var=`$as_echo "pgac_cv_prog_cxx_cxxflags_$cflag" | $as_tr_sh`; eval \${$as_var+:} false; }; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$pgac_save_CXXFLAGS $cflag"
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
eval `$as_echo "pgac_cv_prog_cxx_cxxflags_$cflag" | $as_tr_sh`=yes
else
eval `$as_echo "pgac_cv_prog_cxx_cxxflags_$cflag" | $as_tr_sh`=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"
fi
eval ac_res=\$`$as_echo "pgac_cv_prog_cxx_cxxflags_$cflag" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test x"$`$as_echo "pgac_cv_prog_cxx_cxxflags_$cflag" | $as_tr_sh`" = x"yes"; then
CXXFLAGS="${CXXFLAGS} $cflag"
fi
done
# Defend against clang being used on x86-32 without SSE2 enabled. As current
# versions of clang do not understand -fexcess-precision=standard, the use of
# x87 floating point operations leads to problems like isinf possibly returning
......
......@@ -483,6 +483,21 @@ else
fi
fi
if test "$ac_env_CXXFLAGS_set" = set; then
CXXFLAGS=$ac_env_CXXFLAGS_value
elif test "${CXXFLAGS+set}" = set; then
: # (keep what template set)
elif test "$enable_coverage" = yes; then
: # no optimization by default
elif test "$GCC" = yes; then
CXXFLAGS="-O3"
else
# if the user selected debug mode, don't use -O
if test "$enable_debug" != yes; then
CXXFLAGS="-O"
fi
fi
# For GPDB, Use C99, rather than C89, compile rules
#
#
......@@ -599,19 +614,26 @@ fi
if test "$GCC" = yes -a "$ICC" = no; then
CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith"
CXXFLAGS="-Wall -Wpointer-arith"
# These work in some but not all gcc versions
# GPDB code is full of declarations after statement.
#PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
PGAC_PROG_CXX_CXXFLAGS_OPT([-Wendif-labels])
PGAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute])
PGAC_PROG_CXX_CXXFLAGS_OPT([-Wmissing-format-attribute])
# This was included in -Wall/-Wformat in older GCC versions
PGAC_PROG_CC_CFLAGS_OPT([-Wformat-security])
PGAC_PROG_CXX_CXXFLAGS_OPT([-Wformat-security])
# Disable strict-aliasing rules; needed for gcc 3.3+
PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
PGAC_PROG_CXX_CXXFLAGS_OPT([-fno-strict-aliasing])
# Disable optimizations that assume no overflow; needed for gcc 4.3+
PGAC_PROG_CC_CFLAGS_OPT([-fwrapv])
PGAC_PROG_CXX_CXXFLAGS_OPT([-fwrapv])
# Disable FP optimizations that cause various errors on gcc 4.5+ or maybe 4.6+
PGAC_PROG_CC_CFLAGS_OPT([-fexcess-precision=standard])
PGAC_PROG_CXX_CXXFLAGS_OPT([-fexcess-precision=standard])
# We rely on /* fallthrough */ comments to signal explicit fallthrough, but
# some compilers (clang) don't recognize those and give spurious errors. Make
......@@ -723,27 +745,6 @@ choke me
@%:@endif])], [], [AC_MSG_ERROR([do not put -ffast-math in CFLAGS])])
fi
# Since PostgreSQL is written in pure C, all the tests in this file
# add necessary flags to CFLAGS only. We have some C++ code in
# src/backend/gpopt, so we must also configure CXXFLAGS in the same way.
# However, some CFLAGS might not be applicable to C++, so we cannot just
# use CFLAGS as is with the C++ compiler. Derive CXXFLAGS from CFLAGS,
# by picking those CFLAGS that also work with the C++ compiler.
#
# This assumes that the C++ compiler is roughly compatible with the C
# compiler, and accepts the same flags. While we test that each flag works
# with the C++ compiler, we would miss any flags that we would need for
# the C++ compiler, but not for the C compiler. For example, if you tried
# to use CC=clang and CXX=g++, we would not know to apply flags that are
# needed for g++, but not by clang. So don't mix and match compiler
# families!
# Loop over all options in CFLAGS, and check if they also work with CXX.
# Add to CXXFLAGS those that do.
for cflag in $CFLAGS; do
PGAC_PROG_CXX_CXXFLAGS_OPT($cflag)
done
# Defend against clang being used on x86-32 without SSE2 enabled. As current
# versions of clang do not understand -fexcess-precision=standard, the use of
# x87 floating point operations leads to problems like isinf possibly returning
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册