diff mbox series

[meta-darwin,2/3] lldb: fix install_name_tool for liblldb, libclang-cpp and libLLVM

Message ID 20261203133818.967228-2-ecordonnier@snap.com
State New
Headers show
Series [meta-darwin,1/3] lldb: build nativesdk-lldb with clang for the macOS SDK | expand

Commit Message

Etienne Cordonnier Dec. 3, 2026, 1:38 p.m. UTC
From: Etienne Cordonnier <ecordonnier@snap.com>

The binaries reference @rpath/liblldb.<PV>.dylib, so the previous
'-change liblldb.<PV>.dylib ...' matched nothing and silently did
nothing. The only rpath left is the absolute install prefix, so lldb
failed on a relocated NDK with 'Library not loaded: @rpath/liblldb...'.

Match the real install name and cover lldb, lldb-argdumper, lldb-dap,
lldb-instr and lldb-mcp.

lldb also links libclang-cpp.dylib and libLLVM.dylib via @rpath and
failed the same way, so rewrite them to @loader_path/../lib/ too.
liblldb.<PV>.dylib has the same @rpath references to libclang-cpp and
libLLVM with only the absolute rpath, so rewrite those to
@loader_path/. -change is a no-op for a binary that does not
reference the library.

Tested: macOS NDK nativesdk-lldb build; the packaged binaries now
reference @loader_path/../lib/liblldb.22.1.8.dylib.

AI-Generated: Claude Sonnet 5.5

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
 recipes-devtools/clang/lldb_%.bbappend | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/recipes-devtools/clang/lldb_%.bbappend b/recipes-devtools/clang/lldb_%.bbappend
index 7fe8cb3..969ce17 100644
--- a/recipes-devtools/clang/lldb_%.bbappend
+++ b/recipes-devtools/clang/lldb_%.bbappend
@@ -44,7 +44,15 @@  EXTRA_OECMAKE:append:class-nativesdk:darwin21 = " \
 "
 
 do_compile:append:class-nativesdk:darwin21() {
-    ${SDK_PREFIX}install_name_tool -change liblldb.${PV}.dylib @loader_path/../lib/liblldb.${PV}.dylib ${B}/bin/lldb-dap
+    for tool in lldb lldb-argdumper lldb-dap lldb-instr lldb-mcp; do
+        ${SDK_PREFIX}install_name_tool -change @rpath/liblldb.${PV}.dylib @loader_path/../lib/liblldb.${PV}.dylib ${B}/bin/$tool
+        ${SDK_PREFIX}install_name_tool -change @rpath/libclang-cpp.dylib @loader_path/../lib/libclang-cpp.dylib ${B}/bin/$tool
+        ${SDK_PREFIX}install_name_tool -change @rpath/libLLVM.dylib @loader_path/../lib/libLLVM.dylib ${B}/bin/$tool
+    done
+    ${SDK_PREFIX}install_name_tool \
+        -change @rpath/libclang-cpp.dylib @loader_path/libclang-cpp.dylib \
+        -change @rpath/libLLVM.dylib @loader_path/libLLVM.dylib \
+        ${B}/lib/liblldb.${PV}.dylib
 }
 
 # lldb-dap's rewritten @loader_path reference to liblldb.dylib trips the