Fix Windows build to use dynamic DLL runtime (MD) by default

This change partially reverts commit b60aee58c7

Previously, we compiled with the flags:
/MT /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib,
which resulted in a non-standard setup where the Universal C Runtime
(UCRT) was dynamically linked, but the compiler runtime was statically
linked. Goal was to reduce runtime dependency, while still using dynamic
CRT

However, now now causes subtle static initialization issues
(and also some problems with MSVC ASAN)

To fix, we now use standard /MD, so both C runtime and compiler runtime
dynamically linked. MSVC redistributable DLL (vcruntime140.dll) is
required on the system, similar to version 10.4.

Our packaging, both zip and MSI, is already prepared for it.
This commit is contained in:
Vladislav Vaintroub 2025-03-25 18:49:03 +01:00 committed by Sergei Golubchik
commit 8363d05f4d

View file

@ -121,7 +121,7 @@ IF(MSVC)
# Disable mingw based pkg-config found in Strawberry perl
SET(PKG_CONFIG_EXECUTABLE 0 CACHE INTERNAL "")
SET(MSVC_CRT_TYPE /MT CACHE STRING
SET(MSVC_CRT_TYPE /MD CACHE STRING
"Runtime library - specify runtime library for linking (/MT,/MTd,/MD,/MDd)"
)
SET(VALID_CRT_TYPES /MTd /MDd /MD /MT)