From 06ed5b9adc15f682ca0d822955099e0ba00c2795 Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 23 Sep 2025 14:45:23 +0800 Subject: [PATCH 1/7] scalapack: modernize --- pkgs/by-name/sc/scalapack/package.nix | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkgs/by-name/sc/scalapack/package.nix b/pkgs/by-name/sc/scalapack/package.nix index aee2fc557426..08ea9fbaac7f 100644 --- a/pkgs/by-name/sc/scalapack/package.nix +++ b/pkgs/by-name/sc/scalapack/package.nix @@ -12,14 +12,14 @@ assert blas.isILP64 == lapack.isILP64; -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "scalapack"; version = "2.2.2"; src = fetchFromGitHub { owner = "Reference-ScaLAPACK"; repo = "scalapack"; - tag = "v${version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-KDMW/D7ubGaD2L7eTwULJ04fAYDPAKl8xKPZGZMkeik="; }; @@ -37,7 +37,7 @@ stdenv.mkDerivation rec { # Required to activate ILP64. # See https://github.com/Reference-ScaLAPACK/scalapack/pull/19 - postPatch = lib.optionalString passthru.isILP64 '' + postPatch = lib.optionalString finalAttrs.passthru.isILP64 '' sed -i 's/INTSZ = 4/INTSZ = 8/g' TESTING/EIG/* TESTING/LIN/* sed -i 's/INTGSZ = 4/INTGSZ = 8/g' TESTING/EIG/* TESTING/LIN/* @@ -74,10 +74,10 @@ stdenv.mkDerivation rec { -DCMAKE_C_FLAGS="${ lib.concatStringsSep " " [ "-Wno-implicit-function-declaration" - (lib.optionalString passthru.isILP64 "-DInt=long") + (lib.optionalString finalAttrs.passthru.isILP64 "-DInt=long") ] }" - ${lib.optionalString passthru.isILP64 ''-DCMAKE_Fortran_FLAGS="-fdefault-integer-8"''} + ${lib.optionalString finalAttrs.passthru.isILP64 ''-DCMAKE_Fortran_FLAGS="-fdefault-integer-8"''} ) ''; @@ -89,16 +89,16 @@ stdenv.mkDerivation rec { # _IMPORT_PREFIX, used to point to lib, points to dev output. Every package using the generated # cmake file will thus look for the library in the dev output instead of out. # Use the absolute path to $out instead to fix the issue. - substituteInPlace $dev/lib/cmake/scalapack-${version}/scalapack-targets-release.cmake \ + substituteInPlace $dev/lib/cmake/scalapack-${finalAttrs.version}/scalapack-targets-release.cmake \ --replace "\''${_IMPORT_PREFIX}" "$out" ''; - meta = with lib; { + meta = { homepage = "http://www.netlib.org/scalapack/"; description = "Library of high-performance linear algebra routines for parallel distributed memory machines"; - license = licenses.bsd3; - platforms = platforms.unix; - maintainers = with maintainers; [ + license = lib.licenses.bsd3; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ costrouc markuskowa gdinh @@ -106,4 +106,4 @@ stdenv.mkDerivation rec { # xslu and xsllt tests fail on x86 darwin broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64; }; -} +}) From 98df2bcf18a2254ecda0a07df3d7f8ce0deafed7 Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 23 Sep 2025 14:52:25 +0800 Subject: [PATCH 2/7] scalapack: use cmakeFlagsArray --- pkgs/by-name/sc/scalapack/package.nix | 29 +++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/pkgs/by-name/sc/scalapack/package.nix b/pkgs/by-name/sc/scalapack/package.nix index 08ea9fbaac7f..d8ccfedb3bdd 100644 --- a/pkgs/by-name/sc/scalapack/package.nix +++ b/pkgs/by-name/sc/scalapack/package.nix @@ -65,21 +65,20 @@ stdenv.mkDerivation (finalAttrs: { # this line is left so those who force installation on x86_64-darwin can still build doCheck = !(stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform.isDarwin); - preConfigure = '' - cmakeFlagsArray+=( - -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF - -DLAPACK_LIBRARIES="-llapack" - -DBLAS_LIBRARIES="-lblas" - -DCMAKE_Fortran_COMPILER=${lib.getDev mpi}/bin/mpif90 - -DCMAKE_C_FLAGS="${ - lib.concatStringsSep " " [ - "-Wno-implicit-function-declaration" - (lib.optionalString finalAttrs.passthru.isILP64 "-DInt=long") - ] - }" - ${lib.optionalString finalAttrs.passthru.isILP64 ''-DCMAKE_Fortran_FLAGS="-fdefault-integer-8"''} - ) - ''; + cmakeFlagsArray = [ + (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) + (lib.cmakeBool "BUILD_STATIC_LIBS" stdenv.hostPlatform.isStatic) + (lib.cmakeFeature "LAPACK_LIBRARIES" "-llapack") + (lib.cmakeFeature "BLAS_LIBRARIES" "-lblas") + (lib.cmakeFeature "CMAKE_Fortran_COMPILER" "${lib.getDev mpi}/bin/mpif90") + (lib.cmakeFeature "CMAKE_C_FLAGS" "${lib.concatStringsSep " " [ + "-Wno-implicit-function-declaration" + (lib.optionalString finalAttrs.passthru.isILP64 "-DInt=long") + ]}") + ] + ++ lib.optionals finalAttrs.passthru.isILP64 [ + (lib.cmakeFeature "CMAKE_Fortran_FLAGS" "-fdefault-integer-8") + ]; # Increase individual test timeout from 1500s to 10000s because hydra's builds # sometimes fail due to this From 9daf298676d17e43784bf6f365f189525106031d Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 23 Sep 2025 15:00:05 +0800 Subject: [PATCH 3/7] scalapack: remove cmakeFlag BUILD_STATIC_LIBS BUILD_SHARED_LIBS and BUILD_STATIC_LIBS are mutually exclusive. Only one needs to be specified. See: https://github.com/Reference-ScaLAPACK/scalapack/blob/25935e1a7e022ede9fd71bd86dcbaa7a3f1846b7/CMakeLists.txt#L113 --- pkgs/by-name/sc/scalapack/package.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/by-name/sc/scalapack/package.nix b/pkgs/by-name/sc/scalapack/package.nix index d8ccfedb3bdd..d5305f78703e 100644 --- a/pkgs/by-name/sc/scalapack/package.nix +++ b/pkgs/by-name/sc/scalapack/package.nix @@ -67,7 +67,6 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlagsArray = [ (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) - (lib.cmakeBool "BUILD_STATIC_LIBS" stdenv.hostPlatform.isStatic) (lib.cmakeFeature "LAPACK_LIBRARIES" "-llapack") (lib.cmakeFeature "BLAS_LIBRARIES" "-lblas") (lib.cmakeFeature "CMAKE_Fortran_COMPILER" "${lib.getDev mpi}/bin/mpif90") From 89b4db03cf6b3923edf675ac32e5e1905abd7c66 Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 23 Sep 2025 15:14:28 +0800 Subject: [PATCH 4/7] scalapack: remove hardeningDisable option stackprotector Hardening disable stackprotector is no longer needed to pass the build on aarch64-darwin. --- pkgs/by-name/sc/scalapack/package.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkgs/by-name/sc/scalapack/package.nix b/pkgs/by-name/sc/scalapack/package.nix index d5305f78703e..433049fff143 100644 --- a/pkgs/by-name/sc/scalapack/package.nix +++ b/pkgs/by-name/sc/scalapack/package.nix @@ -57,9 +57,6 @@ stdenv.mkDerivation (finalAttrs: { lapack ]; propagatedBuildInputs = [ mpi ]; - hardeningDisable = lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isDarwin) [ - "stackprotector" - ]; # xslu and xsllt tests seem to time out on x86_64-darwin. # this line is left so those who force installation on x86_64-darwin can still build From f3b0aa4349205563e987d58ac86d01a3dba84843 Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 23 Sep 2025 15:42:48 +0800 Subject: [PATCH 5/7] scalapack: add tests for pkg-config --- pkgs/by-name/sc/scalapack/package.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/sc/scalapack/package.nix b/pkgs/by-name/sc/scalapack/package.nix index 433049fff143..8b1952822fb2 100644 --- a/pkgs/by-name/sc/scalapack/package.nix +++ b/pkgs/by-name/sc/scalapack/package.nix @@ -8,6 +8,7 @@ mpi, blas, lapack, + testers, }: assert blas.isILP64 == lapack.isILP64; @@ -23,7 +24,12 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-KDMW/D7ubGaD2L7eTwULJ04fAYDPAKl8xKPZGZMkeik="; }; - passthru = { inherit (blas) isILP64; }; + passthru = { + inherit (blas) isILP64; + tests.pkg-config = testers.hasPkgConfigModules { + package = finalAttrs.finalPackage; + }; + }; __structuredAttrs = true; @@ -93,6 +99,7 @@ stdenv.mkDerivation (finalAttrs: { description = "Library of high-performance linear algebra routines for parallel distributed memory machines"; license = lib.licenses.bsd3; platforms = lib.platforms.unix; + pkgConfigModules = [ "scalapack" ]; maintainers = with lib.maintainers; [ costrouc markuskowa From e6bb9a1e55ceef1d987603cba73364a56220bc7e Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 23 Sep 2025 15:43:46 +0800 Subject: [PATCH 6/7] scalapack: propagate blas and lapack propagation of blas and lapack is required by scalapack.pc. --- pkgs/by-name/sc/scalapack/package.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/sc/scalapack/package.nix b/pkgs/by-name/sc/scalapack/package.nix index 8b1952822fb2..9954463fe830 100644 --- a/pkgs/by-name/sc/scalapack/package.nix +++ b/pkgs/by-name/sc/scalapack/package.nix @@ -57,12 +57,14 @@ stdenv.mkDerivation (finalAttrs: { ]; nativeBuildInputs = [ cmake ]; + nativeCheckInputs = [ mpiCheckPhaseHook ]; - buildInputs = [ + + propagatedBuildInputs = [ blas lapack + mpi ]; - propagatedBuildInputs = [ mpi ]; # xslu and xsllt tests seem to time out on x86_64-darwin. # this line is left so those who force installation on x86_64-darwin can still build From e2861dce59130b356171e6b85661e636afe69d24 Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 23 Sep 2025 15:03:39 +0800 Subject: [PATCH 7/7] scalapack: add gfortran to nativeBuildInputs --- pkgs/by-name/sc/scalapack/package.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/sc/scalapack/package.nix b/pkgs/by-name/sc/scalapack/package.nix index 9954463fe830..4842b78f734a 100644 --- a/pkgs/by-name/sc/scalapack/package.nix +++ b/pkgs/by-name/sc/scalapack/package.nix @@ -4,6 +4,7 @@ fetchFromGitHub, fetchpatch, cmake, + gfortran, mpiCheckPhaseHook, mpi, blas, @@ -56,7 +57,10 @@ stdenv.mkDerivation (finalAttrs: { "dev" ]; - nativeBuildInputs = [ cmake ]; + nativeBuildInputs = [ + cmake + gfortran + ]; nativeCheckInputs = [ mpiCheckPhaseHook ]; @@ -74,7 +78,6 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) (lib.cmakeFeature "LAPACK_LIBRARIES" "-llapack") (lib.cmakeFeature "BLAS_LIBRARIES" "-lblas") - (lib.cmakeFeature "CMAKE_Fortran_COMPILER" "${lib.getDev mpi}/bin/mpif90") (lib.cmakeFeature "CMAKE_C_FLAGS" "${lib.concatStringsSep " " [ "-Wno-implicit-function-declaration" (lib.optionalString finalAttrs.passthru.isILP64 "-DInt=long")