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 <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-08-06 15:27:53 +02:00
parent d057ecadae
commit a7f703f8c1
2 changed files with 25 additions and 7 deletions

View File

@ -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
#

View File

@ -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