[lldb][windows] add support for out of PATH python.dll resolution by charles-zablit · Pull Request #162509 · llvm/llvm-project (original) (raw)

@llvm/pr-subscribers-lldb

Author: Charles Zablit (charles-zablit)

Changes

This patch adds the LLDB_PYTHON_DLL_RELATIVE_PATH Cmake variable which is the relative path to the directory containing python.dll. The path is relative to the directory containing lldb.exe.

If this variable is set and the resolved path points to an existing directory, we call SetDllDirectoryW to add python.dll to the list of DLL search paths.

This, combined with liblldb.dll being delay loaded, allows to package python.dll with the llvm installer.


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

3 Files Affected:

diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 28bf8d816d89a..4d2036e68704f 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -167,6 +167,12 @@ function(add_lldb_executable name) )

target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})

+if(DEFINED LLDB_PYTHON_DLL_RELATIVE_PATH)

+#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" #include "llvm/Support/InitLLVM.h" #include "llvm/Support/Path.h" #include "llvm/Support/Signals.h" +#include "llvm/Support/Windows/WindowsSupport.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h"

@@ -426,6 +430,47 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) { return error; }

+#ifdef _WIN32 +// Returns the full path to the lldb.exe executable +inline std::wstring GetPathToExecutableW() {

+} +#endif + std::string EscapeString(std::string arg) { std:🧵:size_type pos = 0; while ((pos = arg.find_first_of(""\", pos)) != std:🧵:npos) { @@ -728,6 +773,10 @@ int main(int argc, char const *argv[]) { "~/Library/Logs/DiagnosticReports/.\n"); #endif

+#ifdef _WIN32