SIGN IN SIGN UP

Set the RPATH of _portable_lib.so so it can find libtorch (#3472)

Summary:
Pull Request resolved: https://github.com/pytorch/executorch/pull/3472

pip wheels will need to be able to find the torch libraries. On Linux,
the .so has non-absolute dependencies on libs like "libtorch.so" without
paths; as long as we `import torch` first, those dependencies will work.

But Apple dylibs do not support non-absolute dependencies, so we need
to tell the loader where to look for its libraries. The LC_LOAD_DYLIB
entries for the torch libraries will look like "rpath/libtorch.dylib",
so we can add an LC_RPATH entry to look in a directory relative to the
installed location of our _portable_lib.so file.

To see these LC_* values, run `otool -l _portable_lib*.so`.

imported-using-ghimport

Test Plan: Imported from OSS

Reviewed By: mikekgfb

Differential Revision: D56857492

Pulled By: dbort

fbshipit-source-id: e776ac21118630fe60ccfcd98103ba14a10d1bad
D
Dave Bort committed
da2d695dce8ddaea198ac0c80ca60374f0c09e4a
Parent: 61d7af7
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 5/2/2024, 12:37:07 AM