[Libreoffice-commits] .: configure.in set_soenv.in solenv/gbuild

Matus Kukan mkukan at kemper.freedesktop.org
Mon Aug 22 03:57:29 PDT 2011


 configure.in                     |   19 +++++++++++++++++++
 set_soenv.in                     |    1 +
 solenv/gbuild/platform/macosx.mk |    8 ++++++++
 solenv/gbuild/platform/unxgcc.mk |    7 +++++++
 4 files changed, 35 insertions(+)

New commits:
commit fc41132306cf8ff523fb26518154c1c99c3ca388
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Fri Aug 19 23:06:13 2011 +0200

    enable using link-time optimization
    
    This commit enables LTO for all shared libraries.
    Build takes much longer. Use just with gcc-4.5 or later.

diff --git a/configure.in b/configure.in
index 536ca8b..87522f7 100755
--- a/configure.in
+++ b/configure.in
@@ -244,6 +244,13 @@ AC_ARG_ENABLE(dbgutil,
         [Include additional debugging utilities, such as assertions, object
          counting, etc. Larger build. Independent from --enable-debug]))
 
+AC_ARG_ENABLE(lto,
+    AS_HELP_STRING([--enable-lto],
+        [Enable link-time optimization. Suitable for product builds.
+         Building takes longer but libraries are optimized for speed.
+         (possible only with gcc-4.5 or later,
+          better to use gcc-4.6 and 'gold' as linker)]))
+
 AC_ARG_ENABLE(crashdump,
     AS_HELP_STRING([--enable-crashdump],
         [Enable the crashdump feature.]))
@@ -2229,6 +2236,18 @@ AC_SUBST(PRODUCT)
 AC_SUBST(PROFULLSWITCH)
 AC_SUBST(PROEXT)
 
+# Set the ENABLE_LTO variable
+# ===================================================================
+AC_MSG_CHECKING([whether to use link-time optimization])
+if test -n "$enable_lto" -a "$enable_lto" != "no"; then
+    ENABLE_LTO="TRUE"
+    AC_MSG_RESULT([yes])
+else
+    ENABLE_LTO=""
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST(ENABLE_LTO)
+
 dnl whether to include symbols into final build.
 dnl ===================================================================
 AC_MSG_CHECKING([whether to include symbols])
diff --git a/set_soenv.in b/set_soenv.in
index 76681f3..a65ac5f 100755
--- a/set_soenv.in
+++ b/set_soenv.in
@@ -1842,6 +1842,7 @@ ToFile( "MINGWCXX",          "@MINGWCXX@",       "e" );
 ToFile( "MINGWSTRIP",        "@MINGWSTRIP@",     "e" );
 ToFile( "WITH_STLPORT",      "@WITH_STLPORT@", "e" );
 ToFile( "ALLOC",             "@ALLOC@",          "e" );
+ToFile( "ENABLE_LTO",        "@ENABLE_LTO@",        "e" );
 ToFile( "ENABLE_SYMBOLS",    "@ENABLE_SYMBOLS@",    "e" );
 ToFile( "DISABLE_STRIP",     "@DISABLE_STRIP@",     "e" );
 ToFile( "LFS_CFLAGS",        "@LFS_CFLAGS@",     "e" );
diff --git a/solenv/gbuild/platform/macosx.mk b/solenv/gbuild/platform/macosx.mk
index d8f17db..b074ff9 100644
--- a/solenv/gbuild/platform/macosx.mk
+++ b/solenv/gbuild/platform/macosx.mk
@@ -120,6 +120,10 @@ gb_CFLAGS_WERROR := -Werror
 gb_CXXFLAGS_WERROR := -Werror
 endif
 
+ifeq ($(ENABLE_LTO),TRUE)
+gb_Library_LTOFLAGS := -flto
+endif
+
 gb_LinkTarget_EXCEPTIONFLAGS := \
 	-DEXCEPTIONS_ON \
 	-fexceptions \
@@ -191,6 +195,7 @@ $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) $(dir $(4)) && \
 	$(gb_CC) \
 		$(DEFS) \
+		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_LTOFLAGS)) \
 		$(T_CFLAGS) \
 		-c $(3) \
 		-o $(1) \
@@ -210,6 +215,7 @@ $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) $(dir $(4)) && \
 	$(gb_CXX) \
 		$(DEFS) \
+		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_LTOFLAGS)) \
 		$(T_CXXFLAGS) \
 		-c $(3) \
 		-o $(1) \
@@ -309,12 +315,14 @@ $(call gb_Helper_abbreviate_dirs,\
 	$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
 		$(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
 		$(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
+		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_LTOFLAGS)) \
 		$(subst \d,$$,$(RPATH)) \
 		$(T_LDFLAGS) \
 		$(patsubst lib%.dylib,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) > $${DYLIB_FILE} && \
 	$(gb_CXX) \
 		$(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
 		$(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
+		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_LTOFLAGS)) \
 		$(subst \d,$$,$(RPATH)) \
 		$(T_LDFLAGS) \
 		$(call gb_LinkTarget__get_liblinkflags,$(LINKED_LIBS)) \
diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk
index a9a5764..5d0a411 100644
--- a/solenv/gbuild/platform/unxgcc.mk
+++ b/solenv/gbuild/platform/unxgcc.mk
@@ -121,6 +121,10 @@ ifeq ($(HAVE_CXX0X),TRUE)
 gb_CXXFLAGS += -std=c++0x -Wno-deprecated-declarations
 endif
 
+ifeq ($(ENABLE_LTO),TRUE)
+gb_Library_LTOFLAGS := -flto
+endif
+
 ifneq ($(strip $(SYSBASE)),)
 gb_CXXFLAGS += --sysroot=$(SYSBASE)
 gb_CFLAGS += --sysroot=$(SYSBASE)
@@ -205,6 +209,7 @@ $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) $(dir $(4)) && \
 	$(gb_CC) \
 		$(DEFS) \
+		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_LTOFLAGS)) \
 		$(T_CFLAGS) \
 		-c $(3) \
 		-o $(1) \
@@ -224,6 +229,7 @@ $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) $(dir $(4)) && \
 	$(gb_CXX) \
 		$(DEFS) \
+		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_LTOFLAGS)) \
 		$(T_CXXFLAGS) \
 		-c $(3) \
 		-o $(1) \
@@ -288,6 +294,7 @@ $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) && \
 	$(gb_CXX) \
 		$(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
+		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_LTOFLAGS)) \
 		$(subst \d,$$,$(RPATH)) \
 		$(T_LDFLAGS) \
 		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \


More information about the Libreoffice-commits mailing list