[Lldb-commits] [lldb] [lldb] move XcodeSDK's sysroot into a separate class (PR #144396)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 30 04:46:22 PDT 2026
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/144396
>From f313db05272404a66fb300dc14e17602931d8ce4 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Mon, 16 Jun 2025 17:54:44 +0100
Subject: [PATCH 1/5] [lldb] move XcodeSDK's sysroot into a separate class
---
lldb/include/lldb/Core/Module.h | 1 +
lldb/include/lldb/Symbol/SymbolFile.h | 2 +-
lldb/include/lldb/Symbol/SymbolFileOnDemand.h | 2 +-
lldb/include/lldb/Target/Platform.h | 10 ++--
lldb/include/lldb/Utility/XcodeSDK.h | 8 +---
lldb/include/lldb/Utility/XcodeSDKPath.h | 48 +++++++++++++++++++
.../Clang/ClangExpressionParser.cpp | 43 +++++++++++++++++
.../Platform/MacOSX/PlatformDarwin.cpp | 23 ++++-----
.../Plugins/Platform/MacOSX/PlatformDarwin.h | 5 +-
.../SymbolFile/DWARF/SymbolFileDWARF.cpp | 2 +-
.../SymbolFile/DWARF/SymbolFileDWARF.h | 2 +-
.../DWARF/SymbolFileDWARFDebugMap.cpp | 2 +-
.../DWARF/SymbolFileDWARFDebugMap.h | 2 +-
lldb/source/Symbol/SymbolFileOnDemand.cpp | 6 +--
lldb/source/Utility/CMakeLists.txt | 1 +
lldb/source/Utility/XcodeSDK.cpp | 6 ---
lldb/source/Utility/XcodeSDKPath.cpp | 29 +++++++++++
.../SymbolFile/DWARF/XcodeSDKModuleTests.cpp | 2 +-
lldb/unittests/Utility/XcodeSDKTest.cpp | 27 ++++++-----
19 files changed, 169 insertions(+), 52 deletions(-)
create mode 100644 lldb/include/lldb/Utility/XcodeSDKPath.h
create mode 100644 lldb/source/Utility/XcodeSDKPath.cpp
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index d33d1b1938ef4..65cccce35f829 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -23,6 +23,7 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/UUID.h"
#include "lldb/Utility/XcodeSDK.h"
+#include "lldb/Utility/XcodeSDKPath.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h
index 6b53ba8b6acce..91bd41f1e67fd 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -149,7 +149,7 @@ class SymbolFile : public PluginInterface {
virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0;
/// Return the Xcode SDK comp_unit was compiled against.
- virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) { return {}; }
+ virtual XcodeSDKPath ParseXcodeSDK(CompileUnit &comp_unit) { return {}; }
/// This function exists because SymbolFileDWARFDebugMap may extra compile
/// units which aren't exposed as "real" compile units. In every other
diff --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
index 6807ae2df8faa..304899f174184 100644
--- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
+++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
@@ -65,7 +65,7 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile {
lldb::LanguageType
ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
- lldb_private::XcodeSDK
+ lldb_private::XcodeSDKPath
ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
void InitializeObject() override;
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index 4db1cd328bc08..e6fb1be61fd7d 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -30,7 +30,7 @@
#include "lldb/Utility/Timeout.h"
#include "lldb/Utility/UnimplementedError.h"
#include "lldb/Utility/UserIDResolver.h"
-#include "lldb/Utility/XcodeSDK.h"
+#include "lldb/Utility/XcodeSDKPath.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-public.h"
@@ -466,16 +466,16 @@ class Platform : public PluginInterface {
/// Search each CU associated with the specified 'module' for
/// the SDK paths the CUs were compiled against. In the presence
/// of different SDKs, we try to pick the most appropriate one
- /// using \ref XcodeSDK::Merge.
+ /// using \ref XcodeSDKPath::Merge.
///
/// \param[in] module Module whose debug-info CUs to parse for
/// which SDK they were compiled against.
///
- /// \returns If successful, returns a pair of a parsed XcodeSDK
+ /// \returns If successful, returns a pair of a parsed XcodeSDKPath
/// object and a boolean that is 'true' if we encountered
/// a conflicting combination of SDKs when parsing the CUs
/// (e.g., a public and internal SDK).
- virtual llvm::Expected<std::pair<XcodeSDK, bool>>
+ virtual llvm::Expected<std::pair<XcodeSDKPath, bool>>
GetSDKPathFromDebugInfo(Module &module) {
return llvm::make_error<UnimplementedError>(
llvm::formatv("{0} not implemented for '{1}' platform.",
@@ -503,7 +503,7 @@ class Platform : public PluginInterface {
/// \param[in] unit The CU
///
/// \returns A parsed XcodeSDK object if successful, an Error otherwise.
- virtual llvm::Expected<XcodeSDK>
+ virtual llvm::Expected<XcodeSDKPath>
GetSDKPathFromDebugInfo(CompileUnit & /*unit*/) {
return llvm::make_error<UnimplementedError>(
llvm::formatv("{0} not implemented for '{1}' platform.",
diff --git a/lldb/include/lldb/Utility/XcodeSDK.h b/lldb/include/lldb/Utility/XcodeSDK.h
index a9cb997fec1e4..d14da59784b21 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -9,7 +9,6 @@
#ifndef LLDB_UTILITY_XCODESDK_H
#define LLDB_UTILITY_XCODESDK_H
-#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-forward.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/VersionTuple.h"
@@ -24,7 +23,6 @@ namespace lldb_private {
/// An abstraction for Xcode-style SDKs that works like \ref ArchSpec.
class XcodeSDK {
std::string m_name;
- FileSpec m_sysroot;
public:
/// Different types of Xcode SDKs.
@@ -64,10 +62,6 @@ class XcodeSDK {
/// directory component of a path one would pass to clang's -isysroot
/// parameter. For example, "MacOSX.10.14.sdk".
XcodeSDK(std::string &&name) : m_name(std::move(name)) {}
- XcodeSDK(std::string name, FileSpec sysroot)
- : m_name(std::move(name)), m_sysroot(std::move(sysroot)) {
- assert(!m_sysroot || m_name == m_sysroot.GetFilename().GetStringRef());
- }
static XcodeSDK GetAnyMacOS() { return XcodeSDK("MacOSX.sdk"); }
/// The merge function follows a strict order to maintain monotonicity:
@@ -86,6 +80,8 @@ class XcodeSDK {
Type GetType() const;
llvm::StringRef GetString() const;
const FileSpec &GetSysroot() const;
+ /// Whether this Xcode SDK supports Swift.
+ bool SupportsSwift() const;
/// Whether LLDB feels confident importing Clang modules from this SDK.
static bool SDKSupportsModules(Type type, llvm::VersionTuple version);
diff --git a/lldb/include/lldb/Utility/XcodeSDKPath.h b/lldb/include/lldb/Utility/XcodeSDKPath.h
new file mode 100644
index 0000000000000..68a2ca1d33bad
--- /dev/null
+++ b/lldb/include/lldb/Utility/XcodeSDKPath.h
@@ -0,0 +1,48 @@
+//===-- XcodeSDK.h ----------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_UTILITY_SDK_PATH_H
+#define LLDB_UTILITY_SDK_PATH_H
+
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/XcodeSDK.h"
+
+namespace llvm {
+class Triple;
+}
+
+namespace lldb_private {
+
+/// An abstraction which groups an XcodeSDK with its parsed path.
+class XcodeSDKPath {
+ XcodeSDK m_sdk;
+ FileSpec m_sysroot;
+
+public:
+ /// Default constructor, constructs an empty sdk with an empty path.
+ XcodeSDKPath() = default;
+ XcodeSDKPath(XcodeSDK sdk, FileSpec sysroot)
+ : m_sdk(std::move(sdk)), m_sysroot(std::move(sysroot)) {}
+ XcodeSDKPath(std::string name, FileSpec sysroot)
+ : m_sdk(XcodeSDK(std::move(name))), m_sysroot(std::move(sysroot)) {}
+
+ bool operator==(const XcodeSDKPath &other) const;
+ bool operator!=(const XcodeSDKPath &other) const;
+
+ XcodeSDK TakeSDK() const;
+ const FileSpec &GetSysroot() const { return m_sysroot; }
+ llvm::StringRef GetString() const { return m_sdk.GetString(); }
+ XcodeSDK::Type GetType() const { return m_sdk.GetType(); }
+
+ void Merge(const XcodeSDKPath &other);
+ bool IsAppleInternalSDK() const { return m_sdk.IsAppleInternalSDK(); }
+};
+
+} // namespace lldb_private
+
+#endif
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index ae02fda33fe66..12e4d9b6931d9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -323,6 +323,49 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer {
StringRef m_filename;
};
+/// Returns true if the SDK for the specified triple supports
+/// builtin modules in system headers. This is used to decide
+/// whether to pass -fbuiltin-headers-in-system-modules to
+/// the compiler instance when compiling the `std` module.
+static llvm::Expected<bool>
+sdkSupportsBuiltinModules(lldb_private::Target &target) {
+ auto arch_spec = target.GetArchitecture();
+ auto const &triple = arch_spec.GetTriple();
+ auto module_sp = target.GetExecutableModule();
+ if (!module_sp)
+ return llvm::createStringError("Executable module not found.");
+
+ // Get SDK path that the target was compiled against.
+ auto platform_sp = target.GetPlatform();
+ if (!platform_sp)
+ return llvm::createStringError("No Platform plugin found on target.");
+
+ auto sdk_or_err = platform_sp->GetSDKPathFromDebugInfo(*module_sp);
+ if (!sdk_or_err)
+ return sdk_or_err.takeError();
+
+ // Use the SDK path from debug-info to find a local matching SDK directory.
+ auto sdk_path_or_err =
+ HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk_or_err->first.TakeSDK()});
+ if (!sdk_path_or_err)
+ return sdk_path_or_err.takeError();
+
+ auto VFS = FileSystem::Instance().GetVirtualFileSystem();
+ if (!VFS)
+ return llvm::createStringError("No virtual filesystem available.");
+
+ // Extract SDK version from the /path/to/some.sdk/SDKSettings.json
+ auto parsed_or_err = clang::parseDarwinSDKInfo(*VFS, *sdk_path_or_err);
+ if (!parsed_or_err)
+ return parsed_or_err.takeError();
+
+ auto maybe_sdk = *parsed_or_err;
+ if (!maybe_sdk)
+ return llvm::createStringError("Couldn't find Darwin SDK info.");
+
+ return XcodeSDK::SDKSupportsBuiltinModules(triple, maybe_sdk->getVersion());
+}
+
static void SetupModuleHeaderPaths(CompilerInstance *compiler,
std::vector<std::string> include_directories,
lldb::TargetSP target_sp) {
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 8db4824be7da5..165af9b17ff14 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1470,7 +1470,7 @@ llvm::Triple::OSType PlatformDarwin::GetHostOSType() {
#endif // __APPLE__
}
-llvm::Expected<std::pair<XcodeSDK, bool>>
+llvm::Expected<std::pair<XcodeSDKPath, bool>>
PlatformDarwin::GetSDKPathFromDebugInfo(Module &module) {
SymbolFile *sym_file = module.GetSymbolFile();
if (!sym_file)
@@ -1487,7 +1487,7 @@ PlatformDarwin::GetSDKPathFromDebugInfo(Module &module) {
bool found_public_sdk = false;
bool found_internal_sdk = false;
- XcodeSDK merged_sdk;
+ XcodeSDKPath merged_sdk_path;
for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
@@ -1495,13 +1495,13 @@ PlatformDarwin::GetSDKPathFromDebugInfo(Module &module) {
found_public_sdk |= !is_internal_sdk;
found_internal_sdk |= is_internal_sdk;
- merged_sdk.Merge(cu_sdk);
+ merged_sdk_path.Merge(cu_sdk);
}
}
const bool found_mismatch = found_internal_sdk && found_public_sdk;
- return std::pair{std::move(merged_sdk), found_mismatch};
+ return std::pair{std::move(merged_sdk_path), found_mismatch};
}
llvm::Expected<std::string>
@@ -1513,23 +1513,24 @@ PlatformDarwin::ResolveSDKPathFromDebugInfo(Module &module) {
llvm::formatv("Failed to parse SDK path from debug-info: {0}",
llvm::toString(sdk_or_err.takeError())));
- auto [sdk, _] = std::move(*sdk_or_err);
+ auto [sdk_path, _] = std::move(*sdk_or_err);
- if (FileSystem::Instance().Exists(sdk.GetSysroot()))
- return sdk.GetSysroot().GetPath();
+ if (FileSystem::Instance().Exists(sdk_path.GetSysroot()))
+ return sdk_path.GetSysroot().GetPath();
- auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
+ auto path_or_err =
+ HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk_path.TakeSDK()});
if (!path_or_err)
return llvm::createStringError(
llvm::inconvertibleErrorCode(),
llvm::formatv("Error while searching for SDK (XcodeSDK '{0}'): {1}",
- sdk.GetString(),
+ sdk_path.GetString(),
llvm::toString(path_or_err.takeError())));
return path_or_err->str();
}
-llvm::Expected<XcodeSDK>
+llvm::Expected<XcodeSDKPath>
PlatformDarwin::GetSDKPathFromDebugInfo(CompileUnit &unit) {
ModuleSP module_sp = unit.CalculateSymbolContextModule();
if (!module_sp)
@@ -1554,7 +1555,7 @@ PlatformDarwin::ResolveSDKPathFromDebugInfo(CompileUnit &unit) {
auto sdk = std::move(*sdk_or_err);
- auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
+ auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk.TakeSDK()});
if (!path_or_err)
return llvm::createStringError(
llvm::inconvertibleErrorCode(),
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index f3c176f09cb68..e97250aa335b1 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -124,13 +124,14 @@ class PlatformDarwin : public PlatformPOSIX {
llvm::Expected<StructuredData::DictionarySP>
FetchExtendedCrashInformation(Process &process) override;
- llvm::Expected<std::pair<XcodeSDK, bool>>
+ llvm::Expected<std::pair<XcodeSDKPath, bool>>
GetSDKPathFromDebugInfo(Module &module) override;
llvm::Expected<std::string>
ResolveSDKPathFromDebugInfo(Module &module) override;
- llvm::Expected<XcodeSDK> GetSDKPathFromDebugInfo(CompileUnit &unit) override;
+ llvm::Expected<XcodeSDKPath>
+ GetSDKPathFromDebugInfo(CompileUnit &unit) override;
llvm::Expected<std::string>
ResolveSDKPathFromDebugInfo(CompileUnit &unit) override;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index aca36b45d69ca..2fe827513d9f5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -989,7 +989,7 @@ lldb::LanguageType SymbolFileDWARF::ParseLanguage(CompileUnit &comp_unit) {
return eLanguageTypeUnknown;
}
-XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit &comp_unit) {
+XcodeSDKPath SymbolFileDWARF::ParseXcodeSDK(CompileUnit &comp_unit) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
if (!dwarf_cu)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 09dc8da9b7260..dfddf758f04f2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -110,7 +110,7 @@ class SymbolFileDWARF : public SymbolFileCommon {
lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) override;
- XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) override;
+ XcodeSDKPath ParseXcodeSDK(CompileUnit &comp_unit) override;
size_t ParseFunctions(CompileUnit &comp_unit) override;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index eb80b7ed45d7b..ea83b620ee0f4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -686,7 +686,7 @@ SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) {
return eLanguageTypeUnknown;
}
-XcodeSDK SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
+XcodeSDKPath SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
if (oso_dwarf)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 74b97f610f29c..4a778b572694b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -64,7 +64,7 @@ class SymbolFileDWARFDebugMap : public SymbolFileCommon {
// Compile Unit function calls
lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) override;
- XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) override;
+ XcodeSDKPath ParseXcodeSDK(CompileUnit &comp_unit) override;
llvm::SmallSet<lldb::LanguageType, 4>
ParseAllLanguages(CompileUnit &comp_unit) override;
size_t ParseFunctions(CompileUnit &comp_unit) override;
diff --git a/lldb/source/Symbol/SymbolFileOnDemand.cpp b/lldb/source/Symbol/SymbolFileOnDemand.cpp
index 5ff4d7d23fc81..11ee06a7a910f 100644
--- a/lldb/source/Symbol/SymbolFileOnDemand.cpp
+++ b/lldb/source/Symbol/SymbolFileOnDemand.cpp
@@ -58,13 +58,13 @@ lldb::LanguageType SymbolFileOnDemand::ParseLanguage(CompileUnit &comp_unit) {
return m_sym_file_impl->ParseLanguage(comp_unit);
}
-XcodeSDK SymbolFileOnDemand::ParseXcodeSDK(CompileUnit &comp_unit) {
+XcodeSDKPath SymbolFileOnDemand::ParseXcodeSDK(CompileUnit &comp_unit) {
if (!m_debug_info_enabled) {
Log *log = GetLog();
LLDB_LOG(log, "[{0}] {1} is skipped", GetSymbolFileName(), __FUNCTION__);
- XcodeSDK defaultValue{};
+ XcodeSDKPath defaultValue{};
if (log) {
- XcodeSDK sdk = m_sym_file_impl->ParseXcodeSDK(comp_unit);
+ XcodeSDKPath sdk = m_sym_file_impl->ParseXcodeSDK(comp_unit);
if (!(sdk == defaultValue))
LLDB_LOG(log, "SDK {0} would return if hydrated.", sdk.GetString());
}
diff --git a/lldb/source/Utility/CMakeLists.txt b/lldb/source/Utility/CMakeLists.txt
index 3836ab0ec6c29..352f32aecbbcb 100644
--- a/lldb/source/Utility/CMakeLists.txt
+++ b/lldb/source/Utility/CMakeLists.txt
@@ -77,6 +77,7 @@ add_lldb_library(lldbUtility NO_INTERNAL_DEPENDENCIES
VASprintf.cpp
VirtualDataExtractor.cpp
XcodeSDK.cpp
+ XcodeSDKPath.cpp
ZipFile.cpp
ADDITIONAL_HEADER_DIRS
diff --git a/lldb/source/Utility/XcodeSDK.cpp b/lldb/source/Utility/XcodeSDK.cpp
index 89e05de975835..f0366154a4430 100644
--- a/lldb/source/Utility/XcodeSDK.cpp
+++ b/lldb/source/Utility/XcodeSDK.cpp
@@ -142,8 +142,6 @@ XcodeSDK::Type XcodeSDK::GetType() const {
llvm::StringRef XcodeSDK::GetString() const { return m_name; }
-const FileSpec &XcodeSDK::GetSysroot() const { return m_sysroot; }
-
bool XcodeSDK::Info::operator<(const Info &other) const {
return std::tie(type, version, internal) <
std::tie(other.type, other.version, other.internal);
@@ -168,10 +166,6 @@ void XcodeSDK::Merge(const XcodeSDK &other) {
m_name.substr(0, m_name.size() - 3) + std::string("Internal.sdk");
}
}
-
- // We changed the SDK name. Adjust the sysroot accordingly.
- if (m_sysroot && m_sysroot.GetFilename().GetStringRef() != m_name)
- m_sysroot.SetFilename(m_name);
}
std::string XcodeSDK::GetCanonicalName(XcodeSDK::Info info) {
diff --git a/lldb/source/Utility/XcodeSDKPath.cpp b/lldb/source/Utility/XcodeSDKPath.cpp
new file mode 100644
index 0000000000000..e742fbe94c9b2
--- /dev/null
+++ b/lldb/source/Utility/XcodeSDKPath.cpp
@@ -0,0 +1,29 @@
+//===-- XcodeSDKPath.cpp --------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/XcodeSDKPath.h"
+
+#include <string>
+
+using namespace lldb;
+using namespace lldb_private;
+
+void XcodeSDKPath::Merge(const XcodeSDKPath &other) {
+ m_sdk.Merge(other.m_sdk);
+
+ // We changed the SDK name. Adjust the sysroot accordingly.
+ auto name = m_sdk.GetString();
+ if (m_sysroot && m_sysroot.GetFilename().GetStringRef() != name)
+ m_sysroot.SetFilename(name);
+}
+
+XcodeSDK XcodeSDKPath::TakeSDK() const { return std::move(m_sdk); }
+
+bool XcodeSDKPath::operator==(const XcodeSDKPath &other) const {
+ return m_sdk == other.m_sdk && m_sysroot == other.m_sysroot;
+}
diff --git a/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp b/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
index 50c37dcd4568e..772f901a3ffe3 100644
--- a/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
@@ -116,7 +116,7 @@ TEST_F(XcodeSDKModuleTests, TestModuleGetXcodeSDK) {
SymbolFileDWARF &sym_file = dwarf_cu->GetSymbolFileDWARF();
CompUnitSP comp_unit = sym_file.GetCompileUnitAtIndex(0);
ASSERT_TRUE(static_cast<bool>(comp_unit.get()));
- XcodeSDK sdk = sym_file.ParseXcodeSDK(*comp_unit);
+ XcodeSDKPath sdk = sym_file.ParseXcodeSDK(*comp_unit);
ASSERT_EQ(sdk.GetType(), XcodeSDK::Type::MacOSX);
}
diff --git a/lldb/unittests/Utility/XcodeSDKTest.cpp b/lldb/unittests/Utility/XcodeSDKTest.cpp
index a8a597bdeb746..2c3a9b020419f 100644
--- a/lldb/unittests/Utility/XcodeSDKTest.cpp
+++ b/lldb/unittests/Utility/XcodeSDKTest.cpp
@@ -10,6 +10,7 @@
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/XcodeSDK.h"
+#include "lldb/Utility/XcodeSDKPath.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/TargetParser/Triple.h"
@@ -36,16 +37,14 @@ TEST(XcodeSDKTest, ParseTest) {
EXPECT_EQ(XcodeSDK("MacOSX10.15.4.sdk").GetVersion(), llvm::VersionTuple(10, 15));
EXPECT_EQ(XcodeSDK("MacOSX.sdk").IsAppleInternalSDK(), false);
EXPECT_EQ(
- XcodeSDK("MacOSX.sdk", FileSpec{"/Path/To/MacOSX.sdk"}).GetSysroot(),
+ XcodeSDKPath("MacOSX.sdk", FileSpec{"/Path/To/MacOSX.sdk"}).GetSysroot(),
FileSpec("/Path/To/MacOSX.sdk"));
EXPECT_EQ(XcodeSDK("MacOSX10.15.Internal.sdk").GetType(), XcodeSDK::MacOSX);
EXPECT_EQ(XcodeSDK("MacOSX10.15.Internal.sdk").GetVersion(),
llvm::VersionTuple(10, 15));
EXPECT_EQ(XcodeSDK("MacOSX10.15.Internal.sdk").IsAppleInternalSDK(), true);
- EXPECT_FALSE(XcodeSDK("MacOSX10.15.Internal.sdk").GetSysroot());
EXPECT_EQ(XcodeSDK().GetType(), XcodeSDK::unknown);
EXPECT_EQ(XcodeSDK().GetVersion(), llvm::VersionTuple());
- EXPECT_FALSE(XcodeSDK().GetSysroot());
}
TEST(XcodeSDKTest, MergeTest) {
@@ -66,15 +65,19 @@ TEST(XcodeSDKTest, MergeTest) {
XcodeSDK empty;
empty.Merge(XcodeSDK("MacOSX10.14.Internal.sdk"));
EXPECT_EQ(empty.GetString(), llvm::StringRef("MacOSX10.14.Internal.sdk"));
- EXPECT_FALSE(empty.GetSysroot());
- empty.Merge(XcodeSDK("MacOSX9.5.Internal.sdk",
- FileSpec{"/Path/To/MacOSX9.5.Internal.sdk"}));
- EXPECT_FALSE(empty.GetSysroot());
- empty.Merge(XcodeSDK("MacOSX12.5.sdk", FileSpec{"/Path/To/MacOSX12.5.sdk"}));
- EXPECT_EQ(empty.GetSysroot(), FileSpec{"/Path/To/MacOSX12.5.sdk"});
- empty.Merge(XcodeSDK("MacOSX11.5.Internal.sdk",
- FileSpec{"/Path/To/MacOSX11.5.Internal.sdk"}));
- EXPECT_EQ(empty.GetSysroot(), FileSpec{"/Path/To/MacOSX12.5.Internal.sdk"});
+ XcodeSDKPath empty_path("MacOSX10.14.Internal.sdk",
+ FileSpec{"/Path/To/MacOSX10.14.Internal.sdk"});
+ empty_path.Merge(XcodeSDKPath("MacOSX9.5.Internal.sdk",
+ FileSpec{"/Path/To/MacOSX9.5.Internal.sdk"}));
+ EXPECT_EQ(empty_path.GetSysroot(),
+ FileSpec{"/Path/To/MacOSX10.14.Internal.sdk"});
+ empty_path.Merge(
+ XcodeSDKPath("MacOSX12.5.sdk", FileSpec{"/Path/To/MacOSX12.5.sdk"}));
+ EXPECT_EQ(empty_path.GetSysroot(), FileSpec{"/Path/To/MacOSX12.5.sdk"});
+ empty_path.Merge(XcodeSDKPath("MacOSX11.5.Internal.sdk",
+ FileSpec{"/Path/To/MacOSX11.5.Internal.sdk"}));
+ EXPECT_EQ(empty_path.GetSysroot(),
+ FileSpec{"/Path/To/MacOSX12.5.Internal.sdk"});
}
#ifndef _WIN32
>From 4646cff2ca8f60ce6d0932fee0f1ff1822160661 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Tue, 17 Jun 2025 18:14:21 +0100
Subject: [PATCH 2/5] move XcodeSDKPath in XcodeSDK.h
---
lldb/include/lldb/Core/Module.h | 1 -
lldb/include/lldb/Target/Platform.h | 2 +-
lldb/include/lldb/Utility/XcodeSDK.h | 26 +++++++++++++
lldb/include/lldb/Utility/XcodeSDKPath.h | 48 ------------------------
lldb/source/Utility/XcodeSDKPath.cpp | 3 +-
lldb/unittests/Utility/XcodeSDKTest.cpp | 1 -
6 files changed, 28 insertions(+), 53 deletions(-)
delete mode 100644 lldb/include/lldb/Utility/XcodeSDKPath.h
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 65cccce35f829..d33d1b1938ef4 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -23,7 +23,6 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/UUID.h"
#include "lldb/Utility/XcodeSDK.h"
-#include "lldb/Utility/XcodeSDKPath.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index e6fb1be61fd7d..e5ab9757d3766 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -30,7 +30,7 @@
#include "lldb/Utility/Timeout.h"
#include "lldb/Utility/UnimplementedError.h"
#include "lldb/Utility/UserIDResolver.h"
-#include "lldb/Utility/XcodeSDKPath.h"
+#include "lldb/Utility/XcodeSDK.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-public.h"
diff --git a/lldb/include/lldb/Utility/XcodeSDK.h b/lldb/include/lldb/Utility/XcodeSDK.h
index d14da59784b21..09fd385875941 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -9,6 +9,7 @@
#ifndef LLDB_UTILITY_XCODESDK_H
#define LLDB_UTILITY_XCODESDK_H
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-forward.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/VersionTuple.h"
@@ -95,6 +96,31 @@ class XcodeSDK {
static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path);
};
+/// An abstraction which groups an XcodeSDK with its parsed path.
+class XcodeSDKPath {
+ XcodeSDK m_sdk;
+ FileSpec m_sysroot;
+
+public:
+ /// Default constructor, constructs an empty sdk with an empty path.
+ XcodeSDKPath() = default;
+ XcodeSDKPath(XcodeSDK sdk, FileSpec sysroot)
+ : m_sdk(std::move(sdk)), m_sysroot(std::move(sysroot)) {}
+ XcodeSDKPath(std::string name, FileSpec sysroot)
+ : m_sdk(XcodeSDK(std::move(name))), m_sysroot(std::move(sysroot)) {}
+
+ bool operator==(const XcodeSDKPath &other) const;
+ bool operator!=(const XcodeSDKPath &other) const;
+
+ XcodeSDK TakeSDK() const;
+ const FileSpec &GetSysroot() const { return m_sysroot; }
+ llvm::StringRef GetString() const { return m_sdk.GetString(); }
+ XcodeSDK::Type GetType() const { return m_sdk.GetType(); }
+
+ void Merge(const XcodeSDKPath &other);
+ bool IsAppleInternalSDK() const { return m_sdk.IsAppleInternalSDK(); }
+};
+
} // namespace lldb_private
#endif
diff --git a/lldb/include/lldb/Utility/XcodeSDKPath.h b/lldb/include/lldb/Utility/XcodeSDKPath.h
deleted file mode 100644
index 68a2ca1d33bad..0000000000000
--- a/lldb/include/lldb/Utility/XcodeSDKPath.h
+++ /dev/null
@@ -1,48 +0,0 @@
-//===-- XcodeSDK.h ----------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLDB_UTILITY_SDK_PATH_H
-#define LLDB_UTILITY_SDK_PATH_H
-
-#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/XcodeSDK.h"
-
-namespace llvm {
-class Triple;
-}
-
-namespace lldb_private {
-
-/// An abstraction which groups an XcodeSDK with its parsed path.
-class XcodeSDKPath {
- XcodeSDK m_sdk;
- FileSpec m_sysroot;
-
-public:
- /// Default constructor, constructs an empty sdk with an empty path.
- XcodeSDKPath() = default;
- XcodeSDKPath(XcodeSDK sdk, FileSpec sysroot)
- : m_sdk(std::move(sdk)), m_sysroot(std::move(sysroot)) {}
- XcodeSDKPath(std::string name, FileSpec sysroot)
- : m_sdk(XcodeSDK(std::move(name))), m_sysroot(std::move(sysroot)) {}
-
- bool operator==(const XcodeSDKPath &other) const;
- bool operator!=(const XcodeSDKPath &other) const;
-
- XcodeSDK TakeSDK() const;
- const FileSpec &GetSysroot() const { return m_sysroot; }
- llvm::StringRef GetString() const { return m_sdk.GetString(); }
- XcodeSDK::Type GetType() const { return m_sdk.GetType(); }
-
- void Merge(const XcodeSDKPath &other);
- bool IsAppleInternalSDK() const { return m_sdk.IsAppleInternalSDK(); }
-};
-
-} // namespace lldb_private
-
-#endif
diff --git a/lldb/source/Utility/XcodeSDKPath.cpp b/lldb/source/Utility/XcodeSDKPath.cpp
index e742fbe94c9b2..586d6af450e24 100644
--- a/lldb/source/Utility/XcodeSDKPath.cpp
+++ b/lldb/source/Utility/XcodeSDKPath.cpp
@@ -5,8 +5,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-
-#include "lldb/Utility/XcodeSDKPath.h"
+#include "lldb/Utility/XcodeSDK.h"
#include <string>
diff --git a/lldb/unittests/Utility/XcodeSDKTest.cpp b/lldb/unittests/Utility/XcodeSDKTest.cpp
index 2c3a9b020419f..c8747433b2abe 100644
--- a/lldb/unittests/Utility/XcodeSDKTest.cpp
+++ b/lldb/unittests/Utility/XcodeSDKTest.cpp
@@ -10,7 +10,6 @@
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/XcodeSDK.h"
-#include "lldb/Utility/XcodeSDKPath.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/TargetParser/Triple.h"
>From 8b1b058acd8f19a0c9545bc2702c104474ac0a45 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 29 Apr 2026 22:18:36 +0100
Subject: [PATCH 3/5] fixup! move XcodeSDKPath in XcodeSDK.h
---
lldb/include/lldb/Utility/XcodeSDK.h | 1 -
.../Platform/MacOSX/PlatformDarwin.cpp | 4 +-
.../Platform/Windows/PlatformWindows.cpp | 74 +++++++++++++++++++
.../Platform/Windows/PlatformWindows.h | 12 +++
lldb/source/Utility/XcodeSDKPath.cpp | 4 +
5 files changed, 92 insertions(+), 3 deletions(-)
diff --git a/lldb/include/lldb/Utility/XcodeSDK.h b/lldb/include/lldb/Utility/XcodeSDK.h
index 09fd385875941..f48b831c46818 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -80,7 +80,6 @@ class XcodeSDK {
llvm::VersionTuple GetVersion() const;
Type GetType() const;
llvm::StringRef GetString() const;
- const FileSpec &GetSysroot() const;
/// Whether this Xcode SDK supports Swift.
bool SupportsSwift() const;
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 165af9b17ff14..31945f485fab7 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1120,7 +1120,7 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target *target) {
"Failed to resolve SDK for target: executable's symbol file has no "
"compile units");
- XcodeSDK merged_sdk;
+ XcodeSDKPath merged_sdk;
for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
@@ -1134,7 +1134,7 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target *target) {
if (FileSystem::Instance().Exists(sdk_path)) {
return sdk_path;
}
- auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk});
+ auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk.TakeSDK()});
if (!path_or_err)
return llvm::createStringError(
llvm::formatv("Failed to resolve SDK path: {0}",
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 9e11b66068381..170e67113541c 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -27,6 +27,8 @@
#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/Status.h"
@@ -817,3 +819,75 @@ extern "C" {
return Status();
}
+
+llvm::Expected<std::pair<XcodeSDKPath, bool>>
+PlatformWindows::GetSDKPathFromDebugInfo(Module &module) {
+ SymbolFile *sym_file = module.GetSymbolFile();
+ if (!sym_file)
+ return llvm::createStringError(
+ llvm::inconvertibleErrorCode(),
+ llvm::formatv("No symbol file available for module '{0}'",
+ module.GetFileSpec().GetFilename().AsCString("")));
+
+ if (sym_file->GetNumCompileUnits() == 0)
+ return llvm::createStringError(
+ llvm::formatv("Could not resolve SDK for module '{0}'. Symbol file has "
+ "no compile units.",
+ module.GetFileSpec()));
+
+ bool found_public_sdk = false;
+ bool found_internal_sdk = false;
+ XcodeSDKPath merged_sdk_path;
+ for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
+ if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
+ auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
+ bool is_internal_sdk = cu_sdk.IsAppleInternalSDK();
+ found_public_sdk |= !is_internal_sdk;
+ found_internal_sdk |= is_internal_sdk;
+ merged_sdk_path.Merge(cu_sdk);
+ }
+ }
+
+ const bool found_mismatch = found_internal_sdk && found_public_sdk;
+ return std::pair{std::move(merged_sdk_path), found_mismatch};
+}
+
+llvm::Expected<std::string>
+PlatformWindows::ResolveSDKPathFromDebugInfo(Module &module) {
+ auto sdk_or_err = GetSDKPathFromDebugInfo(module);
+ if (!sdk_or_err)
+ return llvm::createStringError(
+ llvm::inconvertibleErrorCode(),
+ llvm::formatv("Failed to parse SDK path from debug-info: {0}",
+ llvm::toString(sdk_or_err.takeError())));
+
+ auto [sdk_path, _] = std::move(*sdk_or_err);
+ return sdk_path.GetSysroot().GetPath();
+}
+
+llvm::Expected<XcodeSDKPath>
+PlatformWindows::GetSDKPathFromDebugInfo(CompileUnit &unit) {
+ ModuleSP module_sp = unit.CalculateSymbolContextModule();
+ if (!module_sp)
+ return llvm::createStringError("compile unit has no module");
+ SymbolFile *sym_file = module_sp->GetSymbolFile();
+ if (!sym_file)
+ return llvm::createStringError(
+ llvm::formatv("No symbol file available for module '{0}'",
+ module_sp->GetFileSpec().GetFilename()));
+
+ return sym_file->ParseXcodeSDK(unit);
+}
+
+llvm::Expected<std::string>
+PlatformWindows::ResolveSDKPathFromDebugInfo(CompileUnit &unit) {
+ auto sdk_or_err = GetSDKPathFromDebugInfo(unit);
+ if (!sdk_or_err)
+ return llvm::createStringError(
+ llvm::inconvertibleErrorCode(),
+ llvm::formatv("Failed to parse SDK path from debug-info: {0}",
+ llvm::toString(sdk_or_err.takeError())));
+
+ auto sdk = std::move(*sdk_or_err);
+ return sdk.GetSysroot().GetPath();
+}
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h
index 771133f341e90..025d4b4375c37 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h
@@ -80,6 +80,18 @@ class PlatformWindows : public RemoteAwarePlatform {
size_t GetSoftwareBreakpointTrapOpcode(Target &target,
BreakpointSite *bp_site) override;
+ llvm::Expected<std::pair<XcodeSDKPath, bool>>
+ GetSDKPathFromDebugInfo(Module &module) override;
+
+ llvm::Expected<std::string>
+ ResolveSDKPathFromDebugInfo(Module &module) override;
+
+ llvm::Expected<XcodeSDKPath>
+ GetSDKPathFromDebugInfo(CompileUnit &unit) override;
+
+ llvm::Expected<std::string>
+ ResolveSDKPathFromDebugInfo(CompileUnit &unit) override;
+
std::vector<ArchSpec> m_supported_architectures;
private:
diff --git a/lldb/source/Utility/XcodeSDKPath.cpp b/lldb/source/Utility/XcodeSDKPath.cpp
index 586d6af450e24..d1a03a94f8d83 100644
--- a/lldb/source/Utility/XcodeSDKPath.cpp
+++ b/lldb/source/Utility/XcodeSDKPath.cpp
@@ -26,3 +26,7 @@ XcodeSDK XcodeSDKPath::TakeSDK() const { return std::move(m_sdk); }
bool XcodeSDKPath::operator==(const XcodeSDKPath &other) const {
return m_sdk == other.m_sdk && m_sysroot == other.m_sysroot;
}
+
+bool XcodeSDKPath::operator!=(const XcodeSDKPath &other) const {
+ return !(*this == other);
+}
>From 99bb7f08267ea0bdc231a86c6933c03dd0d83eda Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 30 Apr 2026 11:35:04 +0100
Subject: [PATCH 4/5] fixup! fixup! move XcodeSDKPath in XcodeSDK.h
---
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 31945f485fab7..5cb379a70f07f 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1134,7 +1134,8 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target *target) {
if (FileSystem::Instance().Exists(sdk_path)) {
return sdk_path;
}
- auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk.TakeSDK()});
+ auto path_or_err =
+ HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk.TakeSDK()});
if (!path_or_err)
return llvm::createStringError(
llvm::formatv("Failed to resolve SDK path: {0}",
>From 0f0338cfaf9fa8a735f5a941b5cba797c7ebdbdf Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 30 Apr 2026 12:46:08 +0100
Subject: [PATCH 5/5] fix build
---
.../Clang/ClangExpressionParser.cpp | 43 -------------------
1 file changed, 43 deletions(-)
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 12e4d9b6931d9..ae02fda33fe66 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -323,49 +323,6 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer {
StringRef m_filename;
};
-/// Returns true if the SDK for the specified triple supports
-/// builtin modules in system headers. This is used to decide
-/// whether to pass -fbuiltin-headers-in-system-modules to
-/// the compiler instance when compiling the `std` module.
-static llvm::Expected<bool>
-sdkSupportsBuiltinModules(lldb_private::Target &target) {
- auto arch_spec = target.GetArchitecture();
- auto const &triple = arch_spec.GetTriple();
- auto module_sp = target.GetExecutableModule();
- if (!module_sp)
- return llvm::createStringError("Executable module not found.");
-
- // Get SDK path that the target was compiled against.
- auto platform_sp = target.GetPlatform();
- if (!platform_sp)
- return llvm::createStringError("No Platform plugin found on target.");
-
- auto sdk_or_err = platform_sp->GetSDKPathFromDebugInfo(*module_sp);
- if (!sdk_or_err)
- return sdk_or_err.takeError();
-
- // Use the SDK path from debug-info to find a local matching SDK directory.
- auto sdk_path_or_err =
- HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk_or_err->first.TakeSDK()});
- if (!sdk_path_or_err)
- return sdk_path_or_err.takeError();
-
- auto VFS = FileSystem::Instance().GetVirtualFileSystem();
- if (!VFS)
- return llvm::createStringError("No virtual filesystem available.");
-
- // Extract SDK version from the /path/to/some.sdk/SDKSettings.json
- auto parsed_or_err = clang::parseDarwinSDKInfo(*VFS, *sdk_path_or_err);
- if (!parsed_or_err)
- return parsed_or_err.takeError();
-
- auto maybe_sdk = *parsed_or_err;
- if (!maybe_sdk)
- return llvm::createStringError("Couldn't find Darwin SDK info.");
-
- return XcodeSDK::SDKSupportsBuiltinModules(triple, maybe_sdk->getVersion());
-}
-
static void SetupModuleHeaderPaths(CompilerInstance *compiler,
std::vector<std::string> include_directories,
lldb::TargetSP target_sp) {
More information about the lldb-commits
mailing list