3
0
Fork 0
forked from mirrors/nixpkgs

auto-patchelf: don't resolve symlinks if basenames don't match

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 https://github.com/NixOS/nixpkgs/pull/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

https://github.com/NixOS/nixpkgs/pull/172372#issuecomment-1194687183
This commit is contained in:
Yarny0 2023-01-14 19:07:39 +01:00
parent befc83905c
commit 818d0f8cf1

View file

@ -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)