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)
As far as I understand, /MT is being disabled because it is required by LLDB that it be disabled. Is that correct? If that's the case, I think the message needs to change to be clearer. For example: "Disabling /MT *as* required by LLDB". Right now it reads like /MT is being disabled but it is required by LLDB.