From 94aa21c3dd73523853ef9bb9cb1220d527417335 Mon Sep 17 00:00:00 2001 From: Baiju Meswani Date: Tue, 11 Jun 2024 22:23:28 -0700 Subject: [PATCH] Define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR (#21005) https://github.com/microsoft/STL/pull/3824 introduces constexpr mutex. An older version of msvcp140.dll will lead to ```A dynamic link library (DLL) initialization routine failed```. This error can be encountered if using conda Python since conda packages msvc dlls and these are older right now. This PR disables the constexpr mutex so that ort package can work with older msvc dlls. Thanks @snnn for the discovery. --- tools/ci_build/build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index c50650ca20c9e..f2f450b93d131 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -1548,7 +1548,11 @@ def generate_build_tree( and not args.build_wasm ): if is_windows(): - cflags += ["/guard:cf", "/DWIN32", "/D_WINDOWS"] + # DLL initialization errors due to old conda msvcp140.dll dll are a result of the new MSVC compiler + # See https://developercommunity.visualstudio.com/t/Access-violation-with-std::mutex::lock-a/10664660#T-N10668856 + # Remove this definition (_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) + # once the conda msvcp140.dll dll is updated. + cflags += ["/guard:cf", "/DWIN32", "/D_WINDOWS", "/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR"] if not args.use_gdk: # Target Windows 10 cflags += [