-
Notifications
You must be signed in to change notification settings - Fork 163
fix: always set RPATH or clear RUNPATH/RPATH for grafted libraries #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
5842e6b
336398e
60e66b1
b5d6e70
b7e8e79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| from subprocess import check_call | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from auditwheel.elfutils import elf_read_dt_needed, elf_read_rpaths | ||
| from auditwheel.elfutils import elf_read_dt_needed | ||
| from auditwheel.hashfile import hashfile | ||
| from auditwheel.lddtree import LIBPYTHON_RE | ||
| from auditwheel.policy import get_replace_platforms | ||
|
|
@@ -112,14 +112,18 @@ def repair_wheel( | |
| # they may have internal dependencies (DT_NEEDED) on one another, so | ||
| # we need to update those records so each now knows about the new | ||
| # name of the other. | ||
| # we also clear or set RPATH depending on the presence of internal dependencies | ||
| for _, path in soname_map.values(): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there can be a logic issue here if the same library is stored under multiple SONAME entries in soname_map["libfoo.so"] = ("libfoo-abc.so", libfoo-abc.so)
soname_map["libfoo.so.1"] = ("libfoo-abc.so", libfoo-abc.so)The first loop iteration will call One way to solve this would be to perform this in two passes: first record what needs changes and in a second pass, perform the actual changes to RPATH.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any given path can only have a single soname so this can't happen. |
||
| needed = elf_read_dt_needed(path) | ||
| needed = elf_read_dt_needed(path) # TODO perf, we already read those at some point | ||
| replacements = [] | ||
| for n in needed: | ||
| if n in soname_map: | ||
| replacements.append((n, soname_map[n][0])) | ||
| if replacements: | ||
| patcher.set_rpath(path, "$ORIGIN") | ||
| patcher.replace_needed(path, *replacements) | ||
|
mayeut marked this conversation as resolved.
|
||
| else: | ||
| patcher.clear_rpath(path) | ||
|
mayeut marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can it happen that we clear the RPATH for entries which are internal to the wheel? I don't think those will show up in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only applies to external grafted libraries so we can't be modifying for entries which are internal to the wheel. |
||
|
|
||
| if update_tags: | ||
| output_wheel = add_platforms(ctx, abis, get_replace_platforms(abis[0])) | ||
|
|
@@ -156,8 +160,6 @@ def copylib(src_path: Path, dest_dir: Path, patcher: ElfPatcher) -> tuple[str, P | |
|
|
||
| 1) Copy the file from src_path to dest_dir/ | ||
| 2) Rename the shared object from soname to soname.<unique> | ||
| 3) If the library has a RUNPATH/RPATH, clear it and set RPATH to point to | ||
| its new location. | ||
| """ | ||
| # Copy the a shared library from the system (src_path) into the wheel | ||
| # if the library has a RUNPATH/RPATH we clear it and set RPATH to point to | ||
|
|
@@ -175,17 +177,13 @@ def copylib(src_path: Path, dest_dir: Path, patcher: ElfPatcher) -> tuple[str, P | |
| return new_soname, dest_path | ||
|
|
||
| logger.debug("Grafting: %s -> %s", src_path, dest_path) | ||
| rpaths = elf_read_rpaths(src_path) | ||
| shutil.copy2(src_path, dest_path) | ||
| statinfo = dest_path.stat() | ||
| if not statinfo.st_mode & stat.S_IWRITE: | ||
| dest_path.chmod(statinfo.st_mode | stat.S_IWRITE) | ||
|
|
||
| patcher.set_soname(dest_path, new_soname) | ||
|
|
||
| if any(itertools.chain(rpaths["rpaths"], rpaths["runpaths"])): | ||
| patcher.set_rpath(dest_path, "$ORIGIN") | ||
|
|
||
| return new_soname, dest_path | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.