Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/scripts/rpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ XPU_RPATHS=(
XPU_RPATHS=$(IFS=: ; echo "${XPU_RPATHS[*]}")
export C_SO_RPATH=$XPU_RPATHS':$ORIGIN:$ORIGIN/lib'
export LIB_SO_RPATH=$XPU_RPATHS':$ORIGIN'
export FORCE_RPATH="--force-rpath"

rm -rf tmp
mkdir -p tmp
Expand All @@ -40,16 +39,19 @@ else
PREFIX=libtorch
fi

# set RPATH of _C.so and similar to $ORIGIN, $ORIGIN/lib
# set RUNPATH of _C.so and similar to $ORIGIN, $ORIGIN/lib
# WARNING: RPATH is obsolete and is not recommended to be used. Note that
# RPATH is handled before LD_LIBRARY_PATH which affects .so discovery. RUNPATH
# does not have this issue.
find $PREFIX -maxdepth 1 -type f -name "*.so*" | while read sofile; do
echo "Setting rpath of $sofile to ${C_SO_RPATH:-'$ORIGIN:$ORIGIN/lib'}"
$PATCHELF_BIN --set-rpath ${C_SO_RPATH:-'$ORIGIN:$ORIGIN/lib'} ${FORCE_RPATH:-} $sofile
$PATCHELF_BIN --set-rpath ${C_SO_RPATH:-'$ORIGIN:$ORIGIN/lib'} $sofile
$PATCHELF_BIN --print-rpath $sofile
done

# set RPATH of lib/ files to $ORIGIN
find $PREFIX/lib -maxdepth 1 -type f -name "*.so*" | while read sofile; do echo "Setting rpath of $sofile to ${LIB_SO_RPATH:-'$ORIGIN'}"
$PATCHELF_BIN --set-rpath ${LIB_SO_RPATH:-'$ORIGIN'} ${FORCE_RPATH:-} $sofile
$PATCHELF_BIN --set-rpath ${LIB_SO_RPATH:-'$ORIGIN'} $sofile
$PATCHELF_BIN --print-rpath $sofile
done

Expand Down
Loading