From a381f040e9c0014fd9826d34be2968ad1a5611d7 Mon Sep 17 00:00:00 2001 From: Markus Kowalewski Date: Thu, 16 Jan 2025 22:00:29 +0100 Subject: [PATCH 1/2] scalapack: fix cmake files and version string --- pkgs/by-name/sc/scalapack/package.nix | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/sc/scalapack/package.nix b/pkgs/by-name/sc/scalapack/package.nix index cf5d8a5e4480..3c5485c2318c 100644 --- a/pkgs/by-name/sc/scalapack/package.nix +++ b/pkgs/by-name/sc/scalapack/package.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchFromGitHub, + fetchpatch, cmake, mpiCheckPhaseHook, mpi, @@ -18,14 +19,22 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "Reference-ScaLAPACK"; repo = pname; - rev = "v${version}"; - sha256 = "sha256-KDMW/D7ubGaD2L7eTwULJ04fAYDPAKl8xKPZGZMkeik="; + tag = "v${version}"; + hash = "sha256-KDMW/D7ubGaD2L7eTwULJ04fAYDPAKl8xKPZGZMkeik="; }; passthru = { inherit (blas) isILP64; }; __structuredAttrs = true; + patches = [ + (fetchpatch { + name = "version-string"; + url = "https://github.com/Reference-ScaLAPACK/scalapack/commit/76cc1ed3032e9a4158a4513c9047c3746b269f04.patch"; + hash = "sha256-kmllLa9GUeTrHRYeS0yIk9I8LwaIoEytdyQGRuinn3A="; + }) + ]; + # Required to activate ILP64. # See https://github.com/Reference-ScaLAPACK/scalapack/pull/19 postPatch = lib.optionalString passthru.isILP64 '' @@ -76,6 +85,14 @@ stdenv.mkDerivation rec { # sometimes fail due to this checkFlags = [ "ARGS=--timeout 10000" ]; + postFixup = '' + # _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 \ + --replace "\''${_IMPORT_PREFIX}" "$out" + ''; + meta = with lib; { homepage = "http://www.netlib.org/scalapack/"; description = "Library of high-performance linear algebra routines for parallel distributed memory machines"; From f6f5a8766de49f39b333251f86be6198ba038aef Mon Sep 17 00:00:00 2001 From: Markus Kowalewski Date: Thu, 16 Jan 2025 22:03:32 +0100 Subject: [PATCH 2/2] octopus: fix build with scalapack 2.2.2 --- pkgs/by-name/oc/octopus/package.nix | 5 +++++ pkgs/by-name/oc/octopus/scalapack-mpi-alias.patch | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 pkgs/by-name/oc/octopus/scalapack-mpi-alias.patch diff --git a/pkgs/by-name/oc/octopus/package.nix b/pkgs/by-name/oc/octopus/package.nix index 199e729221b9..c735d07e3cf3 100644 --- a/pkgs/by-name/oc/octopus/package.nix +++ b/pkgs/by-name/oc/octopus/package.nix @@ -40,6 +40,11 @@ stdenv.mkDerivation rec { hash = "sha256-vG1HUkuNUZkhBumoJJy3AyFU6cZOo1YGmaOYcU6bPOM="; }; + patches = [ + # Discover all MPI languages components to avoid scalpack discovery failure + ./scalapack-mpi-alias.patch + ]; + nativeBuildInputs = [ which perl diff --git a/pkgs/by-name/oc/octopus/scalapack-mpi-alias.patch b/pkgs/by-name/oc/octopus/scalapack-mpi-alias.patch new file mode 100644 index 000000000000..8c8253ebf1f3 --- /dev/null +++ b/pkgs/by-name/oc/octopus/scalapack-mpi-alias.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 70d89efb5e..47ba750d7a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -131,7 +131,7 @@ set(Octopus_ext_libs) + find_package(GSL) + if (OCTOPUS_MPI) + set(MPI_DETERMINE_LIBRARY_VERSION ON) +- find_package(MPI 3 COMPONENTS Fortran) ++ find_package(MPI 3) + # Further set MKL variables + if (MPI_Fortran_LIBRARY_VERSION_STRING MATCHES Intel) + set(MKL_MPI intelmpi CACHE STRING "Octopus: Overloaded")