diff options
author | Adam Borowski <kilobyte@angband.pl> | 2013-02-24 02:44:31 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2013-02-24 04:10:49 +0100 |
commit | f10de61e79ced7e7e2587986c981659867281b74 (patch) | |
tree | ae15e181a36ae62c21eb0dbf228a73c0e23ca733 /crawl-ref/source/Makefile | |
parent | 97cd1d7d0faae73525cec5413759368c512f123e (diff) | |
download | crawl-ref-f10de61e79ced7e7e2587986c981659867281b74.tar.gz crawl-ref-f10de61e79ced7e7e2587986c981659867281b74.zip |
Work around a gcc misdesign that nearly doubles the time of LTO compilation.
Someone had a bright idea of doing all compilation twice to placate broken
build systems:
traditional build:
.c -> .o: parsing, compilation, assembly
.o -> exe: link
LTO -ffat-lto-objects:
.c -> .o: parsing, compilation, assembly
.o -> exe: compilation, assembly, link
LTO -fno-fat-lto-objects:
.c -> .o: parsing
.o -> exe: compilation, assembly, link
The design decision was to create "fat objects" to be able to silently
revert to non-LTO mode if the build system fails to pass appropriate flags
in the second stage. Since gcc-4.7, it's possible to turn that off, but
the default is still compiling twice (why?!?!?).
With this fix, LTO builds take hardly more CPU than regular ones, although
some parts are still single-threaded.
Diffstat (limited to 'crawl-ref/source/Makefile')
-rw-r--r-- | crawl-ref/source/Makefile | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crawl-ref/source/Makefile b/crawl-ref/source/Makefile index 76670ca2f1..071d9b999f 100644 --- a/crawl-ref/source/Makefile +++ b/crawl-ref/source/Makefile @@ -119,10 +119,6 @@ CFOPTIMIZE := -O2 endif # USE_ICC -ifdef LTO -CFOPTIMIZE += -flto=jobserver -fwhole-program -endif - CFOTHERS := -pipe $(EXTERNAL_FLAGS) CFWARN := -Wall -Wformat-security CFWARN_L := -Wundef @@ -539,6 +535,14 @@ CFOPTIMIZE += -march=native endif endif +ifdef LTO +CFOPTIMIZE += -flto=jobserver -fwhole-program + # FIXME: this check is fragile, and should be done via a full compile test. + ifeq ($(shell $(GXX) -x c++ /dev/null -fno-fat-lto-objects 2>&1 | grep 'unrecognized command line option'),) + CFOPTIMIZE += -fno-fat-lto-objects + endif +endif + # Okay, we have to assume we're on something else that # uses standard UNIX-like methods for finding libs. # |