-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Use mingw-std-threads in MinGW builds #85039
Conversation
25a3e0f
to
8a0ed38
Compare
|
a6a4d65
to
1a43eff
Compare
1a43eff
to
fe4850c
Compare
Awesome stuff :) |
Test build of 4.2 RC 1 + this PR: We discussed this on RC with @RandomShaper, @hpvb and @YuriSizov, and agreed to go with this approach for 4.2. I was wary of replacing our threads implementation for Windows so late in the release cycle, but the alternatives are either building with MSVC (which is also a risky change to do so late in the cycle, and has a number of other issues with known bugs and performance regressions), or finding another workaround for what seems to be a bug in mingw's current threads implementation. RandomShaper tried a potential workaround in #85165 but that didn't seem to work. This PR however properly solves the linked issues. The implementation of
@hpvb also reviewed the library and thinks it should be a good option for us with the given constraints. So let's test in 4.2 RC 2 and hope it doesn't regress in other use cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be ways to improve the namespace issue, as well as preventing windows.h
defines from leaking everywhere, but as a short term fix this should be good enough.
We can clean this up after the 4.2 release (and backport the cleanup to 4.2.x, as this might still cause downstream issues for users with custom modules that would also end up importing some of those new headers).
Thanks! |
godotengine/godot-proposals#6219 godotengine/godot-proposals#6062 just wanted to mention these proposals from nearly a year ago as it directly relates to threading and had action been taken on said proposals, they would have eliminated whatever this bandaid fix is by using OS specific threading systems directly. |
You have written comments both here and in one of the proposals, but I'll just follow up here. Your proposals are about threading, indeed, but about a different aspect of it. Thia PR replaces an implementation of |
Quoting @akien-mga:
This PR replaces the implementation of
std::thread
and friends provided by MinGW with a third-party one (so, in a sense, it indeed fixes MinGW). This seems to fix crashes and hangs occuring in complex multi-threading scenarios.Fixes #78734.
Fixes #85105.
Limitations:
typedefs.h
. If this PR is accepted to at least workaround the serious issue, further work could be done on that area to keep things a bit less ugly, but this is as far as I've been able to reach so far.std::*
symbols provided by MinGW. That doesn't seem to be a big issue. However, a nice piece of future work would be to make everything use the same, given the replacements provided in this PR seem to work better. And to avoid duplicates.With/without this PR I'm getting certain non-fatal errors at exit (of the kind ofUPDATE: After replacing the recursive mutex (lack thereof was a left-behing), I'm no longer getting those errors! I'm starting to think this may be fixing other Windows-only stability issues in prod builds.ERROR: BUG: Unreferenced static string to 0: completed
). That means this PR doesn't completely fix all the threading issues caused by MinGW.EXTRA (2023-11-21):
This may allow us to revert the following PRs without regressions: