I’m about to release a new cross-platform standalone LLVM/clang binary distribution, I already have binaries for all platforms that passed my tests, but I’m not sure I understood the correct strategy for configuring the macOS build.
The main problem with custom standalone toolchains is to avoid inserting unwanted dependencies to shared libraries located in toolchain specific folders.
The common approach is to build the toolchain only with the static libraries, i.e. without the shared libraries and thus give the linker no chance to use the shared libraries.
This generally works on GNU/Linux, however, due to the Apple linker specifics, I could not make it work on macOS, the system
ld seems to prefer the system dynamic libraries before the toolchain specific static libraries, and I could not avoid references to
The resulting binaries, although apparently functional, were in fact hybrids, compiled with the C++ headers from the toolchain (in my case v12.0.1) and linked with the dynamic library from the system (on my macOS 10.13 test machine it is v10.0.0)
In my opinion this is a risky strategy, so my only idea to avoid it was to completely remove the C++ libraries from my build and use only the headers and the dynamic libraries available in the host system.
For this to work, I had to introduce a dependency on the Apple Command Line Tools, since I had to patch the clang driver to add
/Library/Developer/CommandLineTools/usr/include/c++/v1 to the search path, but this is another topic.
Am I missing something? Are there any better strategies?