[lldb] Change the xcrun (fallback) logic in GetXcodeSDK
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 6 Oct 2020 22:12:23 +0000 (15:12 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 6 Oct 2020 22:55:06 +0000 (15:55 -0700)
commite3b0414b0ea305396a1fcfb2821ad643b0731880
treec00119c0dacffa68bdac3812b5593b87c5d2e87c
parentdfa70a483aad438cad826c414a5d710bab6ecf49
[lldb] Change the xcrun (fallback) logic in GetXcodeSDK

This changes the logic in GetXcodeSDK to find an SDK with xcrun. The
code now executes the following steps:

 1. If DEVELOPER_DIR is set in the environment, it invokes xcrun with
    the given developer dir. If this fails we stop and don't fall back.
 2. If the shlib dir is set and exists,it invokes xcrun with the
    developer dir corresponding to the shlib dir. If this fails we fall
    back to 3.
 3. We run xcrun without a developer dir.

The new behavior introduced in this patch is that we fall back to
running xcrun without a developer dir if running it based on the shlib
dir failed.

A situation where this matters is when you're running lldb from an Xcode
that has no SDKs and that is not xcode-selected. Based on lldb's shlib
dir pointing into this Xcode installation, it will do an xcrun with the
developer set to the Xcode without any SDKs which will fail. With this
patch, when that happens, we'll fall back to trying the xcode-selected
Xcode by running xcrun without a developer dir.

Differential revision: https://reviews.llvm.org/D88866
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm