From 1d5148b2292c8e4018c532bf8d56768e8bc1ff89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 28 Nov 2022 12:51:11 +0100 Subject: [PATCH] Windows: Link MSVC dynamic debug CRT for debug builds Fixes #31608. --- platform/windows/detect.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 705e83daced5..2b1ed64f4ac2 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -339,10 +339,14 @@ def configure_msvc(env, vcvars_msvc_config): ## Compile/link flags - if env["use_static_cpp"]: - env.AppendUnique(CCFLAGS=["/MT"]) + if env["optimize"] in ["debug", "none"]: + # Always use dynamic runtime, static debug CRT breaks thread_local. + env.AppendUnique(CCFLAGS=["/MDd"]) else: - env.AppendUnique(CCFLAGS=["/MD"]) + if env["use_static_cpp"]: + env.AppendUnique(CCFLAGS=["/MT"]) + else: + env.AppendUnique(CCFLAGS=["/MD"]) if env["arch"] == "x86_32": env["x86_libtheora_opt_vc"] = True