Skip to contentSkip to conversation

Fix dylib paths for gdb and lldb

PATCH In review Eric L. Hernes 2 participants 2 messages Feb 2 – Feb 25

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix dylib paths for gdb and lldb

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.

---
 recipes-devtools/clang/clang_%.bbappend            | 4 ++++
 recipes-devtools/gdb/gdb-cross-canadian_%.bbappend | 8 +++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
recipes-devtools/clang/clang_%.bbappend +4 -0
index e55dff6..9aa2c83 100644
@@ -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"
recipes-devtools/gdb/gdb-cross-canadian_%.bbappend +7 -1
index 3f69019..8d30ffb 100644
@@ -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"
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw

Hi Eric,

Thanks for the patch!
Merged to main as
https://git.yoctoproject.org/meta-darwin/commit/?id=11f796b19e30c20b7f432b3a11d501e1e66f4956

Quoted 85 lines · Eric L. Hernes via lists.yoctoproject.org

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.

---
 recipes-devtools/clang/clang_%.bbappend            | 4 ++++
 recipes-devtools/gdb/gdb-cross-canadian_%.bbappend | 8 +++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
recipes-devtools/clang/clang_%.bbappend +2 -0
index e55dff6..9aa2c83 100644
@@ -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

recipes-devtools/clang/clang_%.bbappend +2 -0
+}
+
 INSANE_SKIP:${PN}:class-nativesdk:darwin21 += " file-rdeps"
recipes-devtools/gdb/gdb-cross-canadian_%.bbappend +2 -1
index 3f69019..8d30ffb 100644
@@ -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

recipes-devtools/gdb/gdb-cross-canadian_%.bbappend +5 -1
+}
+
+DEPENDS:append:darwinsdk = " nativesdk-zlib "
+
+INSANE_SKIP:append:darwinsdk = " buildpaths"
--

2.50.1 (Apple Git-155)

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#3168):
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_yocto-2Dpatches_message_3168&d=DwIFAg&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=DnnaXiF2bjQKM8-IDWXut7OR6YYymC-9FFg1oCZNLUcdV64-OGGRKx_9gy78azAW&s=TLgX480aR6uD74bbLAUYHubl1Gonl_cEleuc6hdcpWs&e=
Mute This Topic:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_mt_117598468_7048771&d=DwIFAg&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=DnnaXiF2bjQKM8-IDWXut7OR6YYymC-9FFg1oCZNLUcdV64-OGGRKx_9gy78azAW&s=DzvuKyl9Gzy0y3mKfDYl2vuXLIjSF7z7Uwl5TJFa9cc&e=
Group Owner: [email protected] Unsubscribe:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_yocto-2Dpatches_leave_13184993_7048771_1814342232_xyzzy&d=DwIFAg&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=DnnaXiF2bjQKM8-IDWXut7OR6YYymC-9FFg1oCZNLUcdV64-OGGRKx_9gy78azAW&s=Uq4tnTshRts6qa5baONv8242u3SWFU2ydn5U_gRKMto&e=
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-