[lldb] Support dynamically loading ScriptInterpreter plugins (#189718)
Add support for building the script interpreter plugins as shared libraries, controlled by the `LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS` CMake variable. This allows the plugins, rather than `liblldb`, to link against their respective dependencies such as Python and Lua, which has several benefits: 1. It makes it possible to gracefully handle the Python or Lua dependencies not being present, instead of crashing. 2. It enables programmatically deciding which Python or Lua library to load. 3. Combined with (2), this opens up a path towards not statically linking with Python at all, which is required in order to load the LLDB module in a different Python interpreter (at least this is a hard requirement on Darwin due to two-level namespaces and install names). This PR completes #183791
This commit is contained in:
1 parent
3a49e45ac2
commit
c1c557b1a5
8 files changed
+130
-31
No files matched your search
@@ -300,8 +300,13 @@ void ScriptInterpreterPython::Initialize() {
|
||||
setenv("PYTHONMALLOC", "malloc", /*overwrite=*/true);
|
||||
#endif
|
||||
|
||||
// When the plugin is a separate shared library, the SWIG wrapper lives in
|
||||
// the plugin library, so the path helper that redirects lookups back to
|
||||
// liblldb is unnecessary.
|
||||
#if !LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS
|
||||
HostInfo::SetSharedLibraryDirectoryHelper(
|
||||
ScriptInterpreterPython::SharedLibraryDirectoryHelper);
|
||||
#endif
|
||||
PluginManager::RegisterPlugin(
|
||||
GetPluginNameStatic(), GetPluginDescriptionStatic(),
|
||||
lldb::eScriptLanguagePython, ScriptInterpreterPythonImpl::CreateInstance,
|
||||
|
||||
Reference in new issue
Block a user