[libcxx-commits] [libcxx] [libcxxabi] [llvm] [libc++] Implement library support for MCF thread model (PR #116550)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 28 10:47:47 PST 2024


https://github.com/ldionne commented:

At a high-level, the first point of discussion IMO is how this new "backend" is integrated into libc++. As it stands, you do this:

```c++
#elif defined(_LIBCPP_HAS_THREAD_API_MCF)
#    include <mcfgthread/libcxx.h>
```

In other words, the code is pulled in from elsewhere (presumably https://github.com/lhmouse/mcfgthread/blob/master/mcfgthread/libcxx.h), and it's assumed to be available. Instead, I would expect the libc++ entry points to be defined _in libc++_ itself, and then for these functions to call into the MCF runtime as needed. What would you think of that approach instead? The reason why this is fairly important is that we normally don't include random "external" headers from libc++ (with the exception of `__external_threading`, which should be redesigned). This also means that libc++ isn't self-sufficient anymore -- it needs to pull in a header from another project in order to build in that configuration, which also means that we can't officially test (hence officially support) this configuration.

For all these reasons, I think it would be better if the libc++-specific API were contained inside libc++, and libc++ only called into MCF entry points defined in the appropriate DLL. To use this configuration, it would then be sufficient to
1. Install the MCF runtime
2. Build libc++ with `LIBCXX_HAS_MCF_THREAD_API=ON`

I'd also like to remind that contributions must be under the Apache license with the LLVM exception, so this must be kept in mind in case the libc++-specific part of the API is contributed here.

https://github.com/llvm/llvm-project/pull/116550


More information about the libcxx-commits mailing list