fix: patch RPATH on staged libs to fix libvirt_iohelper missing libxml2#179
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the snap build to ensure libvirt_iohelper can reliably resolve staged shared-library dependencies at runtime (without relying on LD_LIBRARY_PATH) by embedding an RPATH into staged ELF shared libraries during the prime step.
Changes:
- Add
patchelfas a build dependency for thelibvirtpart. - Add an
override-primestep that usespatchelfto add an arch-aware RPATH pointing at/snap/<name>/current/usr/lib/<multiarch-triplet>for staged shared libraries underusr/lib.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
234cf8f to
d195efd
Compare
gboutry
left a comment
There was a problem hiding this comment.
I wonder if this cannot be solved from updating the build command?
https://documentation.ubuntu.com/snapcraft/stable/how-to/debugging/use-the-classic-linter/
libvirt_iohelper is spawned by virFileWrapperFdNew() with a minimal environment containing only LIBVIRT_LOG_OUTPUTS=1:stderr. The parent libvirtd's LD_LIBRARY_PATH is never propagated to the child, so staged shared libraries (libxml2, libyajl, libicuuc, etc.) in usr/lib/x86_64-linux-gnu/ are not found, causing server suspend to fail: operation failed: .../libvirt_iohelper: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory Fix by adding build-attributes: [enable-patchelf] to the libvirt part. Snapcraft sets RPATH (old DT_RPATH tag, not RUNPATH) with $ORIGIN on libvirt-built ELF files, enabling the dynamic linker to locate staged libraries transitively — without requiring a build-time patchelf script. Fixes: https://bugs.launchpad.net/snap-openstack/+bug/2150555 Assisted-by: Claude:claude-4.6-sonnet Signed-off-by: Hemanth Nakkina <hemanth.nakkina@canonical.com>
d195efd to
67eaa66
Compare
Yes it worked.. pushed the new change |
libvirt_iohelper is spawned by virFileWrapperFdNew() with a minimal environment containing only LIBVIRT_LOG_OUTPUTS=1:stderr. The parent libvirtd's LD_LIBRARY_PATH is never propagated to the child, so staged shared libraries (libxml2, libyajl, libicuuc, etc.) in usr/lib/x86_64-linux-gnu/ are not found, causing server suspend to fail:
operation failed: .../libvirt_iohelper: error while loading shared
libraries: libxml2.so.2: cannot open shared object file: No such
file or directory
Fix by adding build-attributes: [enable-patchelf] to the libvirt part.
Snapcraft sets RPATH (old DT_RPATH tag, not RUNPATH) with $ORIGIN on
libvirt-built ELF files, enabling the dynamic linker to locate staged
libraries transitively — without requiring a build-time patchelf script.
Fixes: https://bugs.launchpad.net/snap-openstack/+bug/2150555
Assisted-by: Claude:claude-4.6-sonnet