about summary refs log tree commit diff
path: root/pkgs/development/cuda-modules
diff options
context:
space:
mode:
authorSomeone Serge <sergei.kozlukov@aalto.fi>2024-04-03 08:31:25 +0000
committerSomeone Serge <sergei.kozlukov@aalto.fi>2024-04-03 08:36:41 +0000
commit39f35098d5831891f68d8a5fde56e70b957b684c (patch)
tree3f07135f648e1d99e746bbb089c8f919007c7389 /pkgs/development/cuda-modules
parenteef06fe93ea548dc7b84e8bafa9399fbcbbe2ce7 (diff)
cudaPackages.autoAddDriverRunpath: drop the redundant copy of the hook
Diffstat (limited to 'pkgs/development/cuda-modules')
-rw-r--r--pkgs/development/cuda-modules/setup-hooks/auto-add-driver-runpath-hook.sh8
-rw-r--r--pkgs/development/cuda-modules/setup-hooks/auto-fix-elf-files.sh64
-rw-r--r--pkgs/development/cuda-modules/setup-hooks/extension.nix30
3 files changed, 6 insertions, 96 deletions
diff --git a/pkgs/development/cuda-modules/setup-hooks/auto-add-driver-runpath-hook.sh b/pkgs/development/cuda-modules/setup-hooks/auto-add-driver-runpath-hook.sh
deleted file mode 100644
index ecff2a032d64f..0000000000000
--- a/pkgs/development/cuda-modules/setup-hooks/auto-add-driver-runpath-hook.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-# shellcheck shell=bash
-# Run addDriverRunpath on all dynamically linked ELF files
-echo "Sourcing auto-add-driver-runpath-hook"
-
-if [ -z "${dontUseAutoAddDriverRunpath-}" ]; then
-  echo "Using autoAddDriverRunpath"
-  postFixupHooks+=("autoFixElfFiles addDriverRunpath")
-fi
diff --git a/pkgs/development/cuda-modules/setup-hooks/auto-fix-elf-files.sh b/pkgs/development/cuda-modules/setup-hooks/auto-fix-elf-files.sh
deleted file mode 100644
index 1d57dfb17a66d..0000000000000
--- a/pkgs/development/cuda-modules/setup-hooks/auto-fix-elf-files.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-# shellcheck shell=bash
-# List all dynamically linked ELF files in the outputs and apply a generic fix
-# action provided as a parameter (currently used to add the CUDA or the
-# cuda_compat driver to the runpath of binaries)
-echo "Sourcing cuda/fix-elf-files.sh"
-
-# Returns the exit code of patchelf --print-rpath.
-# A return code of 0 (success) means the ELF file has a dynamic section, while
-# a non-zero return code means the ELF file is statically linked (or is not an
-# ELF file).
-elfHasDynamicSection() {
-  local libPath
-
-  if [[ $# -eq 0 ]]; then
-    echo "elfHasDynamicSection: no library path provided" >&2
-    exit 1
-  elif [[ $# -gt 1 ]]; then
-    echo "elfHasDynamicSection: too many arguments" >&2
-    exit 1
-  elif [[ "$1" == "" ]]; then
-    echo "elfHasDynamicSection: empty library path" >&2
-    exit 1
-  else
-    libPath="$1"
-    shift 1
-  fi
-
-  patchelf --print-rpath "$libPath" >& /dev/null
-  return $?
-}
-
-# Run a fix action on all dynamically linked ELF files in the outputs.
-autoFixElfFiles() {
-  local fixAction
-  local outputPaths
-
-  if [[ $# -eq 0 ]]; then
-    echo "autoFixElfFiles: no fix action provided" >&2
-    exit 1
-  elif [[ $# -gt 1 ]]; then
-    echo "autoFixElfFiles: too many arguments" >&2
-    exit 1
-  elif [[ "$1" == "" ]]; then
-    echo "autoFixElfFiles: empty fix action" >&2
-    exit 1
-  else
-    fixAction="$1"
-  fi
-
-  mapfile -t outputPaths < <(for o in $(getAllOutputNames); do echo "${!o}"; done)
-
-  find "${outputPaths[@]}" -type f -print0  | while IFS= read -rd "" f; do
-    if ! isELF "$f"; then
-      continue
-    elif elfHasDynamicSection "$f"; then
-      # patchelf returns an error on statically linked ELF files, and in
-      # practice fixing actions all involve patchelf
-      echo "autoFixElfFiles: using $fixAction to fix $f" >&2
-      $fixAction "$f"
-    elif (( "${NIX_DEBUG:-0}" >= 1 )); then
-      echo "autoFixElfFiles: skipping a statically-linked ELF file $f"
-    fi
-  done
-}
diff --git a/pkgs/development/cuda-modules/setup-hooks/extension.nix b/pkgs/development/cuda-modules/setup-hooks/extension.nix
index 5993c289bcb24..c385b4a06797a 100644
--- a/pkgs/development/cuda-modules/setup-hooks/extension.nix
+++ b/pkgs/development/cuda-modules/setup-hooks/extension.nix
@@ -1,10 +1,10 @@
 final: _: {
-  # Helper hook used in both autoAddCudaCompatRunpath and
-  # autoAddDriverRunpath that applies a generic patching action to all elf
-  # files with a dynamic linking section.
-  autoFixElfFiles = final.callPackage (
-    { makeSetupHook }: makeSetupHook { name = "auto-fix-elf-files"; } ./auto-fix-elf-files.sh
-  ) { };
+  # TODO:
+  # - Move to cuda-modules/aliases.nix once
+  #   https://github.com/NixOS/nixpkgs/issues/141803 is ready.
+  # - Consider removing after 24.11.
+  inherit (final.pkgs) autoAddDriverRunpath autoFixElfFiles;
+  autoAddOpenGLRunpathHook = final.autoAddDriverRunpath;
 
   # Internal hook, used by cudatoolkit and cuda redist packages
   # to accommodate automatic CUDAToolkit_ROOT construction
@@ -32,24 +32,6 @@ final: _: {
     ) { }
   );
 
-  autoAddDriverRunpath = final.callPackage (
-    {
-      addDriverRunpath,
-      autoFixElfFiles,
-      makeSetupHook,
-    }:
-    makeSetupHook {
-      name = "auto-add-opengl-runpath-hook";
-      propagatedBuildInputs = [
-        addDriverRunpath
-        autoFixElfFiles
-      ];
-    } ./auto-add-driver-runpath-hook.sh
-  ) { };
-
-  # Deprecated: an alias kept for compatibility. Consider removing after 24.11
-  autoAddOpenGLRunpathHook = final.autoAddDriverRunpath;
-
   # autoAddCudaCompatRunpath hook must be added AFTER `setupCudaHook`. Both
   # hooks prepend a path with `libcuda.so` to the `DT_RUNPATH` section of
   # patched elf files, but `cuda_compat` path must take precedence (otherwise,