You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compiled binaries and libraries within rez packages that get bundled, may still link to libs outside of the bundle due to runpath/rpath headers.
Unfortunately it doesn't appear possible to fix this simply by patching (eg) rpath headers to $ORIGIN/.... There's no guarantee that patched paths are shorter in length than the existing paths, and it's not possible to patch with longer paths.
A lib within a bundle linking to a lib outside the bundle may still work, but isn't really standalone. We have a case where we're copying bundles into containers that are missing the mount where our central package repos are, so in this case the bundle fails completely because the dynamic linker cannot find the files at all.
A proposed solution is (pseudocode):
libpaths = []
for pkg in reverse_dep_order(bundle_context):
for elfpath in find_elfs(pkg):
for libpath in iter_rpaths(elfpath):
for pkg2 in iter_pkgs(bundle_context):
rel_libpath = os.path.relpath(libpath, get_pre_bundled_root(pkg2)):
if not rel_libpath.startswith("../"):
libpaths.append("{%s.root}/%s" % (pkg.name, rel_libpath))
break
with open("post_commands.py", 'w') as f:
for libpath in libpaths:
f.write("env.LD_LIBRARY_PATH.append(%r)\n" % libpath)
The resulting file will be sourced after the bundle context, via #1071.
Note that this will only work on linux/(mac?). Another solution will have to be found for windows, and it's possible that post_commands.py requires some extra code to switch based on platform.
Note:
We should also investigate whether it's feasible to use patchelf to clear the existing rpath, so the linker never attempts to link to anything outside of the bundle.
The text was updated successfully, but these errors were encountered:
Note: It seems patchelf is actually fine with replacing rpath with a longer searchpath, so I've gone with that (it's simpler and less prone to differing behaviour)
Compiled binaries and libraries within rez packages that get bundled, may still link to libs outside of the bundle due to runpath/rpath headers.
Unfortunately it doesn't appear possible to fix this simply by patching (eg) rpath headers to
$ORIGIN/...
. There's no guarantee that patched paths are shorter in length than the existing paths, and it's not possible to patch with longer paths.A lib within a bundle linking to a lib outside the bundle may still work, but isn't really standalone. We have a case where we're copying bundles into containers that are missing the mount where our central package repos are, so in this case the bundle fails completely because the dynamic linker cannot find the files at all.
A proposed solution is (pseudocode):
The resulting file will be sourced after the bundle context, via #1071.
Note that this will only work on linux/(mac?). Another solution will have to be found for windows, and it's possible that post_commands.py requires some extra code to switch based on platform.
Note:
We should also investigate whether it's feasible to use patchelf to clear the existing rpath, so the linker never attempts to link to anything outside of the bundle.
The text was updated successfully, but these errors were encountered: