Skip to content

Commit

Permalink
Merge pull request #14 from billysuh7/topic/bsuh/rpath
Browse files Browse the repository at this point in the history
Add lib folders to executable's RPATH
  • Loading branch information
billysuh7 authored Oct 29, 2024
2 parents 16991ee + cf9550d commit f27468b
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 38 deletions.
19 changes: 2 additions & 17 deletions .azure-pipelines/azure-pipelines-win.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions .scripts/build_steps.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 32 additions & 10 deletions .scripts/run_win_build.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions azure-pipelines.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ for i in `ls`; do
mkdir -p ${PREFIX}/$i
cp -rv $i ${PREFIX}/${targetsDir}
else
if [[ $i == "bin" ]]; then
for j in `ls "${i}"`; do
echo patchelf --force-rpath --set-rpath "\$ORIGIN/../lib:\$ORIGIN/../${targetsDir}/lib" "${i}/${j}" ...
patchelf --force-rpath --set-rpath "\$ORIGIN/../lib:\$ORIGIN/../${targetsDir}/lib" "${i}/${j}"
done
fi

# bin installed in PREFIX
cp -rv $i ${PREFIX}
fi
Expand Down
8 changes: 7 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ source:
sha256: e771414a1d96eb4b89c0759cd2d2f127b929c5c2a0961f176c3a8f0736e94b64 # [win]

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

requirements:
Expand All @@ -37,10 +38,15 @@ requirements:
- {{ pin_compatible("cuda-version", max_pin="x.x") }}

test:
requires:
- patchelf # [linux]
files:
- test-rpath.sh
commands:
- test -f $PREFIX/bin/cu++filt # [linux]
- test -f $PREFIX/targets/{{ target_name }}/include/nv_decode.h # [linux]
- test -f $PREFIX/targets/{{ target_name }}/lib/libcufilt.a # [linux]
- bash test-rpath.sh # [linux]
- if not exist %LIBRARY_BIN%\\cu++filt.exe exit 1 # [win]
- if not exist %LIBRARY_INC%\\nv_decode.h exit 1 # [win]
- if not exist %LIBRARY_LIB%\\cufilt.lib exit 1 # [win]
Expand Down
39 changes: 39 additions & 0 deletions recipe/test-rpath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/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
[[ "${bin}" =~ "patchelf" ]] && continue

pkg_info=$(conda package -w "${bin}")
echo "\$PKG_NAME: ${PKG_NAME}"
echo "\$pkg_info: ${pkg_info}"

if [[ ! "$pkg_info" == *"$PKG_NAME"* ]]; then
echo "Not a match"
echo "Skipping ${bin}"
continue
fi

echo "Match found"
echo "Testing ${bin}"

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
fi

0 comments on commit f27468b

Please sign in to comment.