[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1585370 1/2: Default gcc -Og to inlining key ops
From: |
Paul Eggert |
Subject: |
master 1585370 1/2: Default gcc -Og to inlining key ops |
Date: |
Sat, 4 Apr 2020 19:57:50 -0400 (EDT) |
branch: master
commit 15853707c8c36aff1d3cc19205971b88e04d007b
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Default gcc -Og to inlining key ops
Problem reported by Martin Rudalics in:
https://lists.gnu.org/r/emacs-devel/2020-04/msg00195.html
* configure.ac (DEFINE_KEY_OPS_AS_MACROS): Define if -Og.
* src/Makefile.in (KEY_OPS_CFLAGS): New macro.
(EMACS_CFLAGS): Use it.
* src/lisp.h (DEFINE_KEY_OPS_AS_MACROS): Let the gcc command line
specify it. Remove use of undocumented INLINING macro.
---
configure.ac | 7 +++++++
src/Makefile.in | 7 +++++--
src/lisp.h | 22 +++++++++++++---------
3 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
index 9907160..4e34a1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -938,6 +938,13 @@ if test "$ac_test_CFLAGS" != set; then
esac
fi
+case "$GCC, $CFLAGS " in
+ yes,*' -Og '*)
+ AC_DEFINE([DEFINE_KEY_OPS_AS_MACROS], 1,
+ [Define to 1 if key low-level operations should be C macros
+ instead of inline functions.])
+esac
+
# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
# ---------------------------------------------------------------------------
# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
diff --git a/src/Makefile.in b/src/Makefile.in
index 552dd2e..dfd32255 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -377,11 +377,14 @@ endif
# Flags that might be in WARN_CFLAGS but are not valid for Objective C.
NON_OBJC_CFLAGS = -Wignored-attributes -Wignored-qualifiers -Wopenmp-simd
+# Cajole GCC into inlining key ops even if it wouldn't normally.
+KEY_OPS_CFLAGS = $(if $(filter -Og,$(CFLAGS)),-DDEFINE_KEY_OPS_AS_MACROS)
+
# -Demacs makes some files produce the correct version for use in Emacs.
# MYCPPFLAGS is for by-hand Emacs-specific overrides, e.g.,
# "make MYCPPFLAGS='-DDBUS_DEBUG'".
-EMACS_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \
- -I$(lib) -I$(top_srcdir)/lib \
+EMACS_CFLAGS = -Demacs $(KEY_OPS_CFLAGS) $(MYCPPFLAGS) \
+ -I. -I$(srcdir) -I$(lib) -I$(top_srcdir)/lib \
$(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \
$(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \
$(PNG_CFLAGS) $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \
diff --git a/src/lisp.h b/src/lisp.h
index f223814..7fc3af9 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -411,15 +411,19 @@ typedef EMACS_INT Lisp_Word;
# define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
#endif
-/* When compiling via gcc -O0, define the key operations as macros, as
- Emacs is too slow otherwise. To disable this optimization, compile
- with -DINLINING=false. */
-#if (defined __NO_INLINE__ \
- && ! defined __OPTIMIZE__ && ! defined __OPTIMIZE_SIZE__ \
- && ! (defined INLINING && ! INLINING))
-# define DEFINE_KEY_OPS_AS_MACROS true
-#else
-# define DEFINE_KEY_OPS_AS_MACROS false
+/* When DEFINE_KEY_OPS_AS_MACROS, define key operations as macros to
+ cajole the compiler into inlining them; otherwise define them as
+ inline functions as this is cleaner and can be more efficient.
+ The default is true if the compiler is GCC-like and if function
+ inlining is disabled because the compiler is not optimizing or is
+ optimizing for size. Otherwise the default is false. */
+#ifndef DEFINE_KEY_OPS_AS_MACROS
+# if (defined __NO_INLINE__ \
+ && ! defined __OPTIMIZE__ && ! defined __OPTIMIZE_SIZE__)
+# define DEFINE_KEY_OPS_AS_MACROS true
+# else
+# define DEFINE_KEY_OPS_AS_MACROS false
+# endif
#endif
#if DEFINE_KEY_OPS_AS_MACROS