summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-02-18 10:20:38 +0100
committerLuboš Luňák <l.lunak@collabora.com>2020-02-19 10:27:43 +0100
commite957382700ed9237d4a7b374cd76bec466f5231c (patch)
tree71f94d798edd8fa64707caf41a2c8066d4ca95d9
parente62b9937ed33388055560ca0710990742b530aec (diff)
add --enable-optimized=debug
This will use -Og with GCC/Clang instead of -O0, which should make unittests run faster without (hopefully) breaking anything related to debugging. This is primarily meant to Jenkins builds, where debug info is rarely needed (backtraces for unittest crashes AFAICT). This can be also used to make LO itself run faster when developing, but I personally do not find it worth it (with Clang and full PCH this makes starmath build take about 70% longer, although presumably for non-PCH builds the relative increase will be smaller). Change-Id: I198d0759ebca94c90be662e02e0f1281a24d1d70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88917 Reviewed-by: Michael Stahl <michael.stahl@cib.de> Reviewed-by: Luboš Luňák <l.lunak@collabora.com> Tested-by: Jenkins
-rw-r--r--config_host.mk.in1
-rw-r--r--configure.ac30
-rw-r--r--solenv/gbuild/LinkTarget.mk6
-rw-r--r--solenv/gbuild/platform/com_GCC_defs.mk1
-rw-r--r--solenv/gbuild/platform/com_MSC_defs.mk1
5 files changed, 34 insertions, 5 deletions
diff --git a/config_host.mk.in b/config_host.mk.in
index 64a1a6627386..9e8b0c2304e9 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -177,6 +177,7 @@ export ENABLE_OOENV=@ENABLE_OOENV@
export ENABLE_OPENGL_TRANSITIONS=@ENABLE_OPENGL_TRANSITIONS@
export ENABLE_OPENGL_CANVAS=@ENABLE_OPENGL_CANVAS@
export ENABLE_OPTIMIZED=@ENABLE_OPTIMIZED@
+export ENABLE_OPTIMIZED_DEBUG=@ENABLE_OPTIMIZED_DEBUG@
export ENABLE_PCH=@ENABLE_PCH@
export ENABLE_PDFIMPORT=@ENABLE_PDFIMPORT@
export ENABLE_PDFIUM=@ENABLE_PDFIUM@
diff --git a/configure.ac b/configure.ac
index 60ece7a9af17..0b728af2e5fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1194,10 +1194,11 @@ libo_FUZZ_ARG_ENABLE(symbols,
Example: --enable-symbols="all -sw/ -Library_sc".]))
libo_FUZZ_ARG_ENABLE(optimized,
- AS_HELP_STRING([--disable-optimized],
+ AS_HELP_STRING([--enable-optimized=<yes/no/debug>],
[Whether to compile with optimization flags.
By default, disabled for --enable-debug and --enable-dbgutil, enabled
- otherwise.]))
+ otherwise. Using 'debug' will try to use only optimizations that should
+ not interfere with debugging.]))
libo_FUZZ_ARG_ENABLE(runtime-optimizations,
AS_HELP_STRING([--disable-runtime-optimizations],
@@ -4204,6 +4205,8 @@ if test -n "$with_android_ndk" -a \( -n "$ENABLE_SYMBOLS" -o -n "$ENABLE_DEBUG"
fi
fi
+ENABLE_OPTIMIZED=
+ENABLE_OPTIMIZED_DEBUG=
AC_MSG_CHECKING([whether to compile with optimization flags])
if test -z "$enable_optimized"; then
if test -n "$ENABLE_DEBUG$ENABLE_DBGUTIL"; then
@@ -4212,14 +4215,33 @@ if test -z "$enable_optimized"; then
enable_optimized=yes
fi
fi
-if test "$enable_optimized" != no; then
+if test "$enable_optimized" = yes; then
ENABLE_OPTIMIZED=TRUE
AC_MSG_RESULT([yes])
+elif test "$enable_optimized" = debug; then
+ ENABLE_OPTIMIZED_DEBUG=TRUE
+ AC_MSG_RESULT([yes (debug)])
+ HAVE_GCC_OG=
+ if test "$GCC" = "yes"; then
+ AC_MSG_CHECKING([whether $CC_BASE supports -Og])
+ save_CFLAGS=$CFLAGS
+ CFLAGS="$CFLAGS -Werror -Og"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_OG=TRUE ],[])
+ CFLAGS=$save_CFLAGS
+ if test "$HAVE_GCC_OG" = "TRUE"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ if test -z "$HAVE_GCC_OG"; then
+ AC_MSG_ERROR([The compiler does not support optimizations suitable for debugging.])
+ fi
else
- ENABLE_OPTIMIZED=
AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_OPTIMIZED)
+AC_SUBST(ENABLE_OPTIMIZED_DEBUG)
#
# determine CPUNAME, OS, ...
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index 914c36d35cd2..9e14f599b690 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -44,7 +44,11 @@ gb_LinkTarget__symbols_enabled = \
$(filter $(1),$(ENABLE_SYMBOLS_FOR))))
# debug flags, if the LinkTarget is named in the list of libraries of ENABLE_SYMBOLS_FOR
-gb_LinkTarget__get_debugflags=$(if $(ENABLE_OPTIMIZED),$(gb_COMPILEROPTFLAGS),$(gb_COMPILERNOOPTFLAGS)) $(if $(call gb_LinkTarget__symbols_enabled,$(1)),$(gb_DEBUGINFO_FLAGS))
+gb_LinkTarget__get_debugflags= \
+$(if $(ENABLE_OPTIMIZED),$(gb_COMPILEROPTFLAGS), \
+$(if $(ENABLE_OPTIMIZED_DEBUG),$(gb_COMPILERDEBUGOPTFLAGS), \
+$(gb_COMPILERNOOPTFLAGS))) \
+$(if $(call gb_LinkTarget__symbols_enabled,$(1)),$(gb_DEBUGINFO_FLAGS))
# similar for LDFLAGS, use linker optimization flags in non-debug case,
# but moreover strip debug from libraries for which debuginfo is not wanted
diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk
index 530bc16e8da3..cc0eabc292f2 100644
--- a/solenv/gbuild/platform/com_GCC_defs.mk
+++ b/solenv/gbuild/platform/com_GCC_defs.mk
@@ -201,6 +201,7 @@ gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
# optimization level
gb_COMPILERNOOPTFLAGS := -O0 -fstrict-aliasing -fstrict-overflow
+gb_COMPILERDEBUGOPTFLAGS := -Og
ifeq ($(OS),ANDROID)
gb_DEBUGINFO_FLAGS=-glldb
diff --git a/solenv/gbuild/platform/com_MSC_defs.mk b/solenv/gbuild/platform/com_MSC_defs.mk
index 11c1aa6d4b49..7409cffa1f40 100644
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -265,6 +265,7 @@ gb_LINKER_DEBUGINFO_FLAGS :=
gb_COMPILEROPTFLAGS := -O2 -Oy-
gb_COMPILERNOOPTFLAGS := -Od
+gb_COMPILERDEBUGOPTFLAGS :=
ifeq ($(gb_FULLDEPS),$(true))
gb_COMPILERDEPFLAGS := -showIncludes