[clang] [clang][CMake] Auto-detect macOS SDK for DEFAULT_SYSROOT (PR #185986)
Carlo Cabrera via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 13 03:57:02 PDT 2026
carlocab wrote:
> Would a modification to this PR to effectively do this at LLVM install time be agreeable?
> ```bash
> echo "--sysroot=$(xcrun --show-sdk-path)" > ${LLVM_INSTALL_DIR}/bin/clang.cfg
> ```
Using a config file instead of `DEFAULT_SYSROOT` is directionally better, but I have some concerns:
1. The LLVM build system has never auto-generated `.cfg` files into the install directory. The existing `.cfg` generation in the cross-compilation caches (`CrossWinToARMLinux.cmake`, `cross-linux-toolchain.cmake`) writes only into the build directory and never installs them. Config files have always been intended as something users and packagers create, not something the build system emits.
2. `cmake --install` would silently overwrite any user-created `clang.cfg` in the install prefix. There's no mechanism to detect or preserve an existing file during installation.
3. `clang.cfg` only applies to C-mode invocations, not `clang++`. A triple-based config file (e.g., `arm64-apple-macos.cfg`) would be more appropriate since the sysroot is target-specific, but that adds complexity.
4. The SDK path is still captured at build/install time and can go stale after an Xcode update, just as with `DEFAULT_SYSROOT`.
If you'd like to pursue the config file direction, I think it would warrant an RFC on Discourse first, since it would establish a new pattern for the project.
https://github.com/llvm/llvm-project/pull/185986
More information about the cfe-commits
mailing list