Work around GCC bug 58416 on 32-bit x86
* configure.ac (C_SWITCH_MATCHINE): On 32-bit x86 with GCC 4+, append -mfpmath=sse (if SSE2 is known to work) or -fno-tree-sra (otherwise) to work around GCC bug 58416. * etc/NEWS: Mention this.
This commit is contained in:
parent
524e9d50a7
commit
9f4fc66082
2 changed files with 51 additions and 0 deletions
45
configure.ac
45
configure.ac
|
@ -2333,6 +2333,51 @@ case $canonical in
|
|||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_CACHE_CHECK([for flags to work around GCC bug 58416],
|
||||
[emacs_cv_gcc_bug_58416_CFLAGS],
|
||||
[emacs_cv_gcc_bug_58416_CFLAGS='none needed'
|
||||
AS_CASE([$canonical],
|
||||
[[i[3456]86-* | x86_64-*]],
|
||||
[AS_IF([test "$GCC" = yes],
|
||||
[old_CFLAGS=$CFLAGS
|
||||
# If no flags are needed (e.g., not GCC 4+), don't use any.
|
||||
# Otherwise, use -mfpmath=sse if already assuming SSE2.
|
||||
# Otherwise, use -fno-tree-sra.
|
||||
for emacs_cv_gcc_bug_58416_CFLAGS in \
|
||||
'none needed' -mfpmath=sse -fno-tree-sra
|
||||
do
|
||||
AS_CASE([$emacs_cv_gcc_bug_58416_CFLAGS],
|
||||
['none needed'], [],
|
||||
[-fno-tree-sra], [break],
|
||||
[CFLAGS="$old_CFLAGS $emacs_cv_gcc_bug_58416_CFLAGS"])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_DEFINES_PROVIDED
|
||||
[/* Work around GCC bug with double in unions on x86,
|
||||
where the generated insns copy non-floating-point data
|
||||
via fldl/fstpl instruction pairs. This can misbehave
|
||||
the data's bit pattern looks like a NaN. See, e.g.:
|
||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58416#c10
|
||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71460
|
||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93271
|
||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114659
|
||||
Problem observed with 'gcc -m32' with GCC 14.1.1
|
||||
20240607 (Red Hat 14.1.1-5) on x86-64. */
|
||||
#include <float.h>
|
||||
#if \
|
||||
(4 <= __GNUC__ && !defined __clang__ \
|
||||
&& (defined __i386__ || defined __x86_64__) \
|
||||
&& ! (0 <= FLT_EVAL_METHOD && FLT_EVAL_METHOD <= 1))
|
||||
# error "GCC bug 58416 is possibly present"
|
||||
#endif
|
||||
]],
|
||||
[break])
|
||||
done
|
||||
CFLAGS=$old_CFLAGS])])])
|
||||
AS_CASE([$emacs_cv_gcc_bug_58416_CFLAGS],
|
||||
[-*],
|
||||
[C_SWITCH_MACHINE="$C_SWITCH_MACHINE $emacs_cv_gcc_bug_58416_CFLAGS"])
|
||||
|
||||
AC_SUBST([C_SWITCH_MACHINE])
|
||||
|
||||
C_SWITCH_SYSTEM=
|
||||
|
|
6
etc/NEWS
6
etc/NEWS
|
@ -24,6 +24,12 @@ applies, and please also update docstrings as needed.
|
|||
|
||||
* Installation Changes in Emacs 31.1
|
||||
|
||||
** When using GCC 4 or later to build Emacs on 32-bit x86 systems,
|
||||
'configure' now defaults to using the GCC options -mfpmath=sse (if the
|
||||
host system supports SSE2) or -fno-tree-sra (if not). These GCC options
|
||||
work around GCC bug 58416, which can cause Emacs to behave incorrectly
|
||||
in rare cases.
|
||||
|
||||
|
||||
* Startup Changes in Emacs 31.1
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue