https://github.com/rchamala created 
https://github.com/llvm/llvm-project/pull/181494

## Summary
Move the definition of `ScriptInterpreter::MakeSBModuleSpec` from 
`ScriptInterpreter.cpp` to `ScriptedPythonInterface.cpp`.

`MakeSBModuleSpec` constructs an `SBModuleSpec`, whose symbols live in the API 
library (`liblldb`). `ScriptInterpreter.cpp` is part of `lldbInterpreter`, 
which is also linked into `lldb-server` — and `lldb-server` does not link the 
API library. On Windows, this causes `LNK2019: unresolved external symbol` for 
`SBModuleSpec`'s constructor and destructor.

`ScriptedPythonInterface.cpp` is part of the Python plugin library, which only 
links into `liblldb` where the API symbols are available. The method retains 
friend access to `SBModuleSpec` since it is still a member of 
`ScriptInterpreter` regardless of which `.cpp` file defines it.

Fixes Windows linker failure from #181334.

## Test plan
- [ ] lldb-x86_64-win `lldb-server.exe` links successfully
- [ ] lldb-aarch64-windows `lldb-server.exe` links successfully
- [ ] Existing ScriptedSymbolLocator tests pass

>From 45e7cb7b155a17aa34e4a3773cceb184ad299b19 Mon Sep 17 00:00:00 2001
From: Rahul Reddy Chamala <[email protected]>
Date: Sat, 14 Feb 2026 10:03:44 -0800
Subject: [PATCH] [lldb] Fix Windows linker error for MakeSBModuleSpec in
 lldb-server

Move the definition of ScriptInterpreter::MakeSBModuleSpec from
ScriptInterpreter.cpp to ScriptedPythonInterface.cpp. The function
constructs an SBModuleSpec (API layer), but ScriptInterpreter.cpp is
part of lldbInterpreter which is linked into lldb-server. On Windows,
lldb-server does not link the API library, causing unresolved symbols
for SBModuleSpec's constructor and destructor.

ScriptedPythonInterface.cpp is part of the Python plugin library which
only links into liblldb, where the API symbols are available. The
method retains friend access to SBModuleSpec since it is still a member
of ScriptInterpreter regardless of which .cpp file defines it.
---
 lldb/source/Interpreter/ScriptInterpreter.cpp          |  6 ------
 .../Python/Interfaces/ScriptedPythonInterface.cpp      | 10 ++++++++++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp 
b/lldb/source/Interpreter/ScriptInterpreter.cpp
index 9e2cad22ad6e6..35fc59c904955 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -191,12 +191,6 @@ lldb::ModuleSP 
ScriptInterpreter::GetOpaqueTypeFromSBModule(
   return module.m_opaque_sp;
 }
 
-std::unique_ptr<lldb::SBModuleSpec>
-ScriptInterpreter::MakeSBModuleSpec(const ModuleSpec &module_spec) const {
-  return std::unique_ptr<lldb::SBModuleSpec>(
-      new lldb::SBModuleSpec(module_spec));
-}
-
 lldb::ScriptLanguage
 ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
   if (language.equals_insensitive(LanguageToString(eScriptLanguageNone)))
diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
index 92438cf51928d..f147b50d20c9b 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
@@ -378,4 +378,14 @@ 
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::ModuleSP>(
   return {};
 }
 
+// MakeSBModuleSpec is defined here rather than in ScriptInterpreter.cpp
+// because it constructs an SBModuleSpec, whose symbols live in liblldb.
+// ScriptInterpreter.cpp is part of lldbInterpreter which is also linked
+// into lldb-server, which does not link the API library.
+std::unique_ptr<lldb::SBModuleSpec>
+ScriptInterpreter::MakeSBModuleSpec(const ModuleSpec &module_spec) const {
+  return std::unique_ptr<lldb::SBModuleSpec>(
+      new lldb::SBModuleSpec(module_spec));
+}
+
 #endif

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

Reply via email to