[Lldb-commits] [lldb] Use the root directory as the SDK root on POSIX platforms (PR #146963)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 3 14:16:18 PDT 2025
https://github.com/adrian-prantl created https://github.com/llvm/llvm-project/pull/146963
LLDB has the concept of an "SDK root", which expresses where the system libraries and so which are necessary for debugging can be found. On POSIX platforms, the SDK root is just the root of the file system, or /.
We need to implement the appropriate method on HostInfoPosix to prevent the use of the default implementation for which just returns an error.
This change is needed to support the Swift REPL but may be useful for other use cases as well.
>From e5af56cf3166f79fe8603164551e4c32b615703e Mon Sep 17 00:00:00 2001
From: CodingCarpincho <CodingCapybara at apple.com>
Date: Thu, 3 Jul 2025 13:54:46 -0700
Subject: [PATCH] Use the root directory as the SDK root on POSIX platforms
LLDB has the concept of an "SDK root", which expresses where the
system libraries and so which are necessary for debugging can be
found. On POSIX platforms, the SDK root is just the root of the
file system, or /.
We need to implement the appropriate method on HostInfoPosix to
prevent the use of the default implementation for which just returns
an error.
This change is needed to support the Swift REPL but may be useful
for other use cases as well.
---
lldb/include/lldb/Host/posix/HostInfoPosix.h | 1 +
lldb/source/Host/posix/HostInfoPosix.cpp | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/lldb/include/lldb/Host/posix/HostInfoPosix.h b/lldb/include/lldb/Host/posix/HostInfoPosix.h
index 779b67bd66eda..1fef837c54cc8 100644
--- a/lldb/include/lldb/Host/posix/HostInfoPosix.h
+++ b/lldb/include/lldb/Host/posix/HostInfoPosix.h
@@ -39,6 +39,7 @@ class HostInfoPosix : public HostInfoBase {
static llvm::VersionTuple GetOSVersion();
static std::optional<std::string> GetOSBuildString();
+ static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options);
protected:
static bool ComputeSupportExeDirectory(FileSpec &file_spec);
static bool ComputeHeaderDirectory(FileSpec &file_spec);
diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp
index 879dccfd353be..768787e69253a 100644
--- a/lldb/source/Host/posix/HostInfoPosix.cpp
+++ b/lldb/source/Host/posix/HostInfoPosix.cpp
@@ -140,6 +140,12 @@ std::optional<std::string> PosixUserIDResolver::DoGetGroupName(id_t gid) {
return std::nullopt;
}
+/// The SDK is the directory where the system C headers, libraries, can be found.
+/// On POSIX platforms this is simply the root directory.
+llvm::Expected<llvm::StringRef> HostInfoPosix::GetSDKRoot(SDKOptions options) {
+ return "/";
+}
+
static llvm::ManagedStatic<PosixUserIDResolver> g_user_id_resolver;
UserIDResolver &HostInfoPosix::GetUserIDResolver() {
More information about the lldb-commits
mailing list