Skip to content

Commit

Permalink
Set _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR when building on windows (#…
Browse files Browse the repository at this point in the history
…449)

There was a change in VS 2022 to make VS more compliant with the C++
standard and make std::mutex a constexpr.
However, this causes problems if an older version of the runtime is
loaded first - in which case, the chiapos wheel will often crash.


https://stackoverflow.com/questions/78598141/first-stdmutexlock-crashes-in-application-built-with-latest-visual-studio

Set `_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR` in order to disable the newer
(albeit more compliant) code and use the more compatible version
  • Loading branch information
emlowe authored Sep 11, 2024
2 parents 9fd65e9 + 09197e1 commit 136616d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ target_include_directories(uint128 PUBLIC uint128_t)

target_compile_features(fse PUBLIC cxx_std_17)
target_compile_features(chiapos PUBLIC cxx_std_17)
if (WIN32)
# workaround for constexpr mutex constructor change in MSVC 2022
# https://stackoverflow.com/questions/78598141/first-stdmutexlock-crashes-in-application-built-with-latest-visual-studio
target_compile_definitions(chiapos PUBLIC _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
endif()
# target_compile_features(RunTests PUBLIC cxx_std_17)

target_link_libraries(chiapos PRIVATE fse Threads::Threads
Expand Down

0 comments on commit 136616d

Please sign in to comment.