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 ;-)