Skip to content

Commit

Permalink
Add target libraries to executable's RPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Oct 15, 2024
1 parent c893887 commit 62215cc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
6 changes: 6 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ for i in `ls`; do

# bin installed in PREFIX
cp -rv $i ${PREFIX}

if [[ $i == "bin" ]]; then
for j in `ls "${i}"`; do
patchelf --force-rpath --set-rpath "\$ORIGIN/../lib:\$ORIGIN/../${targetsDir}/lib" "${PREFIX}/${i}/${j}";
done
fi
done
8 changes: 7 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ source:

build:
number: 0
binary_relocation: false
skip: true # [osx or ppc64le]

requirements:
Expand All @@ -34,8 +35,13 @@ requirements:
- cuda-nvdisasm

test:
requires:
- patchelf # [linux]
files:
- test-rpath.sh
commands:
- test -f $PREFIX/bin/cuobjdump # [linux]
- test -f $PREFIX/bin/cuobjdump # [linux]
- bash test-rpath.sh # [linux]
- if not exist %LIBRARY_BIN%\\cuobjdump.exe exit 1 # [win]

about:
Expand Down
26 changes: 26 additions & 0 deletions recipe/test-rpath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

[[ ${target_platform} == "linux-64" ]] && targetsDir="targets/x86_64-linux"
[[ ${target_platform} == "linux-ppc64le" ]] && targetsDir="targets/ppc64le-linux"
[[ ${target_platform} == "linux-aarch64" ]] && targetsDir="targets/sbsa-linux"

errors=""

for bin in `find ${PREFIX}/bin -type f`; do
rpath=$(patchelf --print-rpath "${bin}")
echo "${bin} rpath: ${rpath}"
if [[ $rpath != "\$ORIGIN/../lib:\$ORIGIN/../${targetsDir}/lib" ]]; then
errors+="${bin}\n"
elif [[ $(objdump -x ${bin} | grep "PATH") == *"RUNPATH"* ]]; then
errors+="${bin}\n"
fi
done

if [[ $errors ]]; then
echo "The following binaries were found with an unexpected RPATH:"
echo -e "${errors}"

exit 1
else
exit 0
fi

0 comments on commit 62215cc

Please sign in to comment.