diff mbox series

[meta-darwin] Fix dylib paths for gdb and lldb

Message ID 20260202155852.76192-2-dev@qinc.tv
State New
Headers show
Series [meta-darwin] Fix dylib paths for gdb and lldb | expand

Commit Message

Eric L. Hernes Feb. 2, 2026, 3:58 p.m. UTC
The installed path to expat and liblldb are wrong.  This results in
the binaries not running on the macOS host. With gdb, we have

$ ./aarch64-oe-linux-gdb
dyld[...]: Library not loaded: libexpat.1.dylib
  Referenced from: <4F097B37-76EC-308F-8022-448023624AD3> /.../aarch64-oe-linux-gdb
  Reason: tried: 'libexpat.1.dylib' (no such file),
  '/System/Volumes/Preboot/Cryptexes/OSlibexpat.1.dylib' (no such
  file), 'libexpat.1.dylib' (no such file), '....'

Running otool shows (some output omitted for clarity):
$ otool -L ./aarch64-oe-linux-gdb
./aarch64-oe-linux-gdb:
	libexpat.1.dylib (compatibility version 12.0.0, current version 12.0.0)
	@loader_path/../../lib/libmpfr.6.dylib (compatibility version 9.0.0, current

One fix would be to patch the configure/build/install scripts to have
the proper path to expat.

The macOS tools give us a simpler option to just run
`install_name_tool` to set it correctly.

lldb-dap has a similar problem with `liblldb`.

Signed-off-by: Eric L. Hernes <dev@qinc.tv>
---
 recipes-devtools/clang/clang_%.bbappend            | 4 ++++
 recipes-devtools/gdb/gdb-cross-canadian_%.bbappend | 8 +++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/recipes-devtools/clang/clang_%.bbappend b/recipes-devtools/clang/clang_%.bbappend
index e55dff6..9aa2c83 100644
--- a/recipes-devtools/clang/clang_%.bbappend
+++ b/recipes-devtools/clang/clang_%.bbappend
@@ -83,4 +83,8 @@  FILES:${PN} += " \
    ${libdir}/LLVMgold.dylib \
 "
 
+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
+}
+
 INSANE_SKIP:${PN}:class-nativesdk:darwin21 += " file-rdeps"
diff --git a/recipes-devtools/gdb/gdb-cross-canadian_%.bbappend b/recipes-devtools/gdb/gdb-cross-canadian_%.bbappend
index 3f69019..8d30ffb 100644
--- a/recipes-devtools/gdb/gdb-cross-canadian_%.bbappend
+++ b/recipes-devtools/gdb/gdb-cross-canadian_%.bbappend
@@ -16,4 +16,10 @@  EXTRA_OECONF:remove:darwinsdk = "--with-system-readline"
 # Remove -rpath-link and -rpath
 LDFLAGS:darwinsdk = "${BUILDSDK_LDFLAGS}"
 
-INSANE_SKIP:append:darwin21 = " buildpaths"
+do_compile:append:darwinsdk() {
+    ${SDK_PREFIX}install_name_tool -change libexpat.1.dylib @loader_path/../../lib/libexpat.1.dylib ${B}/gdb/gdb
+}
+
+DEPENDS:append:darwinsdk = " nativesdk-zlib "
+
+INSANE_SKIP:append:darwinsdk = " buildpaths"