From a7f703f8c1f07c02c3d9be0662de02e4a70f98f8 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 6 Aug 2012 15:27:53 +0200 Subject: [PATCH] build: add --disable-optimizations option We are in a state where redrawing the console can take a significant amount of time on slower machines. Therefore, we definitely need gcc code optimizations which help here a _lot_. However, they are currently bundled to the debug flags. This splits this into two options. We still need this flag to get getter backtraces. Otherwise, those inlined functions are horrible to track done. Signed-off-by: David Herrmann --- Makefile.am | 13 +++++++++---- configure.ac | 19 ++++++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6ac9e63..324c4ee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,8 +49,9 @@ lib_LTLIBRARIES = \ # Also make the linker discard all unused symbols as we are not building a # shared library. # -# When compiling in debug mode, we disable optimization and enable debug symbols -# so debugging with gdb is easier. +# When compiling in debug mode, we enable debug symbols so debugging with gdb +# is easier. If optimizations are disabled, we pass -O0 to the compiler. +# Otherwise, we use standard optimizations -O2. # AM_CFLAGS = \ @@ -63,9 +64,13 @@ AM_LDFLAGS = \ -Wl,--as-needed if DEBUG -AM_CFLAGS += -O0 -g -else +AM_CFLAGS += -g +endif + +if OPTIMIZATIONS AM_CFLAGS += -O2 +else +AM_CFLAGS += -O0 endif # diff --git a/configure.ac b/configure.ac index 3e0990b..8c9f7a4 100644 --- a/configure.ac +++ b/configure.ac @@ -154,10 +154,16 @@ AC_ARG_ENABLE([debug], [whether to build with debugging on])]) AC_MSG_RESULT([ok]) +AC_MSG_CHECKING([whether to disable code optimizations]) +AC_ARG_ENABLE([optimizations], + [AS_HELP_STRING([--disable-optimizations], + [whether to disable code optimizations])]) +AC_MSG_RESULT([ok]) + # -# Debug mode -# In debug mode we use -g -O0 for compilation and set several flags so verbose -# logging is possible. +# Debug mode and code optimizations +# In debug mode we compile with -g and enable several debug-messages and flags. +# With optimizations (default), we add -O2 to compile-flags. # debug_enabled=no @@ -165,6 +171,11 @@ if test x$enable_debug = xyes ; then debug_enabled=yes fi +optimizations_enabled=no +if test ! x$enable_optimizations = xno ; then + optimizations_enabled=yes +fi + if test x$debug_enabled = xyes ; then AC_DEFINE([KMSCON_ENABLE_DEBUG], [1], [Enable debug for kmscon]) @@ -177,6 +188,7 @@ else fi AM_CONDITIONAL([DEBUG], [test x$debug_enabled = xyes]) +AM_CONDITIONAL([OPTIMIZATIONS], [test x$optimizations_enabled = xyes]) # # Main dependencies @@ -464,6 +476,7 @@ AC_OUTPUT([src/genshader.c]) AC_MSG_NOTICE([Build configuration: debug: $debug_enabled + optimizations: $optimizations_enabled systemd: $systemd_enabled udev: $udev_enabled