Skip to content

Commit da0ea99

Browse files
committed
Teach GetXcodeSDK to look in the Xcode that contains LLDB
instead of preferring the one chosen with xcode-select. <rdar://problem/64000666> Differential Revision: https://reviews.llvm.org/D81210 (cherry picked from commit 79daa3d)
1 parent e6b0a87 commit da0ea99

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,21 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
358358
XcodeSDK::Info info = sdk.Parse();
359359
std::string sdk_name = XcodeSDK::GetCanonicalName(info);
360360
auto find_sdk = [](std::string sdk_name) -> std::string {
361-
std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk_name;
361+
std::string xcrun_cmd;
362+
Environment env = Host::GetEnvironment();
363+
std::string developer_dir = env.lookup("DEVELOPER_DIR");
364+
if (developer_dir.empty())
365+
if (FileSpec fspec = HostInfo::GetShlibDir())
366+
if (FileSystem::Instance().Exists(fspec)) {
367+
FileSpec path(
368+
XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
369+
if (path.RemoveLastPathComponent())
370+
developer_dir = path.GetPath();
371+
}
372+
if (!developer_dir.empty())
373+
xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir + "\" ";
374+
xcrun_cmd += "xcrun --show-sdk-path --sdk " + sdk_name;
375+
362376
int status = 0;
363377
int signo = 0;
364378
std::string output_str;

0 commit comments

Comments
 (0)