[clang] [Darwin][Driver][clang] Prioritise `-isysroot` over `--sysroot` consistently (PR #115993)
Steven Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 4 12:03:21 PST 2024
cachemeifyoucan wrote:
> DEFAULT_SYSROOT was expected by some users to support setting a default SDK. Maybe this wasn't actually intended, but it came common enough knowledge to eventually be explicitly recommended in parts of LLVM documentation:
That is flang document, which is not endorsed by platform vendor in anyway. You can use DEFAULT_SYSROOT for local builds (or package manager builds for local host only) but never for products that are built for distribution on macOS. There is no standard location for macOS SDK, and it can be anywhere you want. You have to specify `-isysroot` or set env `SDKROOT` (which is what /usr/bin/clang does, it is a shim that finds the SDK location, then set SDKROOT). DEFAULT_SYSROOT can't fix any problem for distribution.
All Darwin platforms use a different model from your standard linux distribution and all SDKs are backwards compatible to older OS versions, which allows you to build software for older OS on latest version. The compilation model is closer to a cross-compilation in linux world.
The fundamental problem you hit is that you pass a secret `--sysroot` option (not visible from driver command) that doesn't match the `-isysroot`. If you intended to make this less a problem for unsuspecting users, I would change to pass `-isysroot` on Darwin, instead of using `--sysroot` for DEFAULT_SYSROOT. That should be safe enough to not disrupt any users.
https://github.com/llvm/llvm-project/pull/115993
More information about the cfe-commits
mailing list