mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
build without -fno-strict-aliasing when gcc isn't buggy #3326
Patch from Daniel Stutzbach
This commit is contained in:
parent
fc91aa28fd
commit
e6c9d24562
3 changed files with 77 additions and 22 deletions
69
configure
vendored
69
configure
vendored
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue