Skip to content

Commit

Permalink
octopus: fix build (NixOS#374380)
Browse files Browse the repository at this point in the history
  • Loading branch information
markuskowa authored Jan 19, 2025
2 parents 9dee4ae + f6f5a87 commit 8909ef0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkgs/by-name/oc/octopus/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions pkgs/by-name/oc/octopus/scalapack-mpi-alias.patch
Original file line number Diff line number Diff line change
@@ -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")
21 changes: 19 additions & 2 deletions pkgs/by-name/sc/scalapack/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
cmake,
mpiCheckPhaseHook,
mpi,
Expand All @@ -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 ''
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 8909ef0

Please sign in to comment.