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 /solenv | |
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.
Diffstat (limited to 'solenv')
-rw-r--r-- | solenv/gbuild/platform/macosx.mk | 8 | ||||
-rw-r--r-- | solenv/gbuild/platform/unxgcc.mk | 7 |
2 files changed, 15 insertions, 0 deletions
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))) \ |