Can one build a self contained compiler toolchain on macOS with clang/llvm that does not require Xcode/CLT?

Hi,

I’ve been trying to do what is stated in the title:

First I got rid of ld so that clang would use its own linker by default(lld)
Then I tried to get rid of libxar
Then I made it so libcxx could actually be linked with lld (which does not support symbol re-exporting)
Then I realized that libcxx's headers, some of them, are wrapper headers that use #include_next <...> to include system headers
And this is where I gave up 😄
My question is: is there, currently a way to build a Clang/llvm toolchain from sources that is independent of Xcode/CommandLineTools being present on the target machine?

You need to get the platform “sysroot” from somewhere. That is, the system headers and library “tbd” files, which ship in XCode under /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/. (If not those actual files, you’d need a reimplementation of at least a subset of them.)

Hi, thank you for your answer.
I realized this as well but… we would like not to distribute Xcode/CLT with our builds or force the user to install them. Is there another way?

No. Unless you can find a full re-implementation of the Apple SDK under a more free license. I am not aware of anything like that.

I understand. Thank you.