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

Nico Weber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 9 04:31:52 PDT 2021


thakis added a comment.

This is a nice idea.

One drawback is that if you don't pass `-isysroot`, things just wouldn't work before but now every clang invocation will call xcrun, so things will work but will be slower than if you passed `-isysroot`. But the convenience for one-off invocations is probably worth this subtlety.

Tests must be hermetic, so we should have some flag to disable this behavior and expand `%clang` and `%clang_cc1` to pass the disable flag, to make sure tests don't rely on this.

Independent of tests, can we make the driver look at the triple and pass a matching `-sdk` flag to xcrun?

Also, on my system xcrun prints different paths depending on if I pass `-sdk` for some reason:

  % xcrun -show-sdk-path
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
  % xcrun -show-sdk-path -sdk macosx
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk

I have to do `-isysroot $(xcrun -show-sdk-path -sdk macosx)` for things to work. That's another point in favor of passing an `-sdk` flag.


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