[PATCH] D109460: [clang][Darwin] Try to guess the SDK root with xcrun when unspecified

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 8 13:08:31 PDT 2021


ldionne added a comment.
Herald added a subscriber: ormris.

@arphaman This is a WIP patch -- I'm trying to see whether this idea is good or just bad from the start.

To summarize, people have been complaining (e.g. here <https://bugs.llvm.org/show_bug.cgi?id=45880>) that Clang on Darwin doesn't work out of the box, because we don't ship headers in `/usr/include`. This is an attempt to provide a sane default by running `xcrun --show-sdk-path` from within Clang when no SDK root can be found otherwise.

I was pretty sure this was a good idea until I implemented it and then noticed the tests failing. Previously, when no SDK can be found (which is the case in most Clang tests since we don't run with `xcrun`), we would use whatever deployment target Clang defaults to. After this patch, however, we'll often find a SDK even though none is specified, and that will have the effect of setting a different deployment target than the one we expect in those tests. Do you think that is just a sign that this whole idea of trying to infer the SDK using `xcrun` is broken from the start, or those tests should simply be fixed?

I guess another option would be that if the target is specified, we try to infer the SDK path using `xcrun --sdk <sdk-inferred-from-target> --show-sdk-path`. That's starting to be complex, but it might solve some of these issues.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109460/new/

https://reviews.llvm.org/D109460



More information about the cfe-commits mailing list