Add MinGW (Windows GNU) toolchain support#1396
Add MinGW (Windows GNU) toolchain support#1396GuyFromTheInternet wants to merge 2 commits intoKDAB:mainfrom
Conversation
Use Q_COREAPP_STARTUP_FUNCTION for metatype registration, which is Qt's recommended approach and works reliably on all platforms including MinGW. Change generated initializer code to use atomic operations instead of std::call_once for simpler, more portable initialization.
39a3220 to
c042786
Compare
ahayzen-kdab
left a comment
There was a problem hiding this comment.
Awesome! Thanks for looking at solving this!
Looks like CI is failing as clang-format needs to run over the files, are you able to do that?
And then would you be comfortable attempting to add a CI runner for this? As it would be good to ensure we do not regress and we can prove that it works.
This would be a matter of adding MinGW to the matrix similar to MSVC here (can be release rather than debug) https://github.com/KDAB/cxx-qt/blob/main/.github/workflows/github-cxx-qt-tests.yml#L394 set the values in the matrix, eg likely it is win64_mingw as the aqt_arch, then check if any other runner.os == 'Windows' need updating/changing. And note only do this for Qt 6, don't both with Qt 5.
|
And guess there might need to be a Rust toolchain installed too, so might need to be an additional entry for that |
4d297f5 to
ed42b48
Compare
|
Pretty sure I did everything you asked |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1396 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 75 75
Lines 13124 13457 +333
==========================================
+ Hits 13124 13457 +333 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR adds support for building cxx-qt applications with the MinGW (x86_64-pc-windows-gnu) toolchain on Windows.
Changes:
Started using Q_COREAPP_STARTUP_FUNCTION for metatype registration, the previous implementation used std::call_once for one-time metatype registration during static initialization. This fails on MinGW because the pthread TLS emulation (_emutls*) used by MinGW's std::call_once implementation isn't initialized during static constructors, causing a crash.
I also use atomic operations for initialization guards since this is simpler, has no TLS dependencies and works correctly on all platforms including MinGW.
Files changed:
Tested with Qt 6.8.3 MinGW build on Windows 11 using x86_64-pc-windows-gnu target.