-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
os/linux/elf: avoid using ldd for listing dynamic dependencies #16941
Conversation
b630d4f
to
63bb563
Compare
990b4a3
to
b692204
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Just as a couple questions:
- Have you tested this on a few formulae?
- What's the performance difference? Faster/slower and by how much?
a207fe1
to
18d1842
Compare
So far I've spot-tested a few binaries/libraries, like As far as performance, the performance seems to be about the same. Testing with the following: def snippet()= 100.times { Pathname("/home/linuxbrew/.linuxbrew/Cellar/leptonica/1.84.1/lib/libleptonica.so.6").dynamically_linked_libraries }
Benchmark.measure { snippet } Before:
After:
The above "after" result is with no caching mechanism implemented. As mentioned earlier, there is possibly room for caching-related improvements here:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work so far, a few suggested tweaks, feel free to push back on any.
2efd255
to
1b120d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks again @alebcay!
Might need a revert. Homebrew/homebrew-core#169088 On mobile at the moment, so would appreciate if someone else got to it. |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Current approach is to query
ldd
and capture its output (which includes resolved paths to shared libraries), then filters based on the needed libraries determined through checking the dynamic section.New approach is to search for each needed library listed in the dynamic section, trying to locate it via runpath/rpath and the system
ld.so.conf
paths.With the new approach, we avoid passing (potentially untrusted) files to
ldd
. Instead, we analyze the ELF file statically (inspect the dynamic section) and only try to perform lookups for the shared libraries indicated in the dynamic section.This change is intended to modify how the dynamic dependencies lookup happens, but should not alter any internal or public-facing API (only private methods/classes changed) - for instance, the output semantics, format, and type of
Pathname("/some/path/to/an/executable").dynamically_linked_libraries
should remain unchanged.