https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/168864
This patch improves the detection of `python3x.dll`. `SearchPathW` does not account for `SetDllDirectoryW`. Therefore, when manually adding `python3x.dll` to the search path, `SearchPathW` will still return that it has not been found, resulting in a false negative. This patch ensures that the driver uses the same mechanism as the loader to attempt to load `python3x.dll` using `LoadLibraryW`. >From 5af09ebc07b8b4edfa3fef69c5009e8e78389db0 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Thu, 20 Nov 2025 13:05:07 +0100 Subject: [PATCH] [windows] improve python3.dll load check --- lldb/tools/driver/Driver.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index bebf1a70d50e9..33cce42696372 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -477,18 +477,17 @@ bool AddPythonDLLToSearchPath() { #endif #ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME -/// Returns whether `python3x.dll` is in the DLL search path. +/// Returns true if `python3x.dll` can be loaded. bool IsPythonDLLInPath() { #define WIDEN2(x) L##x #define WIDEN(x) WIDEN2(x) - WCHAR foundPath[MAX_PATH]; - DWORD result = - SearchPathW(nullptr, WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME), nullptr, - MAX_PATH, foundPath, nullptr); + HMODULE h = LoadLibraryW(WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME)); + if (!h) + return false; + FreeLibrary(h); + return true; #undef WIDEN2 #undef WIDEN - - return result > 0; } #endif _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
