@@ -50,6 +50,17 @@ macro(set_flag_in_var flagsvar regex flag)
50
50
set (${flagsvar} "${${flagsvar} }" CACHE STRING "${flagsvar_docs} " FORCE)
51
51
endmacro (set_flag_in_var)
52
52
53
+ macro (disable_MT_if_LLDB build message)
54
+ if (LLVM_TOOL_LLDB_BUILD)
55
+ if ((NOT ${build} STREQUAL "DEBUG" ) AND (LLVM_USE_CRT_${build} STREQUAL "MT" ))
56
+ if (LLVM_TOOL_CLANG_BUILD OR LLVM_TOOL_LLD_BUILD)
57
+ set (performance " This might impact runtime performance for Clang or LLD. Preferably build them separately." )
58
+ endif ()
59
+ message (WARNING "${message} .${performance} " )
60
+ set (LLVM_USE_CRT_${build} "MD" )
61
+ endif ()
62
+ endif ()
63
+ endmacro (disable_MT_if_LLDB)
53
64
54
65
macro (choose_msvc_crt MSVC_CRT)
55
66
if (LLVM_USE_CRT)
@@ -66,13 +77,26 @@ variables (LLVM_USE_CRT_DEBUG, etc) instead.")
66
77
get_current_crt(LLVM_USE_CRT_${build}
67
78
MSVC_CRT_REGEX
68
79
CMAKE_CXX_FLAGS_${build} )
80
+
81
+ # Make /MT the default in Release builds to make them faster
82
+ # and avoid the DLL function thunking.
83
+ if ((${build} STREQUAL "MINSIZEREL" ) OR
84
+ (${build} STREQUAL "RELEASE" ) OR
85
+ (${build} STREQUAL "RELWITHDEBINFO" ))
86
+ set (LLVM_USE_CRT_${build} "MT" )
87
+ endif ()
88
+
89
+ disable_MT_if_LLDB(${build} "Using /MD as required by LLDB" )
90
+
69
91
set (LLVM_USE_CRT_${build}
70
92
"${LLVM_USE_CRT_${build} }"
71
93
CACHE STRING "Specify VC++ CRT to use for ${build_type} configurations."
72
94
FORCE)
73
95
set_property (CACHE LLVM_USE_CRT_${build}
74
96
PROPERTY STRINGS ;${${MSVC_CRT} })
75
- endif (NOT LLVM_USE_CRT_${build} )
97
+ else ()
98
+ disable_MT_if_LLDB(${build} "Disabling /MT as required by LLDB" )
99
+ endif ()
76
100
endforeach (build_type )
77
101
78
102
foreach (build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} )
0 commit comments