Commit 2741ed91 authored by Benjamin Peterson's avatar Benjamin Peterson

build without -fno-strict-aliasing when gcc isn't buggy #3326

Patch from Daniel Stutzbach
parent 89d7b308
...@@ -883,6 +883,9 @@ Extension Modules ...@@ -883,6 +883,9 @@ Extension Modules
Build Build
----- -----
- Issue #3326: Build Python without -fno-strict-aliasing when the gcc does not
give false warnings.
- Issue #1628484: The Makefile doesn't ignore the CFLAGS environment - Issue #1628484: The Makefile doesn't ignore the CFLAGS environment
variable anymore. It also forwards the LDFLAGS settings to the linker variable anymore. It also forwards the LDFLAGS settings to the linker
when building a shared library. when building a shared library.
......
#! /bin/sh #! /bin/sh
# From configure.in Revision: 78965 . # From configure.in Revision: 79401 .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 3.2. # Generated by GNU Autoconf 2.61 for python 3.2.
# #
...@@ -4569,14 +4569,16 @@ UNIVERSAL_ARCH_FLAGS= ...@@ -4569,14 +4569,16 @@ UNIVERSAL_ARCH_FLAGS=
# tweak BASECFLAGS based on compiler and platform # tweak BASECFLAGS based on compiler and platform
case $GCC in case $GCC in
yes) yes)
# Python violates C99 rules, by casting between incompatible # Python doesn't violate C99 aliasing rules, but older versions of
# pointer types. GCC may generate bad code as a result of that, # GCC produce warnings for legal Python code. Enable
# so use -fno-strict-aliasing if supported. # -fno-strict-aliasing on versions of GCC that support but produce
{ echo "$as_me:$LINENO: checking whether $CC accepts -fno-strict-aliasing" >&5 # warnings. See Issue3326
echo $ECHO_N "checking whether $CC accepts -fno-strict-aliasing... $ECHO_C" >&6; } { echo "$as_me:$LINENO: checking whether $CC accepts and needs -fno-strict-aliasing" >&5
echo $ECHO_N "checking whether $CC accepts and needs -fno-strict-aliasing... $ECHO_C" >&6; }
ac_save_cc="$CC" ac_save_cc="$CC"
CC="$CC -fno-strict-aliasing" CC="$CC -fno-strict-aliasing"
if test "${ac_cv_no_strict_aliasing_ok+set}" = set; then save_CFLAGS="$CFLAGS"
if test "${ac_cv_no_strict_aliasing+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
...@@ -4611,21 +4613,64 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 ...@@ -4611,21 +4613,64 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test -z "$ac_c_werror_flag" || test -z "$ac_c_werror_flag" ||
test ! -s conftest.err test ! -s conftest.err
} && test -s conftest.$ac_objext; then } && test -s conftest.$ac_objext; then
ac_cv_no_strict_aliasing_ok=yes CC="$ac_save_cc -fstrict-aliasing"
CFLAGS="$CFLAGS -Werror -Wstrict-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 ()
{
void f(int **x) {} int main() { double *x; f((int **) &x); return 0; }
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_no_strict_aliasing=no
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_no_strict_aliasing=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_no_strict_aliasing_ok=no ac_cv_no_strict_aliasing=no
fi fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi fi
CFLAGS="$save_CFLAGS"
CC="$ac_save_cc" CC="$ac_save_cc"
{ echo "$as_me:$LINENO: result: $ac_cv_no_strict_aliasing_ok" >&5 { echo "$as_me:$LINENO: result: $ac_cv_no_strict_aliasing" >&5
echo "${ECHO_T}$ac_cv_no_strict_aliasing_ok" >&6; } echo "${ECHO_T}$ac_cv_no_strict_aliasing" >&6; }
if test $ac_cv_no_strict_aliasing_ok = yes if test $ac_cv_no_strict_aliasing = yes
then then
BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
fi fi
......
...@@ -867,19 +867,26 @@ AC_SUBST(UNIVERSAL_ARCH_FLAGS) ...@@ -867,19 +867,26 @@ AC_SUBST(UNIVERSAL_ARCH_FLAGS)
# tweak BASECFLAGS based on compiler and platform # tweak BASECFLAGS based on compiler and platform
case $GCC in case $GCC in
yes) yes)
# Python violates C99 rules, by casting between incompatible # Python doesn't violate C99 aliasing rules, but older versions of
# pointer types. GCC may generate bad code as a result of that, # GCC produce warnings for legal Python code. Enable
# so use -fno-strict-aliasing if supported. # -fno-strict-aliasing on versions of GCC that support but produce
AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing) # warnings. See Issue3326
AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing)
ac_save_cc="$CC" ac_save_cc="$CC"
CC="$CC -fno-strict-aliasing" CC="$CC -fno-strict-aliasing"
AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok, save_CFLAGS="$CFLAGS"
AC_TRY_COMPILE([],[int main() { return 0; }], AC_CACHE_VAL(ac_cv_no_strict_aliasing,
ac_cv_no_strict_aliasing_ok=yes, AC_TRY_COMPILE([],[int main() { return 0; }],
ac_cv_no_strict_aliasing_ok=no)) 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" CC="$ac_save_cc"
AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok) AC_MSG_RESULT($ac_cv_no_strict_aliasing)
if test $ac_cv_no_strict_aliasing_ok = yes if test $ac_cv_no_strict_aliasing = yes
then then
BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
fi fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment