🍒 [lldb][HostInfoMacOSX] Try to use DW_AT_LLVM_sysroot instead of xcrun when looking up SDK #10157
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GetSDKRoot
usesxcrun
to find an SDK root path for a given SDK version string. But if the SDK doesn't exist in the Xcode installations, but instead lives in theCommandLineTools
,xcrun
will fail to find it. Negative searches for an SDK path cost a lot (a few seconds) each timexcrun
is invoked. We do cache negative results infind_cached_path
inside LLDB, but we would still pay the price on every new debug session the first time we evaluate an expression. This doesn't only cause a noticable delay in running the expression, but also generates following error:In this patch we avoid these possibly expensive calls to
xcrun
by checking theDW_AT_LLVM_sysroot
, and if it exists, using that as the SDK path. We need an explicit check for theCommandLineTools
path before we callRegisterXcodeSDK
, because that will try to callxcrun
. This won't prevent other uses ofGetSDKRoot
popping up that cause us to make expensivexcrun
calls, but for now this addresses the regression in the expression evaluator. We also had to adjust theXcodeSDK::Merge
logic to update the sysroot. There is one case for which this wouldn't make sense: if a CU was compiled withCommandLineTools
and a different one with an older internal SDK, in that case we would update theCommandLineTools
sysroot with a.Internal.sdk
prefix, which won't possibly exist forCommandLineTools
. I added a unit-test for this. Not sure if we want to explicitly detect and disallow this, given it's quite a niche scenario.rdar://113619904
rdar://113619723
(cherry picked from commit 77a8770)