Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 gfortran, 6 cmake, 7 shared ? true, 8 # Compile with ILP64 interface 9 blas64 ? false, 10 testers, 11}: 12 13stdenv.mkDerivation (finalAttrs: { 14 pname = "liblapack"; 15 version = "3.12.1"; 16 17 src = fetchFromGitHub { 18 owner = "Reference-LAPACK"; 19 repo = "lapack"; 20 rev = "v${finalAttrs.version}"; 21 sha256 = "sha256-SfKsvZ07v87tFFd9bnkIEdervyX/ucLfs/TOsl08aKQ="; 22 }; 23 24 nativeBuildInputs = [ 25 gfortran 26 cmake 27 ]; 28 29 # Configure stage fails on aarch64-darwin otherwise, due to either clang 11 or gfortran 10. 30 hardeningDisable = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 31 "stackprotector" 32 ]; 33 34 cmakeFlags = [ 35 "-DCMAKE_Fortran_FLAGS=-fPIC" 36 "-DLAPACKE=ON" 37 "-DCBLAS=ON" 38 "-DBUILD_TESTING=ON" 39 ] 40 ++ lib.optional shared "-DBUILD_SHARED_LIBS=ON" 41 ++ lib.optional blas64 "-DBUILD_INDEX64=ON" 42 # Tries to run host platform binaries during the build 43 # Will likely be disabled by default in 3.12, see: 44 # https://github.com/Reference-LAPACK/lapack/issues/757 45 ++ lib.optional ( 46 !stdenv.buildPlatform.canExecute stdenv.hostPlatform 47 ) "-DTEST_FORTRAN_COMPILER=OFF"; 48 49 passthru = { inherit blas64; }; 50 51 postInstall = 52 let 53 canonicalExtension = 54 if stdenv.hostPlatform.isLinux then 55 "${stdenv.hostPlatform.extensions.sharedLibrary}.${lib.versions.major finalAttrs.version}" 56 else 57 stdenv.hostPlatform.extensions.sharedLibrary; 58 in 59 lib.optionalString blas64 '' 60 ln -s $out/lib/liblapack64${canonicalExtension} $out/lib/liblapack${canonicalExtension} 61 ln -s $out/lib/liblapacke64${canonicalExtension} $out/lib/liblapacke${canonicalExtension} 62 ''; 63 64 doCheck = true; 65 66 # Some CBLAS related tests fail on Darwin: 67 # 14 - CBLAS-xscblat2 (Failed) 68 # 15 - CBLAS-xscblat3 (Failed) 69 # 17 - CBLAS-xdcblat2 (Failed) 70 # 18 - CBLAS-xdcblat3 (Failed) 71 # 20 - CBLAS-xccblat2 (Failed) 72 # 21 - CBLAS-xccblat3 (Failed) 73 # 23 - CBLAS-xzcblat2 (Failed) 74 # 24 - CBLAS-xzcblat3 (Failed) 75 # 76 # Upstream issue to track: 77 # * https://github.com/Reference-LAPACK/lapack/issues/440 78 ctestArgs = lib.optionalString stdenv.hostPlatform.isDarwin "-E '^(CBLAS-(x[sdcz]cblat[23]))$'"; 79 80 checkPhase = '' 81 runHook preCheck 82 ctest ${finalAttrs.ctestArgs} 83 runHook postCheck 84 ''; 85 86 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 87 88 meta = with lib; { 89 description = "Linear Algebra PACKage"; 90 homepage = "http://www.netlib.org/lapack/"; 91 maintainers = with maintainers; [ markuskowa ]; 92 license = licenses.bsd3; 93 pkgConfigModules = [ "lapack" ]; 94 platforms = platforms.all; 95 }; 96})