From e0605b3174f4d786368f5cfc2086a74e66c3cc34 Mon Sep 17 00:00:00 2001 From: Roberto Di Remigio Date: Wed, 11 Dec 2019 20:49:49 +0100 Subject: [PATCH 1/3] mkl: add GNU threading and Fortran libraries Signed-off-by: Roberto Di Remigio --- .../libraries/science/math/mkl/default.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/science/math/mkl/default.nix b/pkgs/development/libraries/science/math/mkl/default.nix index 382d2c303e3c..08644f7c2eff 100644 --- a/pkgs/development/libraries/science/math/mkl/default.nix +++ b/pkgs/development/libraries/science/math/mkl/default.nix @@ -46,10 +46,23 @@ in stdenvNoCC.mkDerivation { tar xzvf $f done '' else '' - rpmextract rpm/intel-mkl-cluster-rt-${rpm-ver}.x86_64.rpm + # Common stuff rpmextract rpm/intel-mkl-common-c-${rpm-ver}.noarch.rpm - rpmextract rpm/intel-mkl-core-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-common-f-${rpm-ver}.noarch.rpm + + # Dynamic libraries + rpmextract rpm/intel-mkl-cluster-rt-${rpm-ver}.x86_64.rpm rpmextract rpm/intel-mkl-core-rt-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-gnu-f-rt-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-gnu-rt-${rpm-ver}.x86_64.rpm + + # Static libraries + rpmextract rpm/intel-mkl-cluster-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-core-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-gnu-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-gnu-f-${rpm-ver}.x86_64.rpm + + # Intel OpenMP runtime rpmextract rpm/intel-openmp-${openmp-ver}.x86_64.rpm ''; From 6cc9bbe2fd441e5c994726d5c456e77a604f272b Mon Sep 17 00:00:00 2001 From: Roberto Di Remigio Date: Sun, 15 Dec 2019 22:43:23 +0100 Subject: [PATCH 2/3] mkl: extract static libraries optionally --- .../libraries/science/math/mkl/default.nix | 36 ++++++++++--------- pkgs/top-level/static.nix | 9 ++--- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/pkgs/development/libraries/science/math/mkl/default.nix b/pkgs/development/libraries/science/math/mkl/default.nix index 08644f7c2eff..89b30703d3d5 100644 --- a/pkgs/development/libraries/science/math/mkl/default.nix +++ b/pkgs/development/libraries/science/math/mkl/default.nix @@ -1,4 +1,4 @@ -{ stdenvNoCC, fetchurl, rpmextract, undmg, darwin }: +{ stdenvNoCC, fetchurl, rpm, cpio, undmg, darwin, enableStatic ? false }: /* For details on using mkl as a blas provider for python packages such as numpy, numexpr, scipy, etc., see the Python section of the NixPkgs manual. @@ -39,7 +39,7 @@ in stdenvNoCC.mkDerivation { then [ undmg darwin.cctools ] else - [ rpmextract ]; + [ rpm cpio ]; buildPhase = if stdenvNoCC.isDarwin then '' for f in Contents/Resources/pkg/*.tgz; do @@ -47,24 +47,28 @@ in stdenvNoCC.mkDerivation { done '' else '' # Common stuff - rpmextract rpm/intel-mkl-common-c-${rpm-ver}.noarch.rpm - rpmextract rpm/intel-mkl-common-f-${rpm-ver}.noarch.rpm + rpm2cpio rpm/intel-mkl-common-c-${rpm-ver}.noarch.rpm | cpio -idv + rpm2cpio rpm/intel-mkl-common-f-${rpm-ver}.noarch.rpm | cpio -idv # Dynamic libraries - rpmextract rpm/intel-mkl-cluster-rt-${rpm-ver}.x86_64.rpm - rpmextract rpm/intel-mkl-core-rt-${rpm-ver}.x86_64.rpm - rpmextract rpm/intel-mkl-gnu-f-rt-${rpm-ver}.x86_64.rpm - rpmextract rpm/intel-mkl-gnu-rt-${rpm-ver}.x86_64.rpm - - # Static libraries - rpmextract rpm/intel-mkl-cluster-${rpm-ver}.x86_64.rpm - rpmextract rpm/intel-mkl-core-${rpm-ver}.x86_64.rpm - rpmextract rpm/intel-mkl-gnu-${rpm-ver}.x86_64.rpm - rpmextract rpm/intel-mkl-gnu-f-${rpm-ver}.x86_64.rpm + rpm2cpio rpm/intel-mkl-cluster-rt-${rpm-ver}.x86_64.rpm | cpio -idv + rpm2cpio rpm/intel-mkl-core-rt-${rpm-ver}.x86_64.rpm | cpio -idv + rpm2cpio rpm/intel-mkl-gnu-f-rt-${rpm-ver}.x86_64.rpm | cpio -idv + rpm2cpio rpm/intel-mkl-gnu-rt-${rpm-ver}.x86_64.rpm | cpio -idv # Intel OpenMP runtime - rpmextract rpm/intel-openmp-${openmp-ver}.x86_64.rpm - ''; + rpm2cpio rpm/intel-openmp-${openmp-ver}.x86_64.rpm | cpio -idv + '' + (if enableStatic then '' + # Static libraries + rpm2cpio rpm/intel-mkl-core-${rpm-ver}.x86_64.rpm | cpio -idv + rpm2cpio rpm/intel-mkl-cluster-${rpm-ver}.x86_64.rpm | cpio -idv + rpm2cpio rpm/intel-mkl-gnu-${rpm-ver}.x86_64.rpm | cpio -idv + rpm2cpio rpm/intel-mkl-gnu-f-${rpm-ver}.x86_64.rpm | cpio -idv + '' else '' + # Extract the PkgConfig files for dynamic libraries only + rpm2cpio rpm/intel-mkl-core-${rpm-ver}.x86_64.rpm | cpio -idv '*dynamic*.pc' + '' + ); installPhase = '' for f in $(find . -name 'mkl*.pc') ; do diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix index 687086b6ed3b..7736a265b947 100644 --- a/pkgs/top-level/static.nix +++ b/pkgs/top-level/static.nix @@ -55,7 +55,7 @@ self: super: let removeUnknownConfigureFlags = f: with self.lib; remove "--disable-shared" (remove "--enable-static" f); - + ocamlFixPackage = b: b.overrideAttrs (o: { configurePlatforms = [ ]; @@ -63,7 +63,7 @@ self: super: let buildInputs = o.buildInputs ++ o.nativeBuildInputs or [ ]; propagatedNativeBuildInputs = o.propagatedBuildInputs or [ ]; }); - + ocamlStaticAdapter = _: super: self.lib.mapAttrs (_: p: if p ? overrideAttrs then ocamlFixPackage p else p) @@ -153,6 +153,7 @@ in { static = true; }; openblas = super.openblas.override { enableStatic = true; }; + mkl = super.mkl.override { enableStatic = true; }; nix = super.nix.override { withAWS = false; }; # openssl 1.1 doesn't compile openssl = super.openssl_1_0_2.override { @@ -209,7 +210,7 @@ in { kmod = super.kmod.override { withStatic = true; }; - + curl = super.curl.override { # a very sad story: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439039 gssSupport = false; @@ -241,6 +242,6 @@ in { ocaml-ng = self.lib.mapAttrs (_: set: if set ? overrideScope' then set.overrideScope' ocamlStaticAdapter else set ) super.ocaml-ng; - + python27 = super.python27.override { static = true; }; } From 153597a3203edcd08306a368fceb401966f2c04b Mon Sep 17 00:00:00 2001 From: Roberto Di Remigio Date: Thu, 19 Dec 2019 10:23:26 +0100 Subject: [PATCH 3/3] mkl: filter static libs in installPhase --- .../libraries/science/math/mkl/default.nix | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/pkgs/development/libraries/science/math/mkl/default.nix b/pkgs/development/libraries/science/math/mkl/default.nix index 89b30703d3d5..604413c96d8a 100644 --- a/pkgs/development/libraries/science/math/mkl/default.nix +++ b/pkgs/development/libraries/science/math/mkl/default.nix @@ -1,4 +1,4 @@ -{ stdenvNoCC, fetchurl, rpm, cpio, undmg, darwin, enableStatic ? false }: +{ stdenvNoCC, fetchurl, rpmextract, undmg, darwin, enableStatic ? false }: /* For details on using mkl as a blas provider for python packages such as numpy, numexpr, scipy, etc., see the Python section of the NixPkgs manual. @@ -39,7 +39,7 @@ in stdenvNoCC.mkDerivation { then [ undmg darwin.cctools ] else - [ rpm cpio ]; + [ rpmextract ]; buildPhase = if stdenvNoCC.isDarwin then '' for f in Contents/Resources/pkg/*.tgz; do @@ -47,26 +47,25 @@ in stdenvNoCC.mkDerivation { done '' else '' # Common stuff - rpm2cpio rpm/intel-mkl-common-c-${rpm-ver}.noarch.rpm | cpio -idv - rpm2cpio rpm/intel-mkl-common-f-${rpm-ver}.noarch.rpm | cpio -idv + rpmextract rpm/intel-mkl-core-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-common-c-${rpm-ver}.noarch.rpm + rpmextract rpm/intel-mkl-common-f-${rpm-ver}.noarch.rpm # Dynamic libraries - rpm2cpio rpm/intel-mkl-cluster-rt-${rpm-ver}.x86_64.rpm | cpio -idv - rpm2cpio rpm/intel-mkl-core-rt-${rpm-ver}.x86_64.rpm | cpio -idv - rpm2cpio rpm/intel-mkl-gnu-f-rt-${rpm-ver}.x86_64.rpm | cpio -idv - rpm2cpio rpm/intel-mkl-gnu-rt-${rpm-ver}.x86_64.rpm | cpio -idv + rpmextract rpm/intel-mkl-cluster-rt-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-core-rt-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-gnu-f-rt-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-gnu-rt-${rpm-ver}.x86_64.rpm # Intel OpenMP runtime - rpm2cpio rpm/intel-openmp-${openmp-ver}.x86_64.rpm | cpio -idv + rpmextract rpm/intel-openmp-${openmp-ver}.x86_64.rpm '' + (if enableStatic then '' # Static libraries - rpm2cpio rpm/intel-mkl-core-${rpm-ver}.x86_64.rpm | cpio -idv - rpm2cpio rpm/intel-mkl-cluster-${rpm-ver}.x86_64.rpm | cpio -idv - rpm2cpio rpm/intel-mkl-gnu-${rpm-ver}.x86_64.rpm | cpio -idv - rpm2cpio rpm/intel-mkl-gnu-f-${rpm-ver}.x86_64.rpm | cpio -idv + rpmextract rpm/intel-mkl-cluster-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-gnu-${rpm-ver}.x86_64.rpm + rpmextract rpm/intel-mkl-gnu-f-${rpm-ver}.x86_64.rpm '' else '' - # Extract the PkgConfig files for dynamic libraries only - rpm2cpio rpm/intel-mkl-core-${rpm-ver}.x86_64.rpm | cpio -idv '*dynamic*.pc' + # Take care of installing dynamic-only PkgConfig files during the installPhase '' ); @@ -97,16 +96,21 @@ in stdenvNoCC.mkDerivation { cp -r compilers_and_libraries_${version}/mac/mkl/bin/pkgconfig/* $out/lib/pkgconfig '' else '' mkdir -p $out/lib + cp license.txt $out/lib/ cp -r opt/intel/compilers_and_libraries_${version}/linux/mkl/include $out/ + mkdir -p $out/lib/pkgconfig + '') + + (if enableStatic then '' cp -r opt/intel/compilers_and_libraries_${version}/linux/compiler/lib/intel64_lin/* $out/lib/ cp -r opt/intel/compilers_and_libraries_${version}/linux/mkl/lib/intel64_lin/* $out/lib/ - cp license.txt $out/lib/ - - mkdir -p $out/lib/pkgconfig cp -r opt/intel/compilers_and_libraries_${version}/linux/mkl/bin/pkgconfig/* $out/lib/pkgconfig - ''); + '' else '' + cp -r opt/intel/compilers_and_libraries_${version}/linux/compiler/lib/intel64_lin/*.so* $out/lib/ + cp -r opt/intel/compilers_and_libraries_${version}/linux/mkl/lib/intel64_lin/*.so* $out/lib/ + cp -r opt/intel/compilers_and_libraries_${version}/linux/mkl/bin/pkgconfig/*dynamic*.pc $out/lib/pkgconfig + ''); # fixDarwinDylibName fails for libmkl_cdft_core.dylib because the # larger updated load commands do not fit. Use install_name_tool