mkl: Add a small test program

The MKL pkg-config files often change and are then incorrect for our
paths. pkg-config validation finds some issues, but not incorrect
paths. So, add a small test program to test whether the generated
pkg-config files can actually be used to build a functioning
binary. Hopefully this catches future regressions.

+49 -1
+4 -1
pkgs/development/libraries/science/math/mkl/default.nix
··· 1 - { stdenvNoCC 1 + { callPackage 2 + , stdenvNoCC 2 3 , fetchurl 3 4 , rpmextract 4 5 , undmg ··· 156 157 # Per license agreement, do not modify the binary 157 158 dontStrip = true; 158 159 dontPatchELF = true; 160 + 161 + passthru.tests.pkg-config = callPackage ./test { }; 159 162 160 163 meta = with stdenvNoCC.lib; { 161 164 description = "Intel Math Kernel Library";
+33
pkgs/development/libraries/science/math/mkl/test/default.nix
··· 1 + { stdenv, pkg-config, mkl }: 2 + 3 + stdenv.mkDerivation { 4 + pname = "mkl-test"; 5 + version = mkl.version; 6 + 7 + src = ./.; 8 + 9 + nativeBuildInputs = [ pkg-config ]; 10 + 11 + buildInputs = [ mkl ]; 12 + 13 + doCheck = true; 14 + 15 + buildPhase = '' 16 + # Check regular Nix build. 17 + gcc $(pkg-config --cflags --libs mkl-dynamic-ilp64-seq) test.c -o test 18 + 19 + # Clear flags to ensure that we are purely relying on options 20 + # provided by pkg-config. 21 + NIX_CFLAGS_COMPILE="" \ 22 + NIX_LDFLAGS="" \ 23 + gcc $(pkg-config --cflags --libs mkl-dynamic-ilp64-seq) test.c -o test 24 + ''; 25 + 26 + installPhase = '' 27 + touch $out 28 + ''; 29 + 30 + checkPhase = '' 31 + ./test 32 + ''; 33 + }
+12
pkgs/development/libraries/science/math/mkl/test/test.c
··· 1 + #include <assert.h> 2 + 3 + #include <mkl_cblas.h> 4 + 5 + int main() { 6 + float u[] = {1., 2., 3.}; 7 + float v[] = {4., 5., 6.}; 8 + 9 + float dp = cblas_sdot(3, u, 1, v, 1); 10 + 11 + assert(dp == 32.); 12 + }