maximbaz / rebuild-detector

Detects which Arch Linux packages need to be rebuilt
ISC License
215 stars 11 forks source link

ldd -r for librariers requires rpath. #5

Closed bartoszek closed 4 years ago

bartoszek commented 4 years ago

Problem with -r flag in ldd call relates to reverse dependency not having info from caller to help resolve its consecutive dependencies. Take for example meshlab asciicast There is no need for plugins to have rpath defined as they are linked from meshlab and inherite its rpath

$LD_DEBUG=libs /usr/bin/meshlab
...
   1777689:     calling init: /usr/lib/meshlab/plugins/libfilter_mutualinfo.so
   1777689:
   1777689:     find library=libgomp.so.1 [0]; searching
   1777689:      search path=/usr/lib/meshlab           (RPATH from file meshlab)
   1777689:       trying file=/usr/lib/meshlab/libgomp.so.1
   1777689:      search path=/opt/oce/lib:/opt/paraview/lib             (LD_LIBRARY_PATH)
   1777689:       trying file=/opt/oce/lib/libgomp.so.1
   1777689:       trying file=/opt/paraview/lib/libgomp.so.1
   1777689:      search cache=/etc/ld.so.cache
   1777689:       trying file=/usr/lib/libgomp.so.1
...

Basically calling ldd -r on libs is quite fragile...

bartoszek commented 4 years ago

Perhaps good practice would be to limit ldd -r call to only libraries that the linker has access to

ldconfig -vN
maximbaz commented 4 years ago

I'm not well versed at this yet, can you please explain what this will achieve - we will go through executable files, and if they are present in ldconfig -vN (i.e. more or less if they are in /usr/lib/ we will check them with ldd -r, but otherwise we will check them with plain ldd?

bartoszek commented 4 years ago

It they,re not in ldconfig -vN will ignore them, as ld can't guarantee that shared objects outside of it's scope can be resolved without extra info.

maximbaz commented 4 years ago

But at the same time this only must apply to libraries, somehow? Thinking of your original example on AUR, we do want to run ldd -r on /usr/bin/yay even though this is not in ldconfig -vN...

bartoszek commented 4 years ago

Yep, we'll have to separate binaries and libraries, I'll think of a sample implementation, perhaps reverse ldd search will do...

bartoszek commented 4 years ago

Looking through what's get reported by checkrebuild with ldd -r I've discovered even stranger edge case. asciicast Symbol Versions::save() undefined in /usr/lib/q4wine/libq4wine-core.so located by ld in /usr/bin/q4wine binary :smirk:

maximbaz commented 4 years ago

Just as an idea, what do you think if we cross-reference files with $PATH, and if the file is in $PATH then we execute ldd -r and otherwise plain ldd?