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