[Lldb-commits] [lldb] [llvm] [LLDB] Make PythonRuntimeLoader a posix platform library (PR #228598)

via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 2 14:47:28 PDT 2026


https://github.com/aokblast updated https://github.com/llvm/llvm-project/pull/228598

>From 18f9257b80068ab28c131265163b4fd88081cec3 Mon Sep 17 00:00:00 2001
From: ShengYi Hung <aokblast at FreeBSD.org>
Date: Sat, 3 Oct 2026 05:42:55 +0800
Subject: [PATCH 1/2] [LLDB] Make PythonRuntimeLoader a posix platform library

The symbol ForEachPythonRuntimeCandidate is required when python is
enabled on LLDB. However, it is only provided by Linux platform now.
Make such soure code be compiled under all Posix platform other than
Darwin or it causes link error.
---
 lldb/source/Host/CMakeLists.txt                      | 12 +++++++-----
 .../PythonRuntimeLoaderPosix.cpp}                    |  7 ++++---
 2 files changed, 11 insertions(+), 8 deletions(-)
 rename lldb/source/Host/{linux/PythonRuntimeLoaderLinux.cpp => posix/PythonRuntimeLoaderPosix.cpp} (78%)

diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index 916012a217b74..ce7d8e703d8da 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -119,6 +119,13 @@ else()
       )
   endif()
 
+  # Darwin has its own framework-aware implementation.
+  if (LLDB_ENABLE_PYTHON AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
+    add_host_subdirectory(posix
+      posix/PythonRuntimeLoaderPosix.cpp
+      )
+  endif()
+
   if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
     add_subdirectory(macosx/objcxx)
     set(LLDBObjCLibs lldbHostMacOSXObjCXX)
@@ -152,11 +159,6 @@ else()
       linux/LibcGlue.cpp
       linux/Support.cpp
       )
-    if (LLDB_ENABLE_PYTHON)
-      add_host_subdirectory(linux
-        linux/PythonRuntimeLoaderLinux.cpp
-        )
-    endif()
     if (CMAKE_SYSTEM_NAME MATCHES "Android")
       add_host_subdirectory(android
         android/HostInfoAndroid.cpp
diff --git a/lldb/source/Host/linux/PythonRuntimeLoaderLinux.cpp b/lldb/source/Host/posix/PythonRuntimeLoaderPosix.cpp
similarity index 78%
rename from lldb/source/Host/linux/PythonRuntimeLoaderLinux.cpp
rename to lldb/source/Host/posix/PythonRuntimeLoaderPosix.cpp
index efc92f59e2323..e1f927629a206 100644
--- a/lldb/source/Host/linux/PythonRuntimeLoaderLinux.cpp
+++ b/lldb/source/Host/posix/PythonRuntimeLoaderPosix.cpp
@@ -18,9 +18,10 @@ namespace lldb_private {
 void ForEachPythonRuntimeCandidate(
     llvm::function_ref<bool(const char *)> callback) {
   // Bare names rely on the dynamic linker's search (LD_LIBRARY_PATH,
-  // ldconfig cache, default paths). libpython3.so usually requires a -dev
-  // package; the versioned SONAMEs cover stripped runtime installs. The
-  // 3.8 floor matches Python's Stable ABI baseline.
+  // ldconfig cache/hints, default paths). libpython3.so usually comes with a
+  // development package; the versioned SONAMEs cover runtime-only installs.
+  // The 3.8 floor matches Python's Stable ABI baseline. Darwin has its own
+  // framework-aware implementation; this covers every other POSIX host.
   static constexpr const char *kCandidates[] = {
       "libpython3.so",        "libpython3.13.so.1.0", "libpython3.12.so.1.0",
       "libpython3.11.so.1.0", "libpython3.10.so.1.0", "libpython3.9.so.1.0",

>From 5d43c817b43d79cbb58143f3117dc09e55a034b5 Mon Sep 17 00:00:00 2001
From: ShengYi Hung <aokblast at FreeBSD.org>
Date: Sat, 3 Oct 2026 05:47:10 +0800
Subject: [PATCH 2/2] fixup! [LLDB] Make PythonRuntimeLoader a posix platform
 library

---
 llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn
index 3a98699eba12a..60021b71bfd4c 100644
--- a/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn
@@ -103,6 +103,11 @@ static_library("Host") {
     if (current_os != "emscripten") {
       sources += [ "posix/ProcessLauncherPosixFork.cpp" ]
     }
+
+    # Darwin has its own framework-aware implementation.
+    if (current_os != "mac") {
+      sources += [ "posix/PythonRuntimeLoaderPosix.cpp" ]
+    }
   }
 
   if (current_os == "aix") {
@@ -141,7 +146,6 @@ static_library("Host") {
       "linux/Host.cpp",
       "linux/HostInfoLinux.cpp",
       "linux/LibcGlue.cpp",
-      "linux/PythonRuntimeLoaderLinux.cpp",
       "linux/Support.cpp",
     ]
   }



More information about the lldb-commits mailing list