matthew-brett / delocate

Find and copy needed dynamic libraries into python wheels
BSD 2-Clause "Simplified" License
262 stars 59 forks source link

[Question] Why is the /DLC link needed? #150

Closed mx-psi closed 2 years ago

mx-psi commented 2 years ago

Hi, this is not a bug nor a feature request, but rather a question. If this is not the correct place to ask questions, please let me know!

My company uses a build system called Omnibus, which has a health check that, on macOS, checks for dependencies of dylibs by using otool, and fails if a library links to a nonexistent one (not sure if 'link' is the right word, it just checks the output of otool -L).

Since a very long time ago (dabce492659d3d579890e7e69817346a3df1ecb6), delocate adds a link to /DLC/<dylib name> to all dylibs. This makes the Omnibus healthcheck fail, which we hit on python-lz4/python-lz4#244.

Now my questions are:

  1. why is delocate adding this link to a nonexistent library? and, relatedly,
  2. who should ultimately fix their thing: should delocate stop adding it, or should Omnibus fix its healthcheck?
matthew-brett commented 2 years ago

macOS distinguishes between the install-name ID - the universal name of the library - and the full or relative path to the library. They are often the same, but need not be. In this case we're just making an ID that isn't a path, but does contain the library name, in order that the install ID is not the same as any other possible (non-delocate) copies of the library in the search path with the same <dylib-name>, and to make sure the directory containing the dylib can be anywhere on the filesystem.

mx-psi commented 2 years ago

Thanks for the fast answer! If I am using otool correctly that checks out with the python-lz4 case:

❯ otool -D lz4/.dylibs/liblz4.1.9.3.dylib
lz4/.dylibs/liblz4.1.9.3.dylib:
/DLC/lz4/.dylibs/liblz4.1.9.3.dylib

So... I guess Omnibus should fix their healthcheck after all! One last question that you may be able to help me with, so I can figure out the Omnibus fix: does "check otool -D output and remove the install name ID we get from there from the otool -L list" the proper way to get a list of all shared libraries used by a dylib?

matthew-brett commented 2 years ago

Yes - you could do that. That's basically what we do : https://github.com/matthew-brett/delocate/blob/master/delocate/tools.py#L475

mx-psi commented 2 years ago

Awesome, this was very helpful, thanks 🙇 !!