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

Avoid conflict between mingw-std-threads and Clang's own #85208

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ Files extracted from upstream repository:
- `mingw.shared_mutex.h`
- `mingw.thread.h`

Once copied, apply `no_except.patch` (needed because Godot is built without exceptions).
Once copied, apply `godot.patch` (needed because Godot is built without exceptions
and to avoid std:: replacements leak in Clang builds).


## minimp3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
diff --git a/thirdparty/mingw-std-threads/mingw.condition_variable.h b/thirdparty/mingw-std-threads/mingw.condition_variable.h
index 50c5ebd6df..f9e248c154 100644
index 50c5ebd6df..d099fad2ec 100644
--- a/thirdparty/mingw-std-threads/mingw.condition_variable.h
+++ b/thirdparty/mingw-std-threads/mingw.condition_variable.h
@@ -58,7 +58,7 @@

namespace mingw_stdthread
{
-#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS)
+#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__)
enum class cv_status { no_timeout, timeout };
#else
using std::cv_status;
@@ -87,12 +87,12 @@ public:
: mSemaphore(CreateSemaphoreA(NULL, 0, 0xFFFF, NULL))
{
Expand All @@ -26,8 +35,17 @@ index 50c5ebd6df..f9e248c154 100644
}
}
public:
@@ -547,7 +547,7 @@ namespace std
// was none. Direct specification (std::), however, would be unaffected.
// Take the safe option, and include only in the presence of MinGW's win32
// implementation.
-#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS)
+#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__)
using mingw_stdthread::cv_status;
using mingw_stdthread::condition_variable;
using mingw_stdthread::condition_variable_any;
diff --git a/thirdparty/mingw-std-threads/mingw.mutex.h b/thirdparty/mingw-std-threads/mingw.mutex.h
index 03efa13f8b..73698d13cb 100644
index 03efa13f8b..1e881e6c7d 100644
--- a/thirdparty/mingw-std-threads/mingw.mutex.h
+++ b/thirdparty/mingw-std-threads/mingw.mutex.h
@@ -132,7 +132,7 @@ struct _OwnerThread
Expand Down Expand Up @@ -55,8 +73,17 @@ index 03efa13f8b..73698d13cb 100644
}
bool try_lock()
{
@@ -480,7 +480,7 @@ namespace std
// was none. Direct specification (std::), however, would be unaffected.
// Take the safe option, and include only in the presence of MinGW's win32
// implementation.
-#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS)
+#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__)
using mingw_stdthread::recursive_mutex;
using mingw_stdthread::mutex;
using mingw_stdthread::recursive_timed_mutex;
diff --git a/thirdparty/mingw-std-threads/mingw.shared_mutex.h b/thirdparty/mingw-std-threads/mingw.shared_mutex.h
index ff1ac65135..5375b0fbd1 100644
index ff1ac65135..ddc46bb826 100644
--- a/thirdparty/mingw-std-threads/mingw.shared_mutex.h
+++ b/thirdparty/mingw-std-threads/mingw.shared_mutex.h
@@ -134,7 +134,7 @@ public:
Expand Down Expand Up @@ -98,20 +125,36 @@ index ff1ac65135..5375b0fbd1 100644
mMutex->unlock_shared();
mOwns = false;
}
@@ -484,10 +484,10 @@ namespace std
// was none. Direct specification (std::), however, would be unaffected.
// Take the safe option, and include only in the presence of MinGW's win32
// implementation.
-#if (__cplusplus < 201703L) || (defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS))
+#if (__cplusplus < 201703L) || (defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__))
using mingw_stdthread::shared_mutex;
#endif
-#if (__cplusplus < 201402L) || (defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS))
+#if (__cplusplus < 201402L) || (defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__))
using mingw_stdthread::shared_timed_mutex;
using mingw_stdthread::shared_lock;
#elif !defined(MINGW_STDTHREAD_REDUNDANCY_WARNING) // Skip repetition
diff --git a/thirdparty/mingw-std-threads/mingw.thread.h b/thirdparty/mingw-std-threads/mingw.thread.h
index bcdd1a36a8..7ca09e25f5 100644
index bcdd1a36a8..60d2200db2 100644
--- a/thirdparty/mingw-std-threads/mingw.thread.h
+++ b/thirdparty/mingw-std-threads/mingw.thread.h
@@ -196,7 +196,7 @@ public:
int errnum = errno;
@@ -193,10 +193,9 @@ public:
if (int_handle == 0)
{
mHandle = kInvalidHandle;
- int errnum = errno;
delete call;
// Note: Should only throw EINVAL, EAGAIN, EACCES
- throw std::system_error(errnum, std::generic_category());
+ __builtin_trap();
} else {
mThreadId.mId = id_receiver;
mHandle = reinterpret_cast<HANDLE>(int_handle);
@@ -213,11 +213,11 @@ public:
@@ -213,11 +212,11 @@ public:
{
using namespace std;
if (get_id() == id(GetCurrentThreadId()))
Expand All @@ -126,7 +169,7 @@ index bcdd1a36a8..7ca09e25f5 100644
WaitForSingleObject(mHandle, kInfinite);
CloseHandle(mHandle);
mHandle = kInvalidHandle;
@@ -266,7 +266,7 @@ moving another thread to it.\n");
@@ -266,7 +265,7 @@ moving another thread to it.\n");
if (!joinable())
{
using namespace std;
Expand All @@ -135,3 +178,12 @@ index bcdd1a36a8..7ca09e25f5 100644
}
if (mHandle != kInvalidHandle)
{
@@ -326,7 +325,7 @@ namespace std
// was none. Direct specification (std::), however, would be unaffected.
// Take the safe option, and include only in the presence of MinGW's win32
// implementation.
-#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS)
+#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__)
using mingw_stdthread::thread;
// Remove ambiguity immediately, to avoid problems arising from the above.
//using std::thread;
4 changes: 2 additions & 2 deletions thirdparty/mingw-std-threads/mingw.condition_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

namespace mingw_stdthread
{
#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS)
#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__)
enum class cv_status { no_timeout, timeout };
#else
using std::cv_status;
Expand Down Expand Up @@ -547,7 +547,7 @@ namespace std
// was none. Direct specification (std::), however, would be unaffected.
// Take the safe option, and include only in the presence of MinGW's win32
// implementation.
#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS)
#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__)
using mingw_stdthread::cv_status;
using mingw_stdthread::condition_variable;
using mingw_stdthread::condition_variable_any;
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/mingw-std-threads/mingw.mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ namespace std
// was none. Direct specification (std::), however, would be unaffected.
// Take the safe option, and include only in the presence of MinGW's win32
// implementation.
#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS)
#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__)
using mingw_stdthread::recursive_mutex;
using mingw_stdthread::mutex;
using mingw_stdthread::recursive_timed_mutex;
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/mingw-std-threads/mingw.shared_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,10 @@ namespace std
// was none. Direct specification (std::), however, would be unaffected.
// Take the safe option, and include only in the presence of MinGW's win32
// implementation.
#if (__cplusplus < 201703L) || (defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS))
#if (__cplusplus < 201703L) || (defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__))
using mingw_stdthread::shared_mutex;
#endif
#if (__cplusplus < 201402L) || (defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS))
#if (__cplusplus < 201402L) || (defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__))
using mingw_stdthread::shared_timed_mutex;
using mingw_stdthread::shared_lock;
#elif !defined(MINGW_STDTHREAD_REDUNDANCY_WARNING) // Skip repetition
Expand Down
3 changes: 1 addition & 2 deletions thirdparty/mingw-std-threads/mingw.thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ class thread
if (int_handle == 0)
{
mHandle = kInvalidHandle;
int errnum = errno;
delete call;
// Note: Should only throw EINVAL, EAGAIN, EACCES
__builtin_trap();
Expand Down Expand Up @@ -326,7 +325,7 @@ namespace std
// was none. Direct specification (std::), however, would be unaffected.
// Take the safe option, and include only in the presence of MinGW's win32
// implementation.
#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS)
#if defined(__MINGW32__ ) && !defined(_GLIBCXX_HAS_GTHREADS) && !defined(__clang__)
using mingw_stdthread::thread;
// Remove ambiguity immediately, to avoid problems arising from the above.
//using std::thread;
Expand Down