summary refs log tree commit diff
path: root/pkgs/development/compilers
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-02-28 00:11:22 +0100
committerEelco Dolstra <edolstra@gmail.com>2017-02-28 11:21:33 +0100
commitc2d4b14637547efc602d4f135517c236ae596cfc (patch)
tree0ef59dbbb3e717a78af3a457b9456b305c70063d /pkgs/development/compilers
parentb5c619cbfec8b319f3a412a39241a9302f58ae82 (diff)
downloadnixpkgs-c2d4b14637547efc602d4f135517c236ae596cfc.tar
nixpkgs-c2d4b14637547efc602d4f135517c236ae596cfc.tar.gz
nixpkgs-c2d4b14637547efc602d4f135517c236ae596cfc.tar.bz2
nixpkgs-c2d4b14637547efc602d4f135517c236ae596cfc.tar.lz
nixpkgs-c2d4b14637547efc602d4f135517c236ae596cfc.tar.xz
nixpkgs-c2d4b14637547efc602d4f135517c236ae596cfc.tar.zst
nixpkgs-c2d4b14637547efc602d4f135517c236ae596cfc.zip
cudatoolkit: Multiple output improvements
* Add a "lib" output containing (for the moment) only libOpenCL. This
  reduces the closure size of opensubdiv and blender by about 2 GiB.

* Add a "doc" output (about ~200 MiB).

* Remove the "sdk" output since it was worse than useless: all of the
  "sdk" output was also included in "out", so it actually increased
  disk space usage.

* Run patchelf on ELF binaries only.
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r--pkgs/development/compilers/cudatoolkit/default.nix38
1 files changed, 27 insertions, 11 deletions
diff --git a/pkgs/development/compilers/cudatoolkit/default.nix b/pkgs/development/compilers/cudatoolkit/default.nix
index f2176ed2607..da29d918b05 100644
--- a/pkgs/development/compilers/cudatoolkit/default.nix
+++ b/pkgs/development/compilers/cudatoolkit/default.nix
@@ -22,7 +22,7 @@ let
           }
         else throw "cudatoolkit does not support platform ${stdenv.system}";
 
-      outputs = [ "out" "sdk" ];
+      outputs = [ "out" "lib" "doc" ];
 
       buildInputs = [ perl ];
 
@@ -43,24 +43,35 @@ let
       '';
 
       buildPhase = ''
-        find . -type f -executable -exec patchelf \
-          --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-          '{}' \; || true
-        find . -type f -exec patchelf \
-          --set-rpath $rpath:$out/jre/lib/amd64/jli:$out/lib:$out/lib64:$out/nvvm/lib:$out/nvvm/lib64:$(cat $NIX_CC/nix-support/orig-cc)/lib \
-          --force-rpath \
-          '{}' \; || true
+        chmod -R u+w .
+        while IFS= read -r -d ''$'\0' i; do
+          if ! isELF "$i"; then continue; fi
+          echo "patching $i..."
+          if [[ ! $i =~ \.so ]]; then
+            patchelf \
+              --set-interpreter "''$(cat $NIX_CC/nix-support/dynamic-linker)" $i
+          fi
+          if [[ $i =~ libOpenCL ]]; then
+            rpath2=
+          else
+            rpath2=$rpath:$lib/lib:$out/jre/lib/amd64/jli:$out/lib:$out/lib64:$out/nvvm/lib:$out/nvvm/lib64
+          fi
+          patchelf --set-rpath $rpath2 --force-rpath $i
+        done < <(find . -type f -print0)
       '';
 
       installPhase = ''
-        mkdir $out $sdk
+        mkdir $out
         perl ./install-linux.pl --prefix="$out"
-        rm $out/tools/CUDA_Occupancy_Calculator.xls
-        perl ./install-sdk-linux.pl --prefix="$sdk" --cudaprefix="$out"
+
+        rm $out/tools/CUDA_Occupancy_Calculator.xls # FIXME: why?
 
         # let's remove the 32-bit libraries, they confuse the lib64->lib mover
         rm -rf $out/lib
 
+        # Remove some cruft.
+        rm $out/bin/uninstall*
+
         # Fixup path to samples (needed for cuda 6.5 or else nsight will not find them)
         if [ -d "$out"/cuda-samples ]; then
             mv "$out"/cuda-samples "$out"/samples
@@ -73,6 +84,11 @@ let
         mkdir -p $out/nix-support
         echo "cmakeFlags+=' -DCUDA_TOOLKIT_ROOT_DIR=$out'" >> $out/nix-support/setup-hook
 
+        # Move some libraries to the lib output so that programs that
+        # depend on them don't pull in this entire monstrosity.
+        mkdir -p $lib/lib
+        mv -v $out/lib64/libOpenCL* $lib/lib/
+
       '' + lib.optionalString (lib.versionOlder version "8.0") ''
         # Hack to fix building against recent Glibc/GCC.
         echo "NIX_CFLAGS_COMPILE+=' -D_FORCE_INLINES'" >> $out/nix-support/setup-hook