Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR for artifact building #335

Closed
greenhat616 opened this issue Dec 16, 2024 · 3 comments
Closed

add _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR for artifact building #335

greenhat616 opened this issue Dec 16, 2024 · 3 comments

Comments

@greenhat616
Copy link

greenhat616 commented Dec 16, 2024

The new MSVC have changed the mutex behavior, and could cause the crash while VC++ runtime < 14.40.33810.0.

For example, it was the minial repo from fastembed demo:

图片

ONNX has fixed via their build.py: microsoft/onnxruntime#21005

I notice we have a custom CMakeList.txt to customize, and I have tried to fix it up, but failed.

diff --git a/src/static-build/CMakeLists.txt b/src/static-build/CMakeLists.txt
index 1e6f474..8ac5224 100644
--- a/src/static-build/CMakeLists.txt
+++ b/src/static-build/CMakeLists.txt
@@ -5,6 +5,11 @@ set(onnxruntime_BUILD_SHARED_LIB ON)

 add_definitions(-D_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS)

+if (MSVC)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR")
+endif()
+
 add_subdirectory(${ONNXRUNTIME_SOURCE_DIR}/cmake onnxruntime EXCLUDE_FROM_ALL)

 function(bundle_static_library bundled_target_name)

Additionally, I tried to run sudo .\build.bat --enable_msvc_static_runtime --config Release --parallel --skip_submodule_sync in onnxrunimte project, and the result used vie ort env. The program can run as expected.

Could you do a fix for it? Thank you.

@greenhat616
Copy link
Author

greenhat616 commented Dec 17, 2024

Thank you for your quick response. I verified the fix successfully through the fastembed demo and our product.

Additionally, shall we update the dist.txt in ort repo? thx.

@channing
Copy link

Hi @decahedron1, thanks for your work! Could you please also update ort-sys/dist.txt so we can use the new artifacts?

@decahedron1
Copy link
Member

Not until the next release of ONNX Runtime, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants