niXman / mingw-builds

Scripts for building the 32 and 64-bit MinGW-W64 compilers for Windows
Other
290 stars 107 forks source link

Do you have any interest in the mcf thread model? #658

Closed lhmouse closed 1 year ago

lhmouse commented 1 year ago

The mcf thread model has been merged into GCC 13. The GCC configure script now accepts --enable-threads=mcf and I think maybe we can give it a try.

Prebuilt binaries of the mcfgthread library can be installed from MSYS2:

pacman -S mingw-w64-x86_64-mcfgthread{,libs}

If anyone would like to build it themselves: This is built as a CRT library, so it should be built after mingw-w64 headers and binuitls, but before mingw-w64 CRT.

In addition to my personal toolchains, winlibs also provides GCC with the mcf thread model since GCC 13. The mcf thread library enables standard C++11 threads, mutexes, condition variables, etc.

I have another patch for mingw-w64 CRT to address other issues about standard conformance, such as order of destruction of static and thread_local objects, and quick_exit() support. Not sure whether they should applied.

starg2 commented 1 year ago

I actually have a patch to add mcf thread model to mingw-builds.

The reason I haven't opened a PR here is the CRT patch looks too "intrusive".

(That said, I like mcf and have been using it for over a year.)

niXman commented 1 year ago

I'm not against MCF threads support. please make a PR and I will accept it. but please add a description of the pros and cons of MCF in the README to avoid questions from users.

best!

lhmouse commented 1 year ago

Thank you both. I need some time to work on this; maybe not very soon, or maybe the next month.

The reason I haven't opened a PR here is the CRT patch looks too "intrusive".

That's actually a squashed version of patches 90??-*.patch from https://github.com/lhmouse/MINGW-packages/tree/master/mingw-w64-crt-git.

niXman commented 1 year ago

@starg2

The reason I haven't opened a PR here is the CRT patch looks too "intrusive".

could you please explain? I think I don't fully understand what's wrong with that patch...

lhmouse commented 1 year ago

Those patches for the CRT are not strictly required.

We had some discussion inside mingw-w64 and the conclusion was that it might be more preferable to follow what MSVC behaves rather than follow standards (namely, POSIX and Itanium ABI).

Even without patching the CRT, one may still get working std::mutex etc.

starg2 commented 1 year ago

could you please explain? I think I don't fully understand what's wrong with that patch...

  1. It's not clear if it's safe to apply the CRT patches unconditionally, including when building posix/win32 thread models.
  2. IIRC, building the mcf thread model requires a toolchain with mcf thread model, while both posix and win32 thread models can be built with the same toolchain (posix thread model).

So you have to be careful not to build both posix/win32 and mcf thread models in the same directory.

lhmouse commented 1 year ago

As there is already a PR, let's move the discussion to #659.