Skip to content

Commit 2b5628e

Browse files
committed
Revert "[lldb]HostInfoMacOSX] Search CommandLineTools directory when looking up SDK paths"
This reverts commit 2665e74.
1 parent 4d7c510 commit 2b5628e

File tree

2 files changed

+2
-63
lines changed

2 files changed

+2
-63
lines changed

lldb/include/lldb/Host/FileSystem.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,8 @@ class FileSystem {
183183
eEnumerateDirectoryResultQuit
184184
};
185185

186-
typedef std::function<EnumerateDirectoryResult(
187-
void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef)>
188-
EnumerateDirectoryCallbackType;
186+
typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)(
187+
void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef);
189188

190189
typedef std::function<EnumerateDirectoryResult(
191190
llvm::sys::fs::file_type file_type, llvm::StringRef)>

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

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@
1515
#include "lldb/Utility/Log.h"
1616
#include "lldb/Utility/Timer.h"
1717

18-
#include "clang/Basic/DarwinSDKInfo.h"
1918
#include "llvm/ADT/ScopeExit.h"
2019
#include "llvm/ADT/SmallString.h"
2120
#include "llvm/ADT/StringMap.h"
22-
#include "llvm/Support/Error.h"
2321
#include "llvm/Support/FileSystem.h"
2422
#include "llvm/Support/Path.h"
25-
#include "llvm/Support/VersionTuple.h"
2623
#include "llvm/Support/raw_ostream.h"
2724

2825
// C++ Includes
@@ -572,52 +569,10 @@ static bool ResolveAndVerifyCandidateSupportDir(FileSpec &path) {
572569
cache.insert({key, {error, true}});
573570
return llvm::createStringError(llvm::inconvertibleErrorCode(), error);
574571
}
575-
576-
if (path_or_err->empty())
577-
return llvm::createStringError("Empty path determined for '%s'",
578-
key.data());
579-
580572
auto it_new = cache.insert({key, {*path_or_err, false}});
581573
return it_new.first->second.str;
582574
}
583575

584-
static llvm::Expected<std::string>
585-
GetCommandLineToolsSDKRoot(llvm::VersionTuple version) {
586-
std::string clt_root_dir;
587-
FileSystem::Instance().EnumerateDirectory(
588-
"/Library/Developer/CommandLineTools/SDKs/", /*find_directories=*/true,
589-
/*find_files=*/false, /*find_other=*/false,
590-
[&](void *baton, llvm::sys::fs::file_type file_type,
591-
llvm::StringRef name) {
592-
assert(file_type == llvm::sys::fs::file_type::directory_file);
593-
594-
if (!name.ends_with(".sdk"))
595-
return FileSystem::eEnumerateDirectoryResultNext;
596-
597-
llvm::Expected<std::optional<clang::DarwinSDKInfo>> sdk_info =
598-
clang::parseDarwinSDKInfo(
599-
*FileSystem::Instance().GetVirtualFileSystem(), name);
600-
if (!sdk_info) {
601-
LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions), sdk_info.takeError(),
602-
"Error while parsing {1}: {0}", name);
603-
return FileSystem::eEnumerateDirectoryResultNext;
604-
}
605-
606-
if (!*sdk_info)
607-
return FileSystem::eEnumerateDirectoryResultNext;
608-
609-
if (version == (*sdk_info)->getVersion()) {
610-
clt_root_dir = name;
611-
return FileSystem::eEnumerateDirectoryResultQuit;
612-
}
613-
614-
return FileSystem::eEnumerateDirectoryResultNext;
615-
},
616-
/*baton=*/nullptr);
617-
618-
return clt_root_dir;
619-
}
620-
621576
llvm::Expected<llvm::StringRef> HostInfoMacOSX::GetSDKRoot(SDKOptions options) {
622577
static llvm::StringMap<ErrorOrPath> g_sdk_path;
623578
static std::mutex g_sdk_path_mutex;
@@ -626,21 +581,6 @@ static bool ResolveAndVerifyCandidateSupportDir(FileSpec &path) {
626581
"XcodeSDK not specified");
627582
XcodeSDK sdk = *options.XcodeSDKSelection;
628583
auto key = sdk.GetString();
629-
630-
// xcrun doesn't search SDKs in the CommandLineTools (CLT) directory. So if
631-
// a program was compiled against a CLT SDK, but that SDK wasn't present in
632-
// any of the Xcode installations, then xcrun would fail to find the SDK
633-
// (which is expensive). To avoid this we first try to find the specified SDK
634-
// in the CLT directory.
635-
auto clt_root_dir = find_cached_path(g_sdk_path, g_sdk_path_mutex, key, [&] {
636-
return GetCommandLineToolsSDKRoot(sdk.GetVersion());
637-
});
638-
639-
if (clt_root_dir)
640-
return clt_root_dir;
641-
else
642-
llvm::consumeError(clt_root_dir.takeError());
643-
644584
return find_cached_path(g_sdk_path, g_sdk_path_mutex, key, [&](){
645585
return GetXcodeSDK(sdk);
646586
});

0 commit comments

Comments
 (0)