From 6bd9ec37356a38456dd8eef4a882abe6d9ce222b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 26 Mar 2011 14:44:08 -0600 Subject: [PATCH] enable link time optimization when using GCC 4.6 or greater --- makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/makefile b/makefile index d9921f3e3b..8d83a40982 100644 --- a/makefile +++ b/makefile @@ -354,9 +354,22 @@ ifeq ($(mode),stress-major) endif ifeq ($(mode),fast) optimization-cflags = -O3 -g3 -DNDEBUG + use-lto = true endif ifeq ($(mode),small) optimization-cflags = -Os -g3 -DNDEBUG + use-lto = true +endif + +ifeq ($(use-lto),true) +# only try to use LTO when GCC 4.6.0 or greater is available + gcc-major := $(shell $(cc) -dumpversion | cut -f1 -d.) + gcc-minor := $(shell $(cc) -dumpversion | cut -f2 -d.) + ifeq ($(shell expr 4 \< $(gcc-major) \ + \| \( 4 \<= $(gcc-major) \& 6 \<= $(gcc-minor) \)),1) + optimization-cflags += -flto + lflags += $(optimization-cflags) + endif endif cflags += $(optimization-cflags)