https://github.com/Nerixyz updated https://github.com/llvm/llvm-project/pull/200843
>From 051c4c84ac4c6d033c4cdb46272e0d0a7d5accf8 Mon Sep 17 00:00:00 2001 From: Nerixyz <[email protected]> Date: Mon, 1 Jun 2026 16:30:50 +0200 Subject: [PATCH 1/5] [lldb] Fix Windows build with dynamic Python plugin --- lldb/bindings/python/CMakeLists.txt | 3 +++ lldb/include/lldb/Host/FileBase.h | 2 +- lldb/source/Host/common/File.cpp | 1 - .../Plugins/ScriptInterpreter/Python/CMakeLists.txt | 10 ++++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lldb/bindings/python/CMakeLists.txt b/lldb/bindings/python/CMakeLists.txt index 2916d004a389e..d76b4d5f4951e 100644 --- a/lldb/bindings/python/CMakeLists.txt +++ b/lldb/bindings/python/CMakeLists.txt @@ -157,6 +157,9 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar create_relative_symlink(${swig_target} ${LIBLLDB_SYMLINK_DEST} ${lldb_python_target_dir}/native/ ${LIBLLDB_SYMLINK_OUTPUT_FILE}) + if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS) + add_dependencies(${swig_target} lldbPluginScriptInterpreterPython) + endif() if (NOT WIN32) add_dependencies(${swig_target} lldb-python-wrapper) diff --git a/lldb/include/lldb/Host/FileBase.h b/lldb/include/lldb/Host/FileBase.h index 54ca89f3201c6..bc0b2914ded8c 100644 --- a/lldb/include/lldb/Host/FileBase.h +++ b/lldb/include/lldb/Host/FileBase.h @@ -33,7 +33,7 @@ LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); /// or stream functionality but are not backed by any host OS file. class File : public IOObject { public: - static int kInvalidDescriptor; + static constexpr int kInvalidDescriptor = -1; static FILE *kInvalidStream; // NB this enum is used in the lldb platform gdb-remote packet diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index 499df4e542ab2..a863e323c65ff 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -93,7 +93,6 @@ Expected<File::OpenOptions> File::GetOptionsFromMode(llvm::StringRef mode) { "invalid mode, cannot convert to File::OpenOptions"); } -int File::kInvalidDescriptor = -1; FILE *File::kInvalidStream = nullptr; Status File::Read(void *buf, size_t &num_bytes) { diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt index 574dcdf874ada..55d8b6060486c 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt @@ -48,6 +48,8 @@ if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS) # resolved via liblldb's re-exports, so lldb_private libs aren't linked here. add_lldb_library(lldbPluginScriptInterpreterPython SHARED ${python_plugin_sources} + LINK_COMPONENTS + Support LINK_LIBS liblldb ${Python3_LIBRARIES} @@ -78,6 +80,14 @@ if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS) target_link_directories(lldbPluginScriptInterpreterPython PRIVATE ${PYTHON_SABI_LIBRARY_DIRS}) target_link_directories(lldbStaticScriptInterpreterPython PUBLIC ${PYTHON_SABI_LIBRARY_DIRS}) + if(WIN32 AND NOT MINGW) + # Windows doesn't have "lib" as CMAKE_SHARED_LIBRARY_PREFIX. To be + # consistent with Unix, the output is still prefixed with "lib". + set_target_properties(lldbPluginScriptInterpreterPython + PROPERTIES + OUTPUT_NAME liblldbPluginScriptInterpreterPython + ) + endif() else() add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN ${python_plugin_sources} >From 9a689b53f6559510619493bfc593cc10a7efa760 Mon Sep 17 00:00:00 2001 From: Nerixyz <[email protected]> Date: Mon, 1 Jun 2026 17:40:06 +0200 Subject: [PATCH 2/5] Update lldb/include/lldb/Host/FileBase.h Co-authored-by: Charles Zablit <[email protected]> --- lldb/include/lldb/Host/FileBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/include/lldb/Host/FileBase.h b/lldb/include/lldb/Host/FileBase.h index bc0b2914ded8c..45e0a49545ee4 100644 --- a/lldb/include/lldb/Host/FileBase.h +++ b/lldb/include/lldb/Host/FileBase.h @@ -34,7 +34,7 @@ LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); class File : public IOObject { public: static constexpr int kInvalidDescriptor = -1; - static FILE *kInvalidStream; + static constexpr FILE *kInvalidStream = nullptr; // NB this enum is used in the lldb platform gdb-remote packet // vFile:open: and existing values cannot be modified. >From 6125960fe92e6e9cbfded84348f62e071df988a6 Mon Sep 17 00:00:00 2001 From: Nerixyz <[email protected]> Date: Mon, 1 Jun 2026 17:49:28 +0200 Subject: [PATCH 3/5] fix: remove old definition --- lldb/source/Host/common/File.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index a863e323c65ff..5870d2f1457ad 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -93,8 +93,6 @@ Expected<File::OpenOptions> File::GetOptionsFromMode(llvm::StringRef mode) { "invalid mode, cannot convert to File::OpenOptions"); } -FILE *File::kInvalidStream = nullptr; - Status File::Read(void *buf, size_t &num_bytes) { return std::error_code(ENOTSUP, std::system_category()); } >From da6a2429292894834e6f931bcb05a69e6802cd5d Mon Sep 17 00:00:00 2001 From: Nerixyz <[email protected]> Date: Mon, 1 Jun 2026 17:54:09 +0200 Subject: [PATCH 4/5] fix: only link `Support` on Windows --- lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt index 55d8b6060486c..2779658d981cb 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt @@ -41,6 +41,7 @@ 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. set(PYTHON_SABI_LIBRARY_DIRS ${Python3_LIBRARY_DIRS}) + set(shared_python_plugin_link_components Support) endif() if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS) @@ -49,7 +50,7 @@ if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS) add_lldb_library(lldbPluginScriptInterpreterPython SHARED ${python_plugin_sources} LINK_COMPONENTS - Support + ${shared_python_plugin_link_components} LINK_LIBS liblldb ${Python3_LIBRARIES} >From 66cc1468aa488e1b617a5e5a630542aa4fbd4794 Mon Sep 17 00:00:00 2001 From: Nerixyz <[email protected]> Date: Tue, 16 Jun 2026 18:05:02 +0200 Subject: [PATCH 5/5] fix: add back OUTPUT_NAME adjustment --- .../Plugins/ScriptInterpreter/Python/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt index 85962b6268565..abb7c2c6ee4e3 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt @@ -73,6 +73,14 @@ if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS) endif() target_link_directories(lldbPluginScriptInterpreterPython PRIVATE ${PYTHON_SABI_LIBRARY_DIRS}) + if(NOT MINGW) + # Windows doesn't have "lib" as CMAKE_SHARED_LIBRARY_PREFIX. To be + # consistent with Unix, the output is still prefixed with "lib". + set_target_properties(lldbPluginScriptInterpreterPython + PROPERTIES + OUTPUT_NAME liblldbPluginScriptInterpreterPython + ) + endif() endif() if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") @@ -85,8 +93,6 @@ if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS) # shared between the test binary and the plugin code. add_lldb_library(lldbStaticScriptInterpreterPython ${python_plugin_sources} - LINK_COMPONENTS - Support LINK_LIBS lldbBreakpoint lldbCore _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
