summaryrefslogtreecommitdiffstats
path: root/configure.in
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-03-30 17:34:47 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-03-30 17:34:47 (GMT)
commite6c9d24562adf4eddfcbeb6cc1873b3e6795e2eb (patch)
tree94f3a3a9aa204d231bbb6feb567a6a23db660976 /configure.in
parentfc91aa28fd8dad5280fd4d3a4747b5e08ee37ac0 (diff)
downloadcpython-e6c9d24562adf4eddfcbeb6cc1873b3e6795e2eb.zip
cpython-e6c9d24562adf4eddfcbeb6cc1873b3e6795e2eb.tar.gz
cpython-e6c9d24562adf4eddfcbeb6cc1873b3e6795e2eb.tar.bz2
build without -fno-strict-aliasing when gcc isn't buggy #3326
Patch from Daniel Stutzbach
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in27
1 files changed, 17 insertions, 10 deletions
diff --git a/configure.in b/configure.in
index 0109367..6a69413 100644
--- a/configure.in
+++ b/configure.in
@@ -867,19 +867,26 @@ AC_SUBST(UNIVERSAL_ARCH_FLAGS)
# tweak BASECFLAGS based on compiler and platform
case $GCC in
yes)
- # Python violates C99 rules, by casting between incompatible
- # pointer types. GCC may generate bad code as a result of that,
- # so use -fno-strict-aliasing if supported.
- AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
+ # Python doesn't violate C99 aliasing rules, but older versions of
+ # GCC produce warnings for legal Python code. Enable
+ # -fno-strict-aliasing on versions of GCC that support but produce
+ # warnings. See Issue3326
+ AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing)
ac_save_cc="$CC"
CC="$CC -fno-strict-aliasing"
- AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
- AC_TRY_COMPILE([],[int main() { return 0; }],
- ac_cv_no_strict_aliasing_ok=yes,
- ac_cv_no_strict_aliasing_ok=no))
+ save_CFLAGS="$CFLAGS"
+ AC_CACHE_VAL(ac_cv_no_strict_aliasing,
+ AC_TRY_COMPILE([],[int main() { return 0; }],
+ CC="$ac_save_cc -fstrict-aliasing"
+ CFLAGS="$CFLAGS -Werror -Wstrict-aliasing"
+ AC_TRY_COMPILE([],[void f(int **x) {} int main() { double *x; f((int **) &x); return 0; }],
+ ac_cv_no_strict_aliasing=no,
+ ac_cv_no_strict_aliasing=yes),
+ ac_cv_no_strict_aliasing=no))
+ CFLAGS="$save_CFLAGS"
CC="$ac_save_cc"
- AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
- if test $ac_cv_no_strict_aliasing_ok = yes
+ AC_MSG_RESULT($ac_cv_no_strict_aliasing)
+ if test $ac_cv_no_strict_aliasing = yes
then
BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
fi