[libcxx-commits] [libcxx] Commit mostly working single wrapped module map (PR #87402)

Ian Anderson via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 5 09:35:07 PDT 2024


ian-twilightcoder wrote:

> > We can't do this. The libc++ public headers all need to be top level modules so that they can layer with the clang and OS modules. https://reviews.llvm.org/D144322 Note that you can't use modules with only the libc++ module map, you'll need a module map to cover your libc headers and the posix headers used by libc++ as well.
> 
> We can and have done this. I suspect the issues you're discussing arise on OS X and not Linux?
> 
> I have built LLVM with this change using modules, without any special tweaks for libc or POSIX. So this change works perfectly in some configurations.
> 
> If you could provide concrete examples of what breaks, I can work to fix those breakages. But without actual meaningful examples, I can't do much to help.
> 
> I understand that this patch, exactly as is, might cause issues with C and POSIX headers. And that those issues may require the `foo.h` and `cfoo` headers to be treated slightly differently.
> 
> We also can't not do this. When was the last time you built a large project using our module map? It very quickly breaks trying to build Clang with more than one thread.
> 
> So if this change breaks on a Mac, but is required on Linux and visa versa without this change, then I can come up with a separate path forward.

It will _only_ work if the libc++ module map is the _only_ module map on the system, or if you start adding `[no_undeclared_includes]` hacks to the system module maps. Also it's a requirement of clang modules that they only include headers that are covered by modules. That means that the C standard library, and some select parts of POSIX, have to have their own module maps. You can cheese it by using a single module map and let it absorb all of its dependencies, but that's not the expectation of clang modules.

Once you do have proper modules for the C headers, they quickly introduce cycles. i.e. inttypes.h includes stdint.h. If those are in the same module in libc++ then you get a module cycle: std -> c_inttypes -> std -> c_stdint. Single giant module just doesn't work, and it's not an Apple SDK specific problem, it's any system that actually supports clang modules.

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


More information about the libcxx-commits mailing list