about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/cudatoolkit/auto-add-opengl-runpath-hook.sh
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/cudatoolkit/auto-add-opengl-runpath-hook.sh')
-rw-r--r--nixpkgs/pkgs/development/compilers/cudatoolkit/auto-add-opengl-runpath-hook.sh10
1 files changed, 7 insertions, 3 deletions
diff --git a/nixpkgs/pkgs/development/compilers/cudatoolkit/auto-add-opengl-runpath-hook.sh b/nixpkgs/pkgs/development/compilers/cudatoolkit/auto-add-opengl-runpath-hook.sh
index 395229ca79b7..f50a5f6c25c6 100644
--- a/nixpkgs/pkgs/development/compilers/cudatoolkit/auto-add-opengl-runpath-hook.sh
+++ b/nixpkgs/pkgs/development/compilers/cudatoolkit/auto-add-opengl-runpath-hook.sh
@@ -2,17 +2,21 @@
 # Run addOpenGLRunpath on all dynamically linked, ELF files
 echo "Sourcing auto-add-opengl-runpath-hook"
 
+elfHasDynamicSection() {
+    patchelf --print-rpath "$1" >& /dev/null
+}
+
 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
+      if elfHasDynamicSection "$f" ; then
         echo "autoAddOpenGLRunpathHook: patching $f"
         addOpenGLRunpath "$f"
-      elif [ -n "${DEBUG-}" ]; then
-        echo "autoAddOpenGLRunpathHook: skipping ELF file $f"
+      elif (( "${NIX_DEBUG:-0}" >= 1 )) ; then
+        echo "autoAddOpenGLRunpathHook: skipping a statically-linked ELF file $f"
       fi
     fi
   done