diff options
| author | Paul Eggert | 2024-07-19 13:39:21 -0700 |
|---|---|---|
| committer | Paul Eggert | 2024-07-19 14:23:11 -0700 |
| commit | 9f4fc6608212191e1a9e07bf89f38ba9e4ea786c (patch) | |
| tree | 044a7d187dc38dc66214f7636f42afd46e3518da | |
| parent | 524e9d50a78c019ab23ecf469787d5ff6c119025 (diff) | |
| download | emacs-9f4fc6608212191e1a9e07bf89f38ba9e4ea786c.tar.gz emacs-9f4fc6608212191e1a9e07bf89f38ba9e4ea786c.zip | |
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.
| -rw-r--r-- | configure.ac | 45 | ||||
| -rw-r--r-- | etc/NEWS | 6 |
2 files changed, 51 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index b6acdf2e456..67da852667d 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -2333,6 +2333,51 @@ case $canonical in | |||
| 2333 | fi | 2333 | fi |
| 2334 | ;; | 2334 | ;; |
| 2335 | esac | 2335 | esac |
| 2336 | |||
| 2337 | AC_CACHE_CHECK([for flags to work around GCC bug 58416], | ||
| 2338 | [emacs_cv_gcc_bug_58416_CFLAGS], | ||
| 2339 | [emacs_cv_gcc_bug_58416_CFLAGS='none needed' | ||
| 2340 | AS_CASE([$canonical], | ||
| 2341 | [[i[3456]86-* | x86_64-*]], | ||
| 2342 | [AS_IF([test "$GCC" = yes], | ||
| 2343 | [old_CFLAGS=$CFLAGS | ||
| 2344 | # If no flags are needed (e.g., not GCC 4+), don't use any. | ||
| 2345 | # Otherwise, use -mfpmath=sse if already assuming SSE2. | ||
| 2346 | # Otherwise, use -fno-tree-sra. | ||
| 2347 | for emacs_cv_gcc_bug_58416_CFLAGS in \ | ||
| 2348 | 'none needed' -mfpmath=sse -fno-tree-sra | ||
| 2349 | do | ||
| 2350 | AS_CASE([$emacs_cv_gcc_bug_58416_CFLAGS], | ||
| 2351 | ['none needed'], [], | ||
| 2352 | [-fno-tree-sra], [break], | ||
| 2353 | [CFLAGS="$old_CFLAGS $emacs_cv_gcc_bug_58416_CFLAGS"]) | ||
| 2354 | AC_COMPILE_IFELSE( | ||
| 2355 | [AC_LANG_DEFINES_PROVIDED | ||
| 2356 | [/* Work around GCC bug with double in unions on x86, | ||
| 2357 | where the generated insns copy non-floating-point data | ||
| 2358 | via fldl/fstpl instruction pairs. This can misbehave | ||
| 2359 | the data's bit pattern looks like a NaN. See, e.g.: | ||
| 2360 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58416#c10 | ||
| 2361 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71460 | ||
| 2362 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93271 | ||
| 2363 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114659 | ||
| 2364 | Problem observed with 'gcc -m32' with GCC 14.1.1 | ||
| 2365 | 20240607 (Red Hat 14.1.1-5) on x86-64. */ | ||
| 2366 | #include <float.h> | ||
| 2367 | #if \ | ||
| 2368 | (4 <= __GNUC__ && !defined __clang__ \ | ||
| 2369 | && (defined __i386__ || defined __x86_64__) \ | ||
| 2370 | && ! (0 <= FLT_EVAL_METHOD && FLT_EVAL_METHOD <= 1)) | ||
| 2371 | # error "GCC bug 58416 is possibly present" | ||
| 2372 | #endif | ||
| 2373 | ]], | ||
| 2374 | [break]) | ||
| 2375 | done | ||
| 2376 | CFLAGS=$old_CFLAGS])])]) | ||
| 2377 | AS_CASE([$emacs_cv_gcc_bug_58416_CFLAGS], | ||
| 2378 | [-*], | ||
| 2379 | [C_SWITCH_MACHINE="$C_SWITCH_MACHINE $emacs_cv_gcc_bug_58416_CFLAGS"]) | ||
| 2380 | |||
| 2336 | AC_SUBST([C_SWITCH_MACHINE]) | 2381 | AC_SUBST([C_SWITCH_MACHINE]) |
| 2337 | 2382 | ||
| 2338 | C_SWITCH_SYSTEM= | 2383 | C_SWITCH_SYSTEM= |
| @@ -24,6 +24,12 @@ applies, and please also update docstrings as needed. | |||
| 24 | 24 | ||
| 25 | * Installation Changes in Emacs 31.1 | 25 | * Installation Changes in Emacs 31.1 |
| 26 | 26 | ||
| 27 | ** When using GCC 4 or later to build Emacs on 32-bit x86 systems, | ||
| 28 | 'configure' now defaults to using the GCC options -mfpmath=sse (if the | ||
| 29 | host system supports SSE2) or -fno-tree-sra (if not). These GCC options | ||
| 30 | work around GCC bug 58416, which can cause Emacs to behave incorrectly | ||
| 31 | in rare cases. | ||
| 32 | |||
| 27 | 33 | ||
| 28 | * Startup Changes in Emacs 31.1 | 34 | * Startup Changes in Emacs 31.1 |
| 29 | 35 | ||