cudaPackages.autoAddOpenGLRunpathHook: fix to skip unsupported/unneed

This commit is contained in:
Elliot Cameron 2023-07-27 16:57:22 -04:00
parent 6a830314d4
commit 03e72e46cb

View File

@ -1,14 +1,24 @@
# Run autoOpenGLRunpath on all files
# shellcheck shell=bash
# Run addOpenGLRunpath on all dynamically linked, ELF files
echo "Sourcing auto-add-opengl-runpath-hook"
autoAddOpenGLRunpathPhase () {
# TODO: support multiple outputs
for file in $(find ${out,lib,bin} -type f); do
addOpenGLRunpath $file
done
}
autoAddOpenGLRunpathPhase() (
local outputPaths
mapfile -t outputPaths < <(for o in $(getAllOutputNames); do echo "${!o}"; done)
find "${outputPaths[@]}" -type f -executable -print0 | while IFS= read -rd "" f; do
if isELF "$f"; then
# patchelf returns an error on statically linked ELF files
if patchelf --print-interpreter "$f" >/dev/null 2>&1; then
echo "autoAddOpenGLRunpathHook: patching $f"
addOpenGLRunpath "$f"
elif [ -n "${DEBUG-}" ]; then
echo "autoAddOpenGLRunpathHook: skipping ELF file $f"
fi
fi
done
)
if [ -z "${dontUseAutoAddOpenGLRunpath-}" ]; then
echo "Using autoAddOpenGLRunpathPhase"
postFixupHooks+=(autoAddOpenGLRunpathPhase)
echo "Using autoAddOpenGLRunpathPhase"
postFixupHooks+=(autoAddOpenGLRunpathPhase)
fi