Skip to content
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

depend: fix library path resolution in POSIX non-ldconfig branches #8422

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

rokm
Copy link
Member

@rokm rokm commented Apr 20, 2024

When resolving library path on POSIX systems and we do not have ldconfig cache available (e.g., Alpine linux), use _resolve_library_path_in_search_paths instead of _which_library, because the former expects the name to have (versioned) .so suffix (which is usually the case), and the latter expects the name to not have suffix. For backwards compatibility reasons, keep using _which_library in case we are given a name without suffix.

See pyinstaller/pyinstaller-hooks-contrib#724 (comment).

While we're at it, remove the replacement of resolved library's filename with its soname; because either it is the same and it is a no-op (most of the cases), or it will end up pointing to incorrect name (i.e., the other binary is referring to the library via the name we were given, so it expects to find the library under that name) which may not even exist (e.g., if the library was renamed to its current name, that differs from its soname, for whatever reason).

The `resolve_library_path` helper in `PyInstaller.depend.bindepend`
expects to be given a full library name; on POSIX systems, this
includes `lib` prefix and `.so` suffix - typically versioned,
as it appears in the soname.

This means that in `_resolve_library_path_unix` codepaths that do
not use `ldconfig` cache but rather search for the library in
given search locations, we should not be using `_which_library`
helper (which expects basename without suffix), but rather
`_resolve_library_path_in_search_paths` helper (which expects
full library name).

However, because it was previously possible to pass a basename
without suffix and because some hooks in contrib hooks repository
rely on this behavior, implement support for both; if the given
name has .so suffix, use  `_resolve_library_path_in_search_paths`
to find exact match, and if name has no suffix, use `_which_library`
to find matching basename instead.
In `_resolve_library_path_unix` helper, remove the part at the
end where we read the soname of the resolved library and replace
the name in returned path with the soname.

In most cases, this was effectively no-op, because we use this
function to resolve dependencies of binaries that we analyze,
and those refer to those dependencies via their sonames.

However, in the unlikely case that we are trying to resolve a
library with soname that differs from its true (file)name, we
would need to collect it under that true (file)name; first, because
whoever was referring to it expects to find it under the true
(file)name, and second, becase in such case, the file with
corresponding soname might not actually exist at all.
@rokm rokm merged commit ba3ccc6 into pyinstaller:develop Apr 22, 2024
18 checks passed
@rokm rokm deleted the bindepend-so-suffix-search branch April 22, 2024 21:13
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.

None yet

2 participants