[Lldb-commits] [lldb] [LLDB] On Windows, fix Python lib path (PR #191565)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 10 16:03:39 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Alexandre Ganea (aganea)
<details>
<summary>Changes</summary>
When `LLDB_ENABLE_PYTHON_LIMITED_API` is ON (which defaults to ON with SWIG >= 4.2 and `LLDB_EMBED_PYTHON_HOME=OFF`), LLDB defines `Py_LIMITED_API`. This causes Python's `pyconfig.h` to emit:
```
#pragma comment(lib, "python3.lib")
```
This is the Windows MSVC auto-link directive for the Python Stable ABI import library. CMake's `FindPython3` correctly found and linked the version-specific `python313.lib` (with full path), but the `#pragma comment(lib)` adds an *additional* implicit link dependency on `python3.lib` using just the bare filename. The linker can't find it because the Python `libs` directory isn't in the default library search path.
This PR adds `target_link_directories` for `Python3_LIBRARY_DIRS` in `lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt`. This ensures the linker can find `python3.lib` (and any other Python libraries) in the Python installation's `libs` directory. The `PUBLIC` visibility propagates this to `liblldb.dll` which is where the actual link failure occurs.
---
Full diff: https://github.com/llvm/llvm-project/pull/191565.diff
1 Files Affected:
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt (+5)
``````````diff
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
index 303e17a938912..0a839adfeba50 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -52,3 +52,8 @@ add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
target_include_directories(lldbPluginScriptInterpreterPython
PUBLIC ${Python3_INCLUDE_DIRS})
+
+if(Python3_LIBRARY_DIRS)
+ target_link_directories(lldbPluginScriptInterpreterPython
+ PUBLIC ${Python3_LIBRARY_DIRS})
+endif()
``````````
</details>
https://github.com/llvm/llvm-project/pull/191565
More information about the lldb-commits
mailing list