Setting macOS deployment target for libc++ (original) (raw)

I’m trying to build libc++ as a runtimes build in a distribution, with the macOS deployment target set to 11.0 (Big Sur), but no matter what I do, I end up with a libc++.dylib that targets 12.3 (the default target in my host Xcode 13.3).

Setting the top-level CMAKE_OSX_DEPLOYMENT_TARGET does not get passed down to the runtimes builds (understandably, since it means a deployment target for any Darwin targets). However, neither does RUNTIMES_<triple>_CMAKE_OSX_DEPLOYMENT_TARGET where I tried x86_64-apple-darwin-macos and x86_64-apple-darwin23.4-macos for the triple (23.4 is my host system and that is what I see being passed down as TARGET_TRIPLE).

I also attempted passing a custom CMAKE_OSX_SYSROOT (pointing to the SDK from Xcode 12.2) but that is also not forwarded, and there are some instances in CMake where xcrun -sdk --show-sdk-path is preferred anyway).

Using Xcode 12.2 as the host compiler would probably solve this, but I am not able to do that because my host system is too new.

Any advice? Am I holding this completely wrong?

tamas May 8, 2024, 12:58pm 2

Looks like it works fine if I build libc++ separately, so the issue boils down to correctly passing the option to the nested build.

tamas May 9, 2024, 11:19am 4

I figured it out. The key is passing -DRUNTIMES_BUILD_ALLOW_DARWIN=ON along with a singular triple that is not OS-specific (e.g. -DLLVM_RUNTIME_TARGETS="x86_64-apple-darwin"), and then -DRUNTIMES_x86_64-apple-darwin_CMAKE_OSX_DEPLOYMENT_TARGET=11.0 gets passed down to the nested runtimes builds as expected. This still doesn’t change the “Darwin builds all the things”-behavior, so it’s a bit confusing but it works.