Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mumps: use magic __structuredAttrs to handle space in makeFlags #355128

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 33 additions & 37 deletions pkgs/by-name/mu/mumps/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,37 @@ assert withParmetis -> mpiSupport;
assert withPtScotch -> mpiSupport;
let
profile = if mpiSupport then "debian.PAR" else "debian.SEQ";
metisFlags =
if withParmetis then
''
IMETIS="-I${parmetis}/include -I${metis}/include" \
LMETIS="-L${parmetis}/lib -lparmetis -L${metis}/lib -lmetis"
''
else
''
IMETIS=-I${metis}/include \
LMETIS="-L${metis}/lib -lmetis"
'';
scotchFlags =
LMETIS = toString ([ "-lmetis" ] ++ lib.optional withParmetis "-lparmetis");
LSCOTCH = toString (
if withPtScotch then
''
ISCOTCH=-I${scotch.dev}/include \
LSCOTCH="-L${scotch}/lib -lptscotch -lptesmumps -lptscotcherr"
''
[
"-lptscotch"
"-lptesmumps"
"-lptscotcherr"
]
else
''
ISCOTCH=-I${scotch.dev}/include \
LSCOTCH="-L${scotch}/lib -lesmumps -lscotch -lscotcherr"
'';
macroFlags =
"-Dmetis -Dpord -Dscotch"
+ lib.optionalString withParmetis " -Dparmetis"
+ lib.optionalString withPtScotch " -Dptscotch";
# Optimized options
# Disable -fopenmp in lines below to benefit from OpenMP
optFlags = ''
OPTF="-O3 -fallow-argument-mismatch" \
OPTL="-O3" \
OPTC="-O3"
'';
[
"-lesmumps"
"-lscotch"
"-lscotcherr"
]
);
ORDERINGSF = toString (
[
"-Dmetis"
"-Dpord"
"-Dscotch"
]
++ lib.optional withParmetis "-Dparmetis"
++ lib.optional withPtScotch "-Dptscotch"
);
in
stdenv.mkDerivation (finalAttrs: {
name = "mumps";
version = "5.7.3";
# makeFlags contain space and one should use makeFlagsArray+
# Setting this magic var is an optional solution
__structuredAttrs = true;

src = fetchzip {
url = "https://mumps-solver.org/MUMPS_${finalAttrs.version}.tar.gz";
Expand All @@ -76,16 +70,19 @@ stdenv.mkDerivation (finalAttrs: {

enableParallelBuilding = true;

preBuild = ''
makeFlagsArray+=(${metisFlags} ${scotchFlags} ORDERINGSF="${macroFlags}" ${optFlags})
'';

makeFlags =
lib.optionals stdenv.hostPlatform.isDarwin [
"SONAME="
"LIBEXT_SHARED=.dylib"
]
++ [
"ISCOTCH=-I${scotch.dev}/include"
"LMETIS=${LMETIS}"
"LSCOTCH=${LSCOTCH}"
"ORDERINGSF=${ORDERINGSF}"
"OPTF=-O3 -fallow-argument-mismatch"
"OPTC=-O3"
"OPTL=-O3"
"SCALAP=-lscalapack"
"allshared"
];
Expand All @@ -105,7 +102,7 @@ stdenv.mkDerivation (finalAttrs: {

nativeBuildInputs = [
gfortran
] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames ++ lib.optional mpiSupport mpi;
] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;

# Parmetis should be placed before scotch to avoid conflict of header file "parmetis.h"
buildInputs =
Expand All @@ -125,7 +122,6 @@ stdenv.mkDerivation (finalAttrs: {
${lib.optionalString stdenv.hostPlatform.isDarwin "export DYLD_LIBRARY_PATH=$out/lib\n"}
${lib.optionalString mpiSupport "export MPIRUN='mpirun -n 2'\n"}
cd examples
make all
$MPIRUN ./ssimpletest <input_simpletest_real
$MPIRUN ./dsimpletest <input_simpletest_real
$MPIRUN ./csimpletest <input_simpletest_cmplx
Expand Down