This patch:
- Disables incremental linking by default. /INCREMENTAL adds extra thunks in the EXE, which makes execution slower.
- Sets /MT (static CRT lib) by default instead of CMake's default /MD (dll CRT lib). The previous default /MD makes all DLL functions to be thunked, thus making execution slower (memcmp, memset, etc.)
- Adds LLVM_ENABLE_INCREMENTAL_LINK which is set to OFF by default.
DLL thunks:
/INCREMENTAL thunks:
I thought it'd be better if Clang / LLVM / LLD would be fast out-of-the-box, instead of people having to dig for "good" settings.
Below are timings for linking a large DLL with LLD. The type merging pass is dominant, and is affected by those two options, because of the tight merge loop. I currently have several optimisations in that loop that tend to increase the gap.
Without this patch (default cmake settings):
Type Merging: 23174 ms ( 56.9%)
With this patch (new default cmake settings):
Type Merging: 22338 ms ( 52.2%)
This is a MSVC-only change. Tested with VS2017 15.9.1 (MSVC 19.16.27023.1 x64)
Isn't it a bad practice to statically link the CRT into DLLs? We have a few (LLDB), and this will get picked up by it. However, I notice that we set this option in the official build_llvm_package.bat script that @hans uses to make the Windows releases:
https://github.com/llvm-git-prototype/llvm/blob/master/llvm/utils/release/build_llvm_package.bat#L47
Anyway, this is just the default, and it's reasonable for people building clang, lld, and other static executables, which is most people.