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.
This commit is contained in:
Daniël de Kok 2020-11-06 09:56:13 +01:00
parent 702b626570
commit b5d27eb87c
3 changed files with 49 additions and 1 deletions

@ -1,4 +1,5 @@
{ stdenvNoCC
{ callPackage
, stdenvNoCC
, fetchurl
, rpmextract
, undmg
@ -157,6 +158,8 @@ in stdenvNoCC.mkDerivation {
dontStrip = true;
dontPatchELF = true;
passthru.tests.pkg-config = callPackage ./test { };
meta = with stdenvNoCC.lib; {
description = "Intel Math Kernel Library";
longDescription = ''

@ -0,0 +1,33 @@
{ stdenv, pkg-config, mkl }:
stdenv.mkDerivation {
pname = "mkl-test";
version = mkl.version;
src = ./.;
nativeBuildInputs = [ pkg-config ];
buildInputs = [ mkl ];
doCheck = true;
buildPhase = ''
# Check regular Nix build.
gcc $(pkg-config --cflags --libs mkl-dynamic-ilp64-seq) test.c -o test
# Clear flags to ensure that we are purely relying on options
# provided by pkg-config.
NIX_CFLAGS_COMPILE="" \
NIX_LDFLAGS="" \
gcc $(pkg-config --cflags --libs mkl-dynamic-ilp64-seq) test.c -o test
'';
installPhase = ''
touch $out
'';
checkPhase = ''
./test
'';
}

@ -0,0 +1,12 @@
#include <assert.h>
#include <mkl_cblas.h>
int main() {
float u[] = {1., 2., 3.};
float v[] = {4., 5., 6.};
float dp = cblas_sdot(3, u, 1, v, 1);
assert(dp == 32.);
}