https://github.com/Nerixyz created 
https://github.com/llvm/llvm-project/pull/197185

On Windows, when compiling with the limited API in non-debug mode, Python will 
instruct the linker to link `python3.lib` 
[here](https://github.com/python/cpython/blob/f5fb491341e566bbaf17d9bf3e4ec3af4a56bb3f/PC/pyconfig.h#L344-L345).

Currently, we don't directly specify the library in CMake. We specify 
`python3xx.lib`. When the linker encounters the `python3.lib` requirement, it 
errors out, because it doesn't know where that is. With this PR, we add the 
directory of `python3xx.lib`. This is the same one as `python3.lib`. So the 
linker can find the library.

This is more of a temporary fix. As commented in the code, we should use 
`Python3_SABI_LIBRARY_DIRS` once we require CMake 3.26. Furthermore, I'm not 
fully sure why we link to `python3xx.lib` when the limited API is requested 
(presumably because of #167001?).

>From edd857999eef0ac7a5e6181318ec7c54d36d30f2 Mon Sep 17 00:00:00 2001
From: Nerixyz <[email protected]>
Date: Mon, 11 May 2026 22:35:57 +0200
Subject: [PATCH] [lldb][Python] Include limited ABI library directory

---
 .../Plugins/ScriptInterpreter/Python/CMakeLists.txt  | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt 
b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
index 3bf70bf51f1e0..3c3c5a8a966e2 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -69,6 +69,13 @@ if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS)
   )
   target_include_directories(lldbStaticScriptInterpreterPython
     PUBLIC ${Python3_INCLUDE_DIRS})
+
+  if (WIN32)
+    # Add the library directories to allow Python to use #pragma comment(lib, 
"python3.lib").
+    # FIXME: We should use Python3_SABI_LIBRARY_DIRS here, but this requires 
CMake 3.26.
+    target_link_directories(lldbPluginScriptInterpreterPython PRIVATE 
${Python3_LIBRARY_DIRS})
+    target_link_directories(lldbStaticScriptInterpreterPython PUBLIC 
${Python3_LIBRARY_DIRS})
+  endif()
 else()
   add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
     ${python_plugin_sources}
@@ -85,6 +92,11 @@ else()
       ${Python3_LIBRARIES}
       ${LLDB_LIBEDIT_LIBS}
   )
+  if (WIN32)
+    # Add the library directories to allow Python to use #pragma comment(lib, 
"python3.lib").
+    # FIXME: We should use Python3_SABI_LIBRARY_DIRS here, but this requires 
CMake 3.26.
+    target_link_directories(lldbPluginScriptInterpreterPython PUBLIC 
${Python3_LIBRARY_DIRS})
+  endif()
 endif()
 
 target_include_directories(lldbPluginScriptInterpreterPython

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to