Skip to content

Commit

Permalink
auto-patchelf: don't resolve symlinks if basenames don't match
Browse files Browse the repository at this point in the history
The auto-patchelf python script assembles a list of
library (so=shared object) file names and their paths.
This helps speed up the discovery of
library files later when patching elf files.
As further optimization, if a symlink points to a library file,
the script uses the resolved path and file name.
However, this produces a broken list entry if the
symlink's target name doesn't match the symlink's name.

A symptom of the bug, affecting the `tsm-client` package,
is fixed in #172372 .

The commit at hand stops resolving symlinks if
the target name differs from the symlink's name.
The commit has been authored by
layus (Guillaume Maudoux <layus.on@gmail.com>)
in pull request comment

#172372 (comment)
  • Loading branch information
Yarny0 committed Jan 15, 2023
1 parent befc839 commit 818d0f8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkgs/build-support/setup-hooks/auto-patchelf.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@ def populate_cache(initial: List[Path], recursive: bool =False) -> None:
if not path.is_file():
continue

# As an optimisation, resolve the symlinks here, as the target is unique
# XXX: (layus, 2022-07-25) is this really an optimisation in all cases ?
# It could make the rpath bigger or break the fragile precedence of $out.
resolved = path.resolve()
# Do not use resolved paths when names do not match
if resolved.name != path.name:
resolved = path

try:
with open_elf(path) as elf:
osabi = get_osabi(elf)
Expand Down

0 comments on commit 818d0f8

Please sign in to comment.