From: Paul Eggert Date: Wed, 21 May 2025 17:07:04 +0000 (-0700) Subject: Work around GCC bug 117423 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=781ecb5fd90c89988b97540f90ee290744615667;p=emacs.git Work around GCC bug 117423 Problem reported by Oliver Reiter and Pip Cet (Emacs bug#78473). It looks like GCC tree-sra is trouble in general with how Emacs uses unions, so disable tree-sra until the GCC bug is fixed. * configure.ac (C_SWITCH_MACHINE): Also work around GCC bug 117423. (cherry picked from commit 9dfc605654bea7a1346da224cf7e1eec850e05c4) --- diff --git a/configure.ac b/configure.ac index e57cf55fe86..5946529100f 100644 --- a/configure.ac +++ b/configure.ac @@ -2319,21 +2319,51 @@ esac C_SWITCH_MACHINE= -test $with_unexec = yes && -case $canonical in - alpha*) - ## With ELF, make sure that all common symbols get allocated to in the - ## data section. Otherwise, the dump of temacs may miss variables in - ## the shared library that have been initialized. For example, with - ## GNU libc, __malloc_initialized would normally be resolved to the - ## shared library's .bss section, which is fatal. - if test "x$GCC" = "xyes"; then - C_SWITCH_MACHINE="-fno-common" - else - AC_MSG_ERROR([Non-GCC compilers are not supported.]) - fi - ;; -esac +AC_CACHE_CHECK([for flag to work around GCC bug 117423], + [emacs_cv_gcc_bug_117423_CFLAGS], + [emacs_cv_gcc_bug_117423_CFLAGS='none needed' + AS_IF([test "$GCC" = yes], + [old_CFLAGS=$CFLAGS + # If no flags are needed (e.g., not GCC 4+), don't use any. + # Otherwise, use -fno-tree-sra. + for emacs_cv_gcc_bug_117423_CFLAGS in \ + 'none needed' -fno-tree-sra + do + AS_CASE([$emacs_cv_gcc_bug_117423_CFLAGS], + ['none needed'], [], + [-fno-tree-sra], [break], + [CFLAGS="$old_CFLAGS $emacs_cv_gcc_bug_117423_CFLAGS"]) + AC_COMPILE_IFELSE( + [AC_LANG_DEFINES_PROVIDED + [/* Work around GCC bug 117423 with unions containing holes: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117423 + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119085 + GCC bug 117423 is present even in GCC 15.1, + the current version as of this writing; for now, + assume it is present in all GCC versions starting with GCC 4. + + Working wround GCC bug 117423 also works around GCC bug 58416 + with double in unions on x86, where the generated insns + copy non-floating-point data via fldl/fstpl instruction pairs. + This can misbehave if 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 + Although GCC bug 58416 is fixed in GCC 15.1, + GCC bug 117423 is still present there. */ + #if 4 <= __GNUC__ && !defined __clang__ + # error "GCC bug 117423 possibly present" + #endif + ]], + [break]) + done + CFLAGS=$old_CFLAGS])]) +AS_CASE([$emacs_cv_gcc_bug_117423_CFLAGS], + [-*], + [C_SWITCH_MACHINE="$C_SWITCH_MACHINE $emacs_cv_gcc_bug_117423_CFLAGS"]) + AC_SUBST([C_SWITCH_MACHINE]) C_SWITCH_SYSTEM=