Add feature --enable-lto, link-time optimization.

Enabling link-time optimization turns debug information off (-g),
sine -flto and -g does not currently well work together.

Also stdlib-debug is turned off, does also not work well with -flto.
---
 config/lyxinclude.m4 | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index 2e529ea..67aea1f 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -236,6 +236,24 @@ AC_ARG_ENABLE(cxx11,
   AC_HELP_STRING([--enable-cxx11],[enable C++11 mode]),,
   enable_cxx11=no;)
 
+AC_ARG_ENABLE(lto,
+  AC_HELP_STRING([--enable-lto],[enable link time optimization]),,
+  enable_lto=no;)
+case $enable_lto in
+    yes)
+       lto_opt=-flto
+       enable_debug=no
+       enable_stdlib_debug=no
+       ;;
+    no)
+       lto_opt=;;
+    *)
+       lto_opt="-flto=${enable_lto}"
+       enable_debug=no
+       enable_stdlib_debug=no
+       ;;
+esac
+
 AC_ARG_ENABLE(assertions,
   AC_HELP_STRING([--enable-assertions],[add runtime sanity checks in the 
program]),,
   [AS_CASE([$build_type], [dev*|pre*], [enable_assertions=yes],
@@ -322,6 +340,15 @@ if test x$GXX = xyes; then
              ;;
       esac
   fi
+  if test x$enable_lto != xno ; then
+      case $gxx_version in
+         4.7*|4.8*)
+             lyx_flags="$lyx_flags link-time-optimization"
+             CFLAGS="$lto_opt $CFLAGS"
+             CXXFLAGS="$lto_opt $CXXFLAGS"
+             ;;
+      esac
+  fi
 fi
 test "$lyx_pch_comp" = yes && lyx_flags="$lyx_flags pch"
 AM_CONDITIONAL(LYX_BUILD_PCH, test "$lyx_pch_comp" = yes)
-- 
1.8.0

Reply via email to