Use -fno-strict-aliasing if available. Fixes #766696. Will backport to 2.2.

This commit is contained in:
Martin v. Löwis 2003-07-07 21:26:19 +00:00
parent dfda8d79ee
commit 70fedcd583
2 changed files with 60 additions and 1 deletions

45
configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# From configure.in Revision: 1.421 . # From configure.in Revision: 1.422 .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.53 for python 2.3. # Generated by GNU Autoconf 2.53 for python 2.3.
# #
@ -3645,6 +3645,49 @@ fi
# 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
# 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
ac_save_cc="$CC"
CC="$CC -fno-strict-aliasing"
if test "$cross_compiling" = yes; then
ac_cv_no_strict_aliasing_ok=no
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
int main() { return 0; }
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_no_strict_aliasing_ok=yes
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
( exit $ac_status )
ac_cv_no_strict_aliasing_ok=no
fi
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
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
then
BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
fi
case $ac_sys_system in case $ac_sys_system in
SCO_SV*) SCO_SV*)
BASECFLAGS="$BASECFLAGS -m486 -DSCO5" BASECFLAGS="$BASECFLAGS -m486 -DSCO5"

View File

@ -641,6 +641,22 @@ AC_SUBST(BASECFLAGS)
# 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
# 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)
ac_save_cc="$CC"
CC="$CC -fno-strict-aliasing"
AC_TRY_RUN([int main() { return 0; }],
ac_cv_no_strict_aliasing_ok=yes,
ac_cv_no_strict_aliasing_ok=no,
ac_cv_no_strict_aliasing_ok=no)
CC="$ac_save_cc"
AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
if test $ac_cv_no_strict_aliasing_ok = yes
then
BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
fi
case $ac_sys_system in case $ac_sys_system in
SCO_SV*) SCO_SV*)
BASECFLAGS="$BASECFLAGS -m486 -DSCO5" BASECFLAGS="$BASECFLAGS -m486 -DSCO5"