Skip to content

Conversation

@Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented May 18, 2025

When trying to run the LLDB API tests on Windows with a debug configuration, they fail, because the _lldb module won't be found. As explained in #51272, this is because lit will run the test with python.exe but the module is built for the debug version of python, python_d.exe.

CMake already resolved the debug executable in Python3_EXECUTABLE_DEBUG, so this PR changes the config.python_executable to point to python_d.exe on Windows in debug mode.

The check is equivalent to the one done in the top-level LLDB CMakeLists when setting the python suffix.

@Nerixyz Nerixyz requested a review from JDevlieghere as a code owner May 18, 2025 08:10
@llvmbot llvmbot added the lldb label May 18, 2025
@llvmbot
Copy link
Member

llvmbot commented May 18, 2025

@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)

Changes

When trying to run the LLDB API tests on Windows with a debug configuration, they fail, because the _lldb module won't be found. As explained in #51272, this is because lit will run the test with python.exe but the module is built for the debug version of python, python_d.exe.

CMake already resolved the debug executable in Python3_EXECUTABLE_DEBUG, so this PR changes the config.python_executable to point to python_d.exe on Windows in debug mode.

The check is equivalent to the one done in the top-level LLDB CMakeLists when setting the python suffix.


Full diff: https://github.com/llvm/llvm-project/pull/140443.diff

2 Files Affected:

  • (modified) lldb/test/API/CMakeLists.txt (+6)
  • (modified) lldb/test/API/lit.site.cfg.py.in (+1-1)
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index da51f2252d023..b1ace6296f46a 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -139,6 +139,12 @@ if(CMAKE_HOST_APPLE)
   endif()
 endif()
 
+if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL Debug)
+  set(LLDB_PYTHON_API_TEST_EXECUTABLE "${Python3_EXECUTABLE_DEBUG}")
+else()
+  set(LLDB_PYTHON_API_TEST_EXECUTABLE "${Python3_EXECUTABLE}")
+endif()
+
 set(dotest_args_replacement ${LLVM_BUILD_MODE})
 
 if(LLDB_BUILT_STANDALONE)
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index ecebc44774859..54807de8819d2 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -19,7 +19,7 @@ config.shared_libs = @LLVM_ENABLE_SHARED_LIBS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
-config.python_executable = "@Python3_EXECUTABLE@"
+config.python_executable = "@LLDB_PYTHON_API_TEST_EXECUTABLE@"
 config.lua_executable = "@LUA_EXECUTABLE@"
 config.lldb_lua_cpath = "@LLDB_LUA_CPATH@"
 config.lua_test_entry = "TestLuaAPI.py"

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

@JDevlieghere JDevlieghere merged commit 3bae8e2 into llvm:main May 19, 2025
12 checks passed
@nico
Copy link
Contributor

nico commented May 19, 2025

lldb/test/lit.site.cfg.py.in, lldb/test/Shell/lit.site.cfg.py.in, lldb/test/Unit/lit.site.cfg.py.in also use "@Python3_EXECUTABLE@". Do those need changing too?

@Nerixyz
Copy link
Contributor Author

Nerixyz commented May 20, 2025

Shell and unit tests don't import lldb directly from Python like the API tests (unless I missed some). The shell tests use the built executable which has a dependency on the correct dynamic Python library. And the unit tests link to the CMake target and don't run on Python.
API tests are "unique" in that they use lldb from Python and not the other way around (lldb importing the Python script).

charles-zablit added a commit that referenced this pull request Oct 21, 2025
…164346)

#140443 makes use of the CMake
variable `Python3_EXECUTABLE_DEBUG`, which was introduced in CMake
version 3.30. On systems with an inferior version of cmake, the lit
tests will try to run with an empty `config.python_executable`.

This PR adds a warning and falls back to using `Python3_EXECUTABLE` if
the CMake version is less than `3.30`.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Oct 21, 2025
…or to 3.30 (#164346)

llvm/llvm-project#140443 makes use of the CMake
variable `Python3_EXECUTABLE_DEBUG`, which was introduced in CMake
version 3.30. On systems with an inferior version of cmake, the lit
tests will try to run with an empty `config.python_executable`.

This PR adds a warning and falls back to using `Python3_EXECUTABLE` if
the CMake version is less than `3.30`.
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
…lvm#164346)

llvm#140443 makes use of the CMake
variable `Python3_EXECUTABLE_DEBUG`, which was introduced in CMake
version 3.30. On systems with an inferior version of cmake, the lit
tests will try to run with an empty `config.python_executable`.

This PR adds a warning and falls back to using `Python3_EXECUTABLE` if
the CMake version is less than `3.30`.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
…lvm#164346)

llvm#140443 makes use of the CMake
variable `Python3_EXECUTABLE_DEBUG`, which was introduced in CMake
version 3.30. On systems with an inferior version of cmake, the lit
tests will try to run with an empty `config.python_executable`.

This PR adds a warning and falls back to using `Python3_EXECUTABLE` if
the CMake version is less than `3.30`.
@Nerixyz Nerixyz deleted the fix/windows-lldb-tests branch November 7, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants