[Lldb-commits] [lldb] [lldb] Fix adding shared ScriptInterpreter libraries to LLDB.framework (PR #223782)

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 25 12:57:59 PDT 2026


https://github.com/bulbazord updated https://github.com/llvm/llvm-project/pull/223782

>From 2743adaba842d3576f4886783b14449572376d76 Mon Sep 17 00:00:00 2001
From: Alex Langford <alangford at apple.com>
Date: Tue, 15 Sep 2026 11:39:33 -0700
Subject: [PATCH] [lldb] Fix adding shared ScriptInterpreter libraries to
 LLDB.framework

These libraries were already being added to the framework in the build
tree but installation rules were still putting it in `/lib`. I pulled
the Python and Lua logic into a separate function and changed the install
logic when LLDB_BUILD_FRAMEWORK is enabled.
---
 lldb/cmake/caches/Apple-lldb-macOS.cmake      |  1 +
 lldb/cmake/modules/AddLLDB.cmake              | 28 ++++++++++++++++++-
 .../ScriptInterpreter/Lua/CMakeLists.txt      | 11 ++------
 .../ScriptInterpreter/Python/CMakeLists.txt   | 11 ++------
 4 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/lldb/cmake/caches/Apple-lldb-macOS.cmake b/lldb/cmake/caches/Apple-lldb-macOS.cmake
index 027a793e08f07..26cc917be3ebd 100644
--- a/lldb/cmake/caches/Apple-lldb-macOS.cmake
+++ b/lldb/cmake/caches/Apple-lldb-macOS.cmake
@@ -26,4 +26,5 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   lldb-mcp
   darwin-debug
   debugserver
+  lldbPluginScriptInterpreterPython
   CACHE STRING "")
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 6dfcc87dd5be3..ee2ff5ea2d2a7 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -541,7 +541,7 @@ endfunction()
 # sits beside it. A framework build moves liblldb into the bundle, so the plugin
 # must move with it and carry an rpath that reaches liblldb from its new
 # location.
-function(lldb_add_scriptinterpreter_plugin_to_framework name)
+function(lldb_add_scriptinterpreter_plugin_to_buildtree_framework name)
   if(NOT LLDB_BUILD_FRAMEWORK)
     return()
   endif()
@@ -569,6 +569,32 @@ function(lldb_add_scriptinterpreter_plugin_to_framework name)
   add_dependencies(lldb-framework-cleanup ${name}-framework-cleanup)
 endfunction()
 
+function(lldb_add_scriptinterpreter_dynamic_library name wrapper_fn)
+  if (LLDB_BUILD_FRAMEWORK)
+    set(framework_arg INSTALL_PREFIX "${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/")
+  endif()
+
+
+  # ScriptInterpreter shared libraries are loaded at runtime by PluginManager.
+  # Private lldb symbols are resolved via liblldb's re-exports, so we
+  # explicitly cannot link against any lldb_private libraries.
+  # FIXME: Add a mechanism to enforce this. We already have
+  # `ALLOWED_INTERNAL_DEPENDENCIES`, but it is not fine-grained enough to
+  # distinguish between link dependencies and header dependencies.
+  add_lldb_library(${name} SHARED
+    ${framework_arg}
+    ${ARGN}
+  )
+
+  cmake_language(CALL ${wrapper_fn} ${name})
+
+  if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+    lldb_record_dynamic_script_interpreter_exports(${name})
+  endif()
+
+  lldb_add_scriptinterpreter_plugin_to_buildtree_framework(${name})
+endfunction(lldb_add_scriptinterpreter_dynamic_library)
+
 # Add extra install steps for dSYM creation and stripping for the given target.
 function(lldb_add_post_install_steps_darwin name install_prefix)
   if(NOT APPLE)
diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
index 4e56dede27716..6df6d5fa48698 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
@@ -6,20 +6,13 @@ set(lua_plugin_sources
 if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS)
   # Shared library loaded at runtime by PluginManager. Private lldb symbols are
   # resolved via liblldb's re-exports, so lldb_private libs aren't linked here.
-  add_lldb_library(lldbPluginScriptInterpreterLua SHARED
+  lldb_add_scriptinterpreter_dynamic_library(
+    lldbPluginScriptInterpreterLua add_lua_wrapper
     ${lua_plugin_sources}
     LINK_LIBS
       liblldb
       ${LUA_LIBRARIES}
   )
-  add_lua_wrapper(lldbPluginScriptInterpreterLua)
-
-  if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-    lldb_record_dynamic_script_interpreter_exports(
-      lldbPluginScriptInterpreterLua)
-  endif()
-
-  lldb_add_scriptinterpreter_plugin_to_framework(lldbPluginScriptInterpreterLua)
 
   # Static variant linked directly by unit tests. Separate compilation is
   # required so llvm::Error RTTI (ErrorInfoBase::ID) has a single address
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
index 0515570c5c4ca..409211a0511d1 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -51,13 +51,13 @@ if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS)
   # resolved via liblldb's re-exports, so lldb_private libs aren't linked here.
   # Python is dlopen'd at runtime by ScriptInterpreterRuntimeLoader, so the
   # plugin is built with allow-undefined-symbol semantics on POSIX.
-  add_lldb_library(lldbPluginScriptInterpreterPython SHARED
+  lldb_add_scriptinterpreter_dynamic_library(
+    lldbPluginScriptInterpreterPython add_python_wrapper
     ${python_plugin_sources}
     LINK_LIBS
       liblldb
       ${LLDB_LIBEDIT_LIBS}
   )
-  add_python_wrapper(lldbPluginScriptInterpreterPython)
   if (APPLE)
     target_link_options(lldbPluginScriptInterpreterPython PRIVATE
       "LINKER:-undefined,dynamic_lookup")
@@ -75,13 +75,6 @@ if (LLDB_ENABLE_DYNAMIC_SCRIPTINTERPRETERS)
       ${PYTHON_SABI_LIBRARY_DIRS})
   endif()
 
-  if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-    lldb_record_dynamic_script_interpreter_exports(
-      lldbPluginScriptInterpreterPython)
-  endif()
-
-  lldb_add_scriptinterpreter_plugin_to_framework(lldbPluginScriptInterpreterPython)
-
   # Static variant linked directly by unit tests. Separate compilation is
   # required so llvm::Error RTTI (ErrorInfoBase::ID) has a single address
   # shared between the test binary and the plugin code.



More information about the lldb-commits mailing list