diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2011-08-19 23:06:13 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2011-08-22 12:54:53 +0200 |
commit | fc41132306cf8ff523fb26518154c1c99c3ca388 (patch) | |
tree | 0bd638f2f7f4dd799aeb38b271e45b5741bc8c94 | |
parent | 63eef1c1cf203aa75093b479a1e8dd24593546e7 (diff) |
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.
-rwxr-xr-x | configure.in | 19 | ||||
-rwxr-xr-x | set_soenv.in | 1 | ||||
-rw-r--r-- | solenv/gbuild/platform/macosx.mk | 8 | ||||
-rw-r--r-- | solenv/gbuild/platform/unxgcc.mk | 7 |
4 files changed, 35 insertions, 0 deletions
diff --git a/configure.in b/configure.in index 536ca8ba5e27..87522f7ac525 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 76681f3542b1..a65ac5f21f3b 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 d8f17db1d9cc..b074ff930b33 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 a9a5764a9ce3..5d0a4116e253 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))) \ |