mirror of https://github.com/python/cpython
build without -fno-strict-aliasing when gcc isn't buggy #3326
Patch from Daniel Stutzbach
This commit is contained in:
parent
fc91aa28fd
commit
e6c9d24562
|
@ -883,6 +883,9 @@ Extension Modules
|
|||
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
|
||||
variable anymore. It also forwards the LDFLAGS settings to the linker
|
||||
when building a shared library.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#! /bin/sh
|
||||
# From configure.in Revision: 78965 .
|
||||
# From configure.in Revision: 79401 .
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.61 for python 3.2.
|
||||
#
|
||||
|
@ -4569,14 +4569,16 @@ 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.
|
||||
{ echo "$as_me:$LINENO: checking whether $CC accepts -fno-strict-aliasing" >&5
|
||||
echo $ECHO_N "checking whether $CC accepts -fno-strict-aliasing... $ECHO_C" >&6; }
|
||||
# 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
|
||||
{ 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"
|
||||
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
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
|
@ -4611,21 +4613,64 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
|||
test -z "$ac_c_werror_flag" ||
|
||||
test ! -s conftest.err
|
||||
} && 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_ok=no
|
||||
ac_cv_no_strict_aliasing=yes
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_cv_no_strict_aliasing=no
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
|
||||
CFLAGS="$save_CFLAGS"
|
||||
CC="$ac_save_cc"
|
||||
{ echo "$as_me:$LINENO: result: $ac_cv_no_strict_aliasing_ok" >&5
|
||||
echo "${ECHO_T}$ac_cv_no_strict_aliasing_ok" >&6; }
|
||||
if test $ac_cv_no_strict_aliasing_ok = yes
|
||||
{ echo "$as_me:$LINENO: result: $ac_cv_no_strict_aliasing" >&5
|
||||
echo "${ECHO_T}$ac_cv_no_strict_aliasing" >&6; }
|
||||
if test $ac_cv_no_strict_aliasing = yes
|
||||
then
|
||||
BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
|
||||
fi
|
||||
|
|
27
configure.in
27
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
|
||||
|
|
Loading…
Reference in New Issue