Commit c46d9af2 authored by Douglas Yung's avatar Douglas Yung
Browse files

Revert "Host: generalise `GetXcodeSDKPath`"

This reverts commit ade3c6a6.

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
parent 4343534a
Loading
Loading
Loading
Loading
+4 −25
Original line number Diff line number Diff line
@@ -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.
@@ -126,13 +109,9 @@ public:
  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
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ public:
  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
+2 −2
Original line number Diff line number Diff line
@@ -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: " +
+2 −8
Original line number Diff line number Diff line
@@ -338,8 +338,7 @@ FileSpec HostInfoMacOSX::GetXcodeContentsDirectory() {
      }
    }

    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 @@ llvm::Expected<std::string> GetXcodeSDK(XcodeSDK sdk) {
  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 @@ llvm::Expected<llvm::StringRef> HostInfoMacOSX::GetSDKRoot(SDKOptions options) {
  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()) {
+1 −2
Original line number Diff line number Diff line
@@ -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()));
Loading