Commit graph

2 commits

Author SHA1 Message Date
Johan Engelen
704d95c54c CMake: fix LTO build: prevent applying LTO flags when building the runtime libraries.
Resolves issue #2082
2017-04-29 15:24:39 +02:00
Johan Engelen
305fcddd57 [CMake] Add option to build LDC using LTO: -DLDC_BUILD_WITH_LTO={OFF, ON, FULL, THIN}.
When LDC_BUILD_WITH_LTO is set, the script adds -flto switch for the C++ compiler and D compiler, but only if they can create an executable with it.

Tested on OSX with ThinLTO (both with and without ThinLTO LLVM build). Some extra work is probably needed on Linux. On Windows, it won't do anything as the cmdline flag checks will fail.
On Linux, we should also enable the thinlto cache if possible.
Quick measurements indicate ~3% percent increased performance for -O0 and -O3 compilation, and a ~20% ldc2 file size reduction. Future step is adding PGO ;-)
2017-02-04 16:03:57 +01:00