When building with a non-modularized C runtime, csignal would claim time.h and thus timespec rather than ctime. Adjust the modulemap to ensure that ctime claims timespec.
For auditing, can you use llvm-bcanalyze to see which headers are claimed by which PCM? If not, we should probably add a clang-pcm tool or something to help inspect module contents. @Bigcheese, thoughts?
I guess the obvious concern about this is that this is a game of whack-a-mole. If the headers change, you may need to shuffle module order again, at which point, which version of libc should we make libc++ work against? And different libc implementations could need different orders. But I'm just pointing it out; I don't have a problem with this patch landing.
I think that a clang-pcm like tool would be incredible. Working with modules is somewhat frustrating because there is no good supported way to see what the module structure that clang actually sees. But that goes well beyond an attempt to repair the NetBSD builds.
Are you building with or without -fmodules-local-submodule-visibility (cmake -DLLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY=ON)? If you don't use that, this sort of random weirdness is going to come up a lot. And if you do use that setting, then this patch shouldn't make any difference; if it does, we should dig into why.
Given that the original motivation here was to help with NetBSD, and the submodule visibility flag handling unblocks NetBSD, I think that I will hold off on this unless some other motivation arises.