[Lldb-commits] [lldb] c46d9af - Revert "Host: generalise `GetXcodeSDKPath`"

Douglas Yung via lldb-commits lldb-commits at lists.llvm.org
Mon May 1 10:24:27 PDT 2023


Author: Douglas Yung
Date: 2023-05-01T10:22:53-07:00
New Revision: c46d9af26cefb0b24646d3235b75ae7a1b8548d4

URL: https://github.com/llvm/llvm-project/commit/c46d9af26cefb0b24646d3235b75ae7a1b8548d4
DIFF: https://github.com/llvm/llvm-project/commit/c46d9af26cefb0b24646d3235b75ae7a1b8548d4.diff

LOG: Revert "Host: generalise `GetXcodeSDKPath`"

This reverts commit ade3c6a6a88ed3a9b06c076406f196da9d3cc1b9.

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

Added: 
    

Modified: 
    lldb/include/lldb/Host/HostInfoBase.h
    lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
    lldb/source/Core/Module.cpp
    lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
    lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
    lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
    lldb/unittests/Host/HostInfoTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Host/HostInfoBase.h b/lldb/include/lldb/Host/HostInfoBase.h
index 28f809398d5b4..42f71d91f9bf9 100644
--- a/lldb/include/lldb/Host/HostInfoBase.h
+++ b/lldb/include/lldb/Host/HostInfoBase.h
@@ -31,23 +31,6 @@ struct SharedCacheImageInfo {
   lldb::DataBufferSP data_sp;
 };
 
-namespace {
-struct HostInfoError : public llvm::ErrorInfo<HostInfoError> {
-  static char ID;
-  const std::string message_;
-
-  HostInfoError(const std::string message) : message_(std::move(message)) {}
-
-  void log(llvm::raw_ostream &OS) const override { OS << "HostInfoError"; }
-
-  std::error_code convertToErrorCode() const override {
-    return llvm::inconvertibleErrorCode();
-  }
-};
-
-char HostInfoError::ID = 0;
-} // namespace
-
 class HostInfoBase {
 private:
   // Static class, unconstructable.
@@ -125,14 +108,10 @@ class HostInfoBase {
 
   static FileSpec GetXcodeContentsDirectory() { return {}; }
   static FileSpec GetXcodeDeveloperDirectory() { return {}; }
-
-  struct SDKOptions {
-    std::optional<XcodeSDK> XcodeSDK;
-  };
-
-  /// Return the directory containing something like a SDK (reused for Swift).
-  static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options) {
-    return llvm::make_error<HostInfoError>("cannot determine SDK root");
+  
+  /// Return the directory containing a specific Xcode SDK.
+  static llvm::Expected<llvm::StringRef> GetXcodeSDKPath(XcodeSDK sdk) {
+    return "";
   }
 
   /// Return information about module \p image_name if it is loaded in

diff  --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index 74d979d965a73..0402509cfa261 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -31,7 +31,7 @@ class HostInfoMacOSX : public HostInfoPosix {
   static FileSpec GetXcodeDeveloperDirectory();
 
   /// Query xcrun to find an Xcode SDK directory.
-  static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options);
+  static llvm::Expected<llvm::StringRef> GetXcodeSDKPath(XcodeSDK sdk);
 
   /// Shared cache utilities
   static SharedCacheImageInfo

diff  --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 6293cc7853f53..17d8043852ab7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1607,8 +1607,8 @@ std::optional<std::string> Module::RemapSourceFile(llvm::StringRef path) const {
 
 void Module::RegisterXcodeSDK(llvm::StringRef sdk_name,
                               llvm::StringRef sysroot) {
-  auto sdk_path_or_err =
-      HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk_name.str()});
+  XcodeSDK sdk(sdk_name.str());
+  auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(sdk);
 
   if (!sdk_path_or_err) {
     Debugger::ReportError("Error while searching for Xcode SDK: " +

diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 6569013044513..5a39ed370747a 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -338,8 +338,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
       }
     }
 
-    auto sdk_path_or_err =
-        HostInfo::GetSDKRoot(SDKOptions{XcodeSDK::GetAnyMacOS()});
+    auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS());
     if (!sdk_path_or_err) {
       Log *log = GetLog(LLDBLog::Host);
       LLDB_LOGF(log, "Error while searching for Xcode SDK: %s",
@@ -520,7 +519,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
   return path;
 }
 
-llvm::Expected<llvm::StringRef> HostInfoMacOSX::GetSDKRoot(SDKOptions options) {
+llvm::Expected<llvm::StringRef> HostInfoMacOSX::GetXcodeSDKPath(XcodeSDK sdk) {
   struct ErrorOrPath {
     std::string str;
     bool is_error;
@@ -531,11 +530,6 @@ static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
   std::lock_guard<std::mutex> guard(g_sdk_path_mutex);
   LLDB_SCOPED_TIMER();
 
-  if (!options.XcodeSDK)
-    return llvm::createStringError(llvm::inconvertibleErrorCode(),
-                                   "XCodeSDK not specified");
-  XcodeSDK sdk = *options.XcodeSDK;
-
   auto key = sdk.GetString();
   auto it = g_sdk_path.find(key);
   if (it != g_sdk_path.end()) {

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index 7044426e17b50..7501f3edd24ff 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -284,8 +284,7 @@ static llvm::StringRef GetXcodeSDKDir(std::string preferred,
                                       std::string secondary) {
   llvm::StringRef sdk;
   auto get_sdk = [&](std::string sdk) -> llvm::StringRef {
-    auto sdk_path_or_err =
-        HostInfo::GetSDKRoot(HostInfo::SDKOptions{XcodeSDK(std::move(sdk))});
+    auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(sdk)));
     if (!sdk_path_or_err) {
       Debugger::ReportError("Error while searching for Xcode SDK: " +
                             toString(sdk_path_or_err.takeError()));

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index ba412da62e57b..25b821d12a314 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -124,8 +124,7 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) {
   }
 
   // Use the default SDK as a fallback.
-  auto sdk_path_or_err =
-      HostInfo::GetSDKRoot(HostInfo::SDKOptions{XcodeSDK::GetAnyMacOS()});
+  auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS());
   if (!sdk_path_or_err) {
     Debugger::ReportError("Error while searching for Xcode SDK: " +
                           toString(sdk_path_or_err.takeError()));

diff  --git a/lldb/unittests/Host/HostInfoTest.cpp b/lldb/unittests/Host/HostInfoTest.cpp
index 322675c7f485a..b6c8edd74154f 100644
--- a/lldb/unittests/Host/HostInfoTest.cpp
+++ b/lldb/unittests/Host/HostInfoTest.cpp
@@ -57,8 +57,7 @@ TEST_F(HostInfoTest, GetHostname) {
 #if defined(__APPLE__)
 TEST_F(HostInfoTest, GetXcodeSDK) {
   auto get_sdk = [](std::string sdk, bool error = false) -> llvm::StringRef {
-    auto sdk_path_or_err =
-        HostInfo::GetSDKRoot(HostInfo::SDKOptions{XcodeSDK(std::move(sdk))});
+    auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(sdk)));
     if (!error) {
       EXPECT_TRUE((bool)sdk_path_or_err);
       return *sdk_path_or_err;


        


More information about the lldb-commits mailing list