Skip to content

Commit c46d9af

Browse files
committed
Revert "Host: generalise GetXcodeSDKPath"
This reverts commit ade3c6a. This breaks the build with GCC and affects at least 2 build bots: https://lab.llvm.org/buildbot/#/builders/217/builds/20568 https://lab.llvm.org/buildbot/#/builders/243/builds/5576
1 parent 4343534 commit c46d9af

File tree

7 files changed

+12
-42
lines changed

7 files changed

+12
-42
lines changed

lldb/include/lldb/Host/HostInfoBase.h

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@ struct SharedCacheImageInfo {
3131
lldb::DataBufferSP data_sp;
3232
};
3333

34-
namespace {
35-
struct HostInfoError : public llvm::ErrorInfo<HostInfoError> {
36-
static char ID;
37-
const std::string message_;
38-
39-
HostInfoError(const std::string message) : message_(std::move(message)) {}
40-
41-
void log(llvm::raw_ostream &OS) const override { OS << "HostInfoError"; }
42-
43-
std::error_code convertToErrorCode() const override {
44-
return llvm::inconvertibleErrorCode();
45-
}
46-
};
47-
48-
char HostInfoError::ID = 0;
49-
} // namespace
50-
5134
class HostInfoBase {
5235
private:
5336
// Static class, unconstructable.
@@ -125,14 +108,10 @@ class HostInfoBase {
125108

126109
static FileSpec GetXcodeContentsDirectory() { return {}; }
127110
static FileSpec GetXcodeDeveloperDirectory() { return {}; }
128-
129-
struct SDKOptions {
130-
std::optional<XcodeSDK> XcodeSDK;
131-
};
132-
133-
/// Return the directory containing something like a SDK (reused for Swift).
134-
static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options) {
135-
return llvm::make_error<HostInfoError>("cannot determine SDK root");
111+
112+
/// Return the directory containing a specific Xcode SDK.
113+
static llvm::Expected<llvm::StringRef> GetXcodeSDKPath(XcodeSDK sdk) {
114+
return "";
136115
}
137116

138117
/// Return information about module \p image_name if it is loaded in

lldb/include/lldb/Host/macosx/HostInfoMacOSX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class HostInfoMacOSX : public HostInfoPosix {
3131
static FileSpec GetXcodeDeveloperDirectory();
3232

3333
/// Query xcrun to find an Xcode SDK directory.
34-
static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options);
34+
static llvm::Expected<llvm::StringRef> GetXcodeSDKPath(XcodeSDK sdk);
3535

3636
/// Shared cache utilities
3737
static SharedCacheImageInfo

lldb/source/Core/Module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,8 +1607,8 @@ std::optional<std::string> Module::RemapSourceFile(llvm::StringRef path) const {
16071607

16081608
void Module::RegisterXcodeSDK(llvm::StringRef sdk_name,
16091609
llvm::StringRef sysroot) {
1610-
auto sdk_path_or_err =
1611-
HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk_name.str()});
1610+
XcodeSDK sdk(sdk_name.str());
1611+
auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(sdk);
16121612

16131613
if (!sdk_path_or_err) {
16141614
Debugger::ReportError("Error while searching for Xcode SDK: " +

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
338338
}
339339
}
340340

341-
auto sdk_path_or_err =
342-
HostInfo::GetSDKRoot(SDKOptions{XcodeSDK::GetAnyMacOS()});
341+
auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS());
343342
if (!sdk_path_or_err) {
344343
Log *log = GetLog(LLDBLog::Host);
345344
LLDB_LOGF(log, "Error while searching for Xcode SDK: %s",
@@ -520,7 +519,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
520519
return path;
521520
}
522521

523-
llvm::Expected<llvm::StringRef> HostInfoMacOSX::GetSDKRoot(SDKOptions options) {
522+
llvm::Expected<llvm::StringRef> HostInfoMacOSX::GetXcodeSDKPath(XcodeSDK sdk) {
524523
struct ErrorOrPath {
525524
std::string str;
526525
bool is_error;
@@ -531,11 +530,6 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
531530
std::lock_guard<std::mutex> guard(g_sdk_path_mutex);
532531
LLDB_SCOPED_TIMER();
533532

534-
if (!options.XcodeSDK)
535-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
536-
"XCodeSDK not specified");
537-
XcodeSDK sdk = *options.XcodeSDK;
538-
539533
auto key = sdk.GetString();
540534
auto it = g_sdk_path.find(key);
541535
if (it != g_sdk_path.end()) {

lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ static llvm::StringRef GetXcodeSDKDir(std::string preferred,
284284
std::string secondary) {
285285
llvm::StringRef sdk;
286286
auto get_sdk = [&](std::string sdk) -> llvm::StringRef {
287-
auto sdk_path_or_err =
288-
HostInfo::GetSDKRoot(HostInfo::SDKOptions{XcodeSDK(std::move(sdk))});
287+
auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(sdk)));
289288
if (!sdk_path_or_err) {
290289
Debugger::ReportError("Error while searching for Xcode SDK: " +
291290
toString(sdk_path_or_err.takeError()));

lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) {
124124
}
125125

126126
// Use the default SDK as a fallback.
127-
auto sdk_path_or_err =
128-
HostInfo::GetSDKRoot(HostInfo::SDKOptions{XcodeSDK::GetAnyMacOS()});
127+
auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS());
129128
if (!sdk_path_or_err) {
130129
Debugger::ReportError("Error while searching for Xcode SDK: " +
131130
toString(sdk_path_or_err.takeError()));

lldb/unittests/Host/HostInfoTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ TEST_F(HostInfoTest, GetHostname) {
5757
#if defined(__APPLE__)
5858
TEST_F(HostInfoTest, GetXcodeSDK) {
5959
auto get_sdk = [](std::string sdk, bool error = false) -> llvm::StringRef {
60-
auto sdk_path_or_err =
61-
HostInfo::GetSDKRoot(HostInfo::SDKOptions{XcodeSDK(std::move(sdk))});
60+
auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(sdk)));
6261
if (!error) {
6362
EXPECT_TRUE((bool)sdk_path_or_err);
6463
return *sdk_path_or_err;

0 commit comments

Comments
 (0)