Skip to content

Set rpath when a lib has invalid ones#672

Open
oraluben wants to merge 5 commits intopypa:mainfrom
oraluben:set-rpath-for-grafted-lib-with-nonexist-rpath
Open

Set rpath when a lib has invalid ones#672
oraluben wants to merge 5 commits intopypa:mainfrom
oraluben:set-rpath-for-grafted-lib-with-nonexist-rpath

Conversation

@oraluben
Copy link
Copy Markdown
Contributor

@oraluben oraluben commented Jan 15, 2026

Closes #671

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.24%. Comparing base (5ef7bd5) to head (ea44641).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #672   +/-   ##
=======================================
  Coverage   95.24%   95.24%           
=======================================
  Files          22       22           
  Lines        1829     1829           
  Branches      343      343           
=======================================
  Hits         1742     1742           
  Misses         48       48           
  Partials       39       39           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

oraluben and others added 2 commits January 15, 2026 15:03
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: oraluben <[email protected]>
@mayeut
Copy link
Copy Markdown
Member

mayeut commented Apr 18, 2026

Thanks for the PR and sorry for the delay, maintainer time is scarce.
Per #643 (comment), there might be another route to follow, the gist of the pseudo-code would be:

if has_other_grafted_deps(dest_path):
    patcher.set_rpath(dest_path, "$ORIGIN")
else:
    patcher.clear_rpath(dest_path)

cc @lkollar for further insight/comments on this proposal.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes auditwheel repair behavior so that shared libraries with invalid/non-existent RUNPATH/RPATH entries still get their RPATH rewritten to $ORIGIN, preventing dependency resolution failures like the one described in issue #671.

Changes:

  • Add a keep_non_exist option to parse_ld_paths so callers can retain non-existent directories when desired.
  • Update elf_read_rpaths() to preserve non-existent RUNPATH/RPATH entries (so copylib() can detect “has rpath/runpath” even when invalid).
  • Add a unit test asserting copylib() sets $ORIGIN when the library reports a non-existent RUNPATH.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/unit/test_repair.py Adds a regression test for copylib() ensuring $ORIGIN is set even if RUNPATH points to a non-existent directory.
src/auditwheel/lddtree.py Extends parse_ld_paths() with keep_non_exist to optionally keep invalid paths.
src/auditwheel/elfutils.py Uses keep_non_exist=True when reading DT_RPATH/DT_RUNPATH so invalid entries are retained.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/auditwheel/lddtree.py
path
The object actively being parsed (used for $ORIGIN)
keep_non_exist
Do not eliminate non-exist rpath from result
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new keep_non_exist docstring text has a grammar issue (“non-exist rpath”). Consider rephrasing to “non-existent rpaths” (and it applies to RUNPATH too).

Suggested change
Do not eliminate non-exist rpath from result
Do not eliminate non-existent rpaths from the result

Copilot uses AI. Check for mistakes.
Comment on lines 119 to +132
if t.entry.d_tag == "DT_RPATH":
result["rpaths"] = parse_ld_paths(t.rpath, root="/", path=str(fn))
result["rpaths"] = parse_ld_paths(
t.rpath,
root="/",
path=str(fn),
keep_non_exist=True,
)
elif t.entry.d_tag == "DT_RUNPATH":
result["runpaths"] = parse_ld_paths(t.runpath, root="/", path=str(fn))
result["runpaths"] = parse_ld_paths(
t.runpath,
root="/",
path=str(fn),
keep_non_exist=True,
)
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new behavior (preserving non-existent RPATH/RUNPATH entries by passing keep_non_exist=True) is not currently covered by unit tests. Please add a test that exercises elf_read_rpaths when .dynamic contains DT_RPATH/DT_RUNPATH tags and asserts parse_ld_paths is called with keep_non_exist=True (or that non-existent paths are retained).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should set rpath to $ORIGIN for libs with non-exist rpath

4 participants