From: Lucian Petrut Date: Tue, 30 May 2023 13:46:54 +0000 (+0000) Subject: common: skip boost shared_mutex with mingw-llvm X-Git-Tag: v19.0.0~575^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4b43afd509a4faf1354f96d5bf560bca5b08d5b9;p=ceph.git common: skip boost shared_mutex with mingw-llvm Because of winpthreads issues, we had to use Boost's shared_mutex implementation. When using mingw-llvm, we can safely use libc++'s shared mutex implementation. Signed-off-by: Lucian Petrut --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1778a7202649..ceffeccc29a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,15 +41,19 @@ if(WIN32) # the targeted Windows version. The availability of certain functions and # structures will depend on it. set(WIN32_WINNT "0x0A00" CACHE STRING "Targeted Windows version.") - # In order to avoid known winpthread issues, we're using the boost - # shared mutex implementation. - # https://github.com/msys2/MINGW-packages/issues/3319 add_definitions( -D_WIN32_WINNT=${WIN32_WINNT} -DFMT_USE_TZSET=0 - -DBOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN - -DBOOST_THREAD_V2_SHARED_MUTEX ) + # In order to avoid known winpthread issues, we're using the Boost + # shared mutex implementation. This isn't required with llvm/libc++. + # https://github.com/msys2/MINGW-packages/issues/3319 + if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) + add_definitions( + -DBOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN + -DBOOST_THREAD_V2_SHARED_MUTEX + ) + endif() set(Boost_THREADAPI "win32") endif() diff --git a/src/common/ceph_mutex.h b/src/common/ceph_mutex.h index 8d87e605b84a..6ed8c56d5dad 100644 --- a/src/common/ceph_mutex.h +++ b/src/common/ceph_mutex.h @@ -151,7 +151,7 @@ namespace ceph { // The winpthreads shared mutex implementation is broken. // We'll use boost::shared_mutex instead. // https://github.com/msys2/MINGW-packages/issues/3319 -#if __MINGW32__ +#if defined(__MINGW32__) && !defined(__clang__) #include #else #include @@ -163,7 +163,7 @@ namespace ceph { typedef std::recursive_mutex recursive_mutex; typedef std::condition_variable condition_variable; -#if __MINGW32__ +#if defined(__MINGW32__) && !defined(__clang__) typedef boost::shared_mutex shared_mutex; #else typedef std::shared_mutex shared_mutex;