← Back to issue list

elf: add fallback methods to detect library dependencies

View original Github issue

Metadata

Project
snapcraft
Number
#3514
Type
pull request
State
merged
Author
cjp256
Labels
—
Created
Updated
Closed

Current evaluation

Merged in snapcore/snapcraft#3514 (commit 76ca948c4): ELF dependency detection now falls back from ldd to host-libc6 preloading and loader tracing before warning.

Resolution: closed resolved

Reason: The PR was approved and merged into master as commit 76ca948c4 ("elf: add fallback methods to detect library dependencies (#3514)"), visible in the history of snapcraft/internal/elf.py. It adds three ldd fallbacks — plain ldd, ldd with LD_PRELOAD of host libc6, then LD_TRACE_LOADED_OBJECTS loader tracing — before emitting the original warning.

Evaluated by: mr-cal-bot

No scores available.

Issue body

libc6 may mismatch with the paths provided to ldd in LD_LIBRARY_PATH. This may be avoided if invoking the binary directory and using LD_TRACE_LOADED_OBJECTS, but this method is limited to executable files. This updates the library dependency search to try three variants: (1) use ldd as today. if ldd fails.. (2) use ldd with LD_PRELOAD to specify libc6 from host. if ldd fails... (3) use ld trace method. if ldd trace fails... (4) warn as before. For #2, libc6 is expected as /lib/<arch-triplet>/libc.so.6. This likely will need to be more robust in the future. Signed-off-by: Chris Patterson <chris.patterson@canonical.com> - [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [ ] Have you successfully run `./runtests.sh static`? - [ ] Have you successfully run `./runtests.sh tests/unit`? -----

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged in snapcore/snapcraft#3514 (commit 76ca948c4): ELF dependency detection now falls back from ldd to host-libc6 preloading and loader tracing before warning.
stealth/space-bunny-alpha — closed resolved Merged in snapcore/snapcraft#3514 (76ca948c4): ELF dependency detection now falls back from ldd to host-libc preloading and loader tracing before warning.
qwen/qwen3.6-35b-a3b — — Merged changes implementing fallback methods to detect library dependencies when ldd fails due to libc6 mismatches. The three-step detection logic was approved by reviewers and passed CI checks before integration.
qwen3.6-35b-a3b-mtp-q6 — — Merged into master. Adds fallback methods to detect ELF library dependencies when ldd fails due to libc6 or LD_LIBRARY_PATH mismatches. Implements a three-step fallback chain before warning. Approved and merged with full coverage.

Update history

No update history recorded yet.

Related work

  • Related To: snapcore/snapcraft#2909 (confidence 40%)

    Prior commit 'elf: search for host libraries within search paths' in the same file, addressing the same family of ldd/host-glibc dependency resolution problems.

Related issues

Issue Project State Summary Similarity
#3840 elf: add handling and patching helpers snapcraft merged Merged in snapcore/snapcraft#3840 via commit 8a9914510, adding helpers to enumerate ELF binaries and locate architecture-specific dynamic linkers.
77%
#2746 elf: handle missing dependencies not found on system snapcraft merged Merged PR #2746 via ed3f32aa3: ELF scanning now retains unresolved libraries, falls back to sonames, parses ldd output reliably, and tests missing-library cases.
74%
#4751 Use `ld` from the base snap for library linting snapcraft open Triaged enhancement to make snapcraft lint resolve libraries with the target base snap's dynamic linker instead of host ldd, preventing spurious core24/core26 warnings; the TODO remains in current code.
73%
#2929 elf: fixes for corrupt shared objects snapcraft merged Merged PR snapcore/snapcraft#2929 (commit 051f24e07, Feb 2020) catching elftools ConstructErrors as CorruptedElfFileError and skipping corrupt shared objects during library crawling.
73%
#1881 elf: better handling for newer libc6 snapcraft merged Merged in snapcraft#1881 (commit 10ab28277), requiring libc6 to be explicitly declared in snapcraft.yaml so newer libc6 dependencies are recorded correctly.
71%
#75 refactor: rewrite elf file support debcraft merged Merged as c841273, replacing Snapcraft-derived ELF handling with deb-oriented library dependency support. Symbol support was deferred to follow-up work.
71%
#1850 pluginhandler: patch and handle elf files on glibc mismatch snapcraft merged Merged in snapcraft#1850 (bdaf0b7f1), adding host libc6 staging and its dynamic loader when ELF files need newer glibc; fixes #1668 and #1669.
71%
#1669 patchelf with ld-linux from the future snapcraft closed Resolved by commit bdaf0b7f1, which added Snapcraft handling for PatchELF and ELF files when the built glibc/linker does not match the base.
71%
#1935 elf: contemplate more patching scenarios snapcraft merged Merged PR #1935 as 048adc4a3, adding ELF patching for classic snaps built on bionic targeting core16 and for hooks built with Snapcraft.
70%