I already have a sysroot or SDK set up for each platform, but they either lack libc++, have an outdated version, or don’t include C++ standard library modules.
I want to build and statically link libc++ myself, so I can use modern C++ features (including modules) across all platforms I target—desktop, mobile, and embedded.
I’m familiar with building LLVM from source, and I understand building libc++ should be similar, just without the other runtimes and projects.
Assume I’ve done that for each target platform, so now I have several separate libc++ directories—one per target.
The problem is: how do I integrate these into my toolchains correctly? Simply adding the library and include directories doesn’t seem to be enough. For example, CMake fails to find libc++.modules.json, even when it’s located inside the lib directory I added.
When compiling natively, clang finds libc++ automatically, but this isn’t happening for cross-compilation.
So:
How can I properly link my custom-built libc++ into each toolchain so CMake and Clang can use it—including module support—during cross-compilation?