[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:53 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: aokblast
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/228598.diff
3 Files Affected:
- (modified) lldb/source/Host/CMakeLists.txt (+7-5)
- (renamed) lldb/source/Host/posix/PythonRuntimeLoaderPosix.cpp (+4-3)
- (modified) llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn (+5-1)
``````````diff
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",
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",
]
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/228598
More information about the lldb-commits
mailing list