← Back to issue list

elf: only set rpaths to libs of the same arch

View original Github issue

Metadata

Project
snapcraft
Number
#1988
Type
pull request
State
merged
Author
kyrofa
Labels
—
Created
Updated
Closed

Current evaluation

Merged as commit 17f1f8c2f: elf dependency resolution now matches architecture (in addition to soname), so rpaths only point to libs of the same arch. Fixes LP #1752964 (i386 libc picked over amd64).

Resolution: closed resolved

Reason: PR #1988 was approved and merged into master as commit 17f1f8c2f ("elf: only set rpaths to libs of the same arch"), the only commit in elf.py matching that title; the arch_tuple based on EI_CLASS/EI_DATA/e_machine is still present in snapcraft/elf/_elf_file.py today. The work also rebase-landed on #1959 (64f78f762).

Evaluated by: mr-cal-bot

No scores available.

Issue body

- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)? - [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)? - [x] Have you successfully run `./runtests.sh static`? - [x] Have you successfully run `./runtests.sh unit`? ----- This PR is a spike RFC. Tests will fail. This has been tested, and works, but performance will take a hit. I'll be working on the tests (and rebasing onto #1959) tomorrow, but want to get it up tonight so you guys can verify the approach. Currently Snapcraft looks for libs by soname, and gets tripped up if it finds multiple sonames that match (i.e. it takes the first one). This happens in the case of libc coming from the core snap, which includes both amd64's and i386's libc, and it takes i386's libc by default. This PR fixes LP: [#1752964](https://bugs.launchpad.net/snapcraft/+bug/1752964) by matching architecture in addition to soname.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged as commit 17f1f8c2f: elf dependency resolution now matches architecture (in addition to soname), so rpaths only point to libs of the same arch. Fixes LP #1752964 (i386 libc picked over amd64).
stealth/space-bunny-alpha — closed resolved Merged in canonical/snapcraft#1988 as commit 17f1f8c2f, restricting ELF rpath selection to libraries matching the target architecture and fixing LP #1752964.
qwen/qwen3.6-35b-a3b — — Merged after reviewer approval. Fixes LP #1752964 by restricting ELF rpath resolution to libraries matching the target architecture alongside soname, preventing incorrect selection when multiple architectures exist in the core snap.
qwen3.6-35b-a3b-mtp-q6 — — Merged. Fixes LP #1752964 by restricting ELF rpath resolution to libraries matching the target architecture, preventing incorrect cross-architecture selections like i386 over amd64.

Update history

No update history recorded yet.

Related work

  • Related To: snapcraft#1959 (confidence 85%)

    Rebase base referenced in the PR body; merged as 64f78f762 and likewise added arch detection to dependency matching.

  • Related To: snapcraft#1989 (confidence 60%)

    Follow-up commit 393ba2c63 'elf: don't parse elf more than necessary' landed alongside #1988.

  • Duplicate Of: snapcraft#1959 (confidence 45%)

    Overlapping arch-detection work in ELF dependency resolution; later commit d65c8de2e ('elf: read ELF type when extracting attributes') refined this.

Related issues

Issue Project State Summary Similarity
#1781 many: set rpath for elf files for classic snapcraft merged Merged as commit 3eafb9dd6, adding patchelf-based $ORIGIN-relative rpaths for ELF files in classic snaps and avoiding LD_LIBRARY_PATH side effects.
71%