Hi,
I saw that gcc-4.8 introduced a new optimization level -Og which enables
optimizations that do not interfere with debugging.
Yesterday I floated the idea on IRC of using this with --enable-debug
rather than -O0 if available, and some feedback was that it enables gcc
to report extra warnings which would be a good thing.
I tried it out and can see that it does indeed break the build if
--enable-werror is enabled, eg:
/home/deller/build/libo/vcl/unx/glxtest.cxx: In function ‘void glxtest()’:
/home/deller/build/libo/vcl/unx/glxtest.cxx:236:44: error: ignoring
return value of ‘ssize_t write(int, const void*, size_t)’, declared with
attribute warn_unused_result [-Werror=unused-result]
write(write_end_of_the_pipe, buf, length);
So I guess this means we couldn't incorporate -Og until all these new
warnings are fixed right?
Any other thoughts on whether this is a good idea to pursue? One fear
was that it might slow down compilation, but it doesn't actually seem to
slow down "make clean && make" much at all for me. I'll get some proper
timing measurements.
(A draft patch is attached to enable -Og if available)
Regards,
Luke.
commit 46809cf5731ae9d2ccbe22b38865242779658225
Author: Luke Deller <[email protected]>
Date: Wed Jan 14 23:48:36 2015 +1100
enable optimization (-Og) with --enable-debug
gcc-4.8 introduced a new optimization level -Og which enables
optimizations that do not interfere with debugging.
When configured with --enable-debug, use -Og rather than -O0
if available.
Change-Id: Iff3f98d736681ae34e49b96510228a14ce456b34
diff --git a/config_host.mk.in b/config_host.mk.in
index 26e38ea..131b348 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -247,6 +247,7 @@ export HAVE_GCC_FNO_DEFAULT_INLINE=@HAVE_GCC_FNO_DEFAULT_INLINE@
export HAVE_GCC_FNO_ENFORCE_EH_SPECS=@HAVE_GCC_FNO_ENFORCE_EH_SPECS@
export HAVE_GCC_FNO_INLINE=@HAVE_GCC_FNO_INLINE@
export HAVE_GCC_GGDB2=@HAVE_GCC_GGDB2@
+export HAVE_GCC_OG=@HAVE_GCC_OG@
export HAVE_GCC_PRAGMA_OPERATOR=@HAVE_GCC_PRAGMA_OPERATOR@
export HAVE_GCC_VISIBILITY_BROKEN=@HAVE_GCC_VISIBILITY_BROKEN@
export HAVE_GCC_VISIBILITY_FEATURE=@HAVE_GCC_VISIBILITY_FEATURE@
diff --git a/configure.ac b/configure.ac
index ac3dc4e..449ce54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3223,6 +3223,7 @@ AC_SUBST(GCC_VERSION)
HAVE_GCC_GGDB2=
HAVE_GCC_FINLINE_LIMIT=
HAVE_GCC_FNO_INLINE=
+HAVE_GCC_OG=
if test "$GCC" = "yes"; then
AC_MSG_CHECKING([whether $CC supports -ggdb2])
if test -n "$CLANGVER" -a 0"$CLANGVER" -le 30100; then
@@ -3272,10 +3273,24 @@ if test "$GCC" = "yes"; then
else
AC_MSG_RESULT([no])
fi
+
+ AC_MSG_CHECKING([whether $CC supports -Og])
+ # Note that clang-3.1 reports a real error for this option
+ # so we do not need a special case for clang<=3.1 as above.
+ 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
AC_SUBST(HAVE_GCC_GGDB2)
AC_SUBST(HAVE_GCC_FINLINE_LIMIT)
AC_SUBST(HAVE_GCC_FNO_INLINE)
+AC_SUBST(HAVE_GCC_OG)
HAVE_LD_BSYMBOLIC_FUNCTIONS=
if test "$GCC" = "yes"; then
diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk
index 7acd068..715bd54 100644
--- a/solenv/gbuild/platform/com_GCC_defs.mk
+++ b/solenv/gbuild/platform/com_GCC_defs.mk
@@ -139,7 +139,13 @@ endif
gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
# optimization level
+# Use -Og if available (gcc-4.8+), which enables optimizations that do not
+# interfere with debugging.
+ifeq ($(HAVE_GCC_OG),TRUE)
+gb_COMPILERNOOPTFLAGS := -Og -fstrict-aliasing -fstrict-overflow
+else
gb_COMPILERNOOPTFLAGS := -O0 -fstrict-aliasing -fstrict-overflow
+endif
# Clang does not know -ggdb2 or some other options
ifeq ($(HAVE_GCC_GGDB2),TRUE)
_______________________________________________
LibreOffice mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice