From 4cf19c226e9a55d1a3b5b9d81d20164247923aaf Mon Sep 17 00:00:00 2001 From: CodingCarpincho 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. (cherry picked from commit 0b98b27930dad5ff59de050605c3f101330a2b5c) --- lldb/include/lldb/Host/posix/HostInfoPosix.h | 4 +++- lldb/source/Host/posix/HostInfoPosix.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/Host/posix/HostInfoPosix.h b/lldb/include/lldb/Host/posix/HostInfoPosix.h index 767f353f15150..bf80786dcade3 100644 --- a/lldb/include/lldb/Host/posix/HostInfoPosix.h +++ b/lldb/include/lldb/Host/posix/HostInfoPosix.h @@ -43,7 +43,9 @@ class HostInfoPosix : public HostInfoBase { static bool ComputeSwiftResourceDirectory(FileSpec &lldb_shlib_spec, FileSpec &file_spec, bool verify); #endif - + + static llvm::Expected 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 390bda7dc4010..b8606e85bbdb1 100644 --- a/lldb/source/Host/posix/HostInfoPosix.cpp +++ b/lldb/source/Host/posix/HostInfoPosix.cpp @@ -117,6 +117,12 @@ std::optional 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 HostInfoPosix::GetSDKRoot(SDKOptions options) { + return "/"; +} + static llvm::ManagedStatic g_user_id_resolver; UserIDResolver &HostInfoPosix::GetUserIDResolver() {