fix(snap): make bundled magick find libgomp at runtime#4016
Merged
Conversation
The `magick` part builds ImageMagick from source with `--prefix=/usr`, so
its own libraries are installed to `usr/lib`, and the binary's RPATH (set
by `enable-patchelf`) is `$ORIGIN/../lib`. However, `libgomp1` is pulled in
as a stage-package and installs `libgomp.so.1` into the multiarch directory
`usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/`, which is not on that RPATH.
As a result the bundled binary fails to start whenever yazi invokes it for
Font/HEIC/JPEG-XL previews:
magick: error while loading shared libraries: libgomp.so.1:
cannot open shared object file: No such file or directory
Relocate the bundled libgomp alongside the Magick libraries in `usr/lib`
so the existing `$ORIGIN/../lib` RPATH resolves it. Verified by placing
libgomp on that path next to the shipped binary and running it with no
LD_LIBRARY_PATH set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the snap build, the bundled
magickbinary fails to start, so Font / HEIC / JPEG-XL previews don't work.yazi --debugreports:Reproduced on
latest/stable(rev 908) andlatest/edge(rev 904), amd64. All other previewers (chafa, ffmpeg, poppler, 7-Zip, resvg) work fine.Root cause
The
magickpart builds ImageMagick from source with--prefix=/usr, so its own libraries land inusr/lib/, andenable-patchelfsets the binary'sRPATHto:i.e. it searches
usr/lib(wherelibMagickCore/libMagickWandlive) and the core24 base. Butlibgomp1is pulled in as astage-package, which installslibgomp.so.1into the multiarch dirusr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/— which is on neither RPATH entry. core24 doesn't shiplibgompeither, so at runtime the loader can't resolve it.Fix
organizethe bundledlibgompintousr/lib/, alongside the Magick libraries, so the existing$ORIGIN/../libRPATH resolves it (and update theprimepath to match). No newRPATH/LD_LIBRARY_PATHplumbing needed.I deliberately avoided the
apps.*.environment: LD_LIBRARY_PATHapproach because$CRAFT_ARCH_TRIPLET_BUILD_FORis not expanded inside theenvironmentblock on core22/core24 (canonical/snapcraft#4486), which would ship a literal, broken path.$CRAFT_ARCH_TRIPLET_BUILD_FORis expanded inorganize/prime(already used here).Verification
I couldn't run a full
snapcraft packin my environment (no LXD/Multipass), but I verified the mechanism directly against the shipped snap: reconstruct the prime layout withlibgompplaced inusr/lib/next to the Magick libs, then run the unmodified shippedmagickbinary with noLD_LIBRARY_PATH:A maintainer CI build would be the real confirmation.
I couldn't find an existing issue or PR tracking this.