Skip to content

Commit efc9da9

Browse files
authored
Mumps: use magic __structuredAttrs to handle space in makeFlags (#355128)
2 parents 1a3635f + 0128d05 commit efc9da9

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed

pkgs/by-name/mu/mumps/package.nix

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,37 @@ assert withParmetis -> mpiSupport;
2121
assert withPtScotch -> mpiSupport;
2222
let
2323
profile = if mpiSupport then "debian.PAR" else "debian.SEQ";
24-
metisFlags =
25-
if withParmetis then
26-
''
27-
IMETIS="-I${parmetis}/include -I${metis}/include" \
28-
LMETIS="-L${parmetis}/lib -lparmetis -L${metis}/lib -lmetis"
29-
''
30-
else
31-
''
32-
IMETIS=-I${metis}/include \
33-
LMETIS="-L${metis}/lib -lmetis"
34-
'';
35-
scotchFlags =
24+
LMETIS = toString ([ "-lmetis" ] ++ lib.optional withParmetis "-lparmetis");
25+
LSCOTCH = toString (
3626
if withPtScotch then
37-
''
38-
ISCOTCH=-I${scotch.dev}/include \
39-
LSCOTCH="-L${scotch}/lib -lptscotch -lptesmumps -lptscotcherr"
40-
''
27+
[
28+
"-lptscotch"
29+
"-lptesmumps"
30+
"-lptscotcherr"
31+
]
4132
else
42-
''
43-
ISCOTCH=-I${scotch.dev}/include \
44-
LSCOTCH="-L${scotch}/lib -lesmumps -lscotch -lscotcherr"
45-
'';
46-
macroFlags =
47-
"-Dmetis -Dpord -Dscotch"
48-
+ lib.optionalString withParmetis " -Dparmetis"
49-
+ lib.optionalString withPtScotch " -Dptscotch";
50-
# Optimized options
51-
# Disable -fopenmp in lines below to benefit from OpenMP
52-
optFlags = ''
53-
OPTF="-O3 -fallow-argument-mismatch" \
54-
OPTL="-O3" \
55-
OPTC="-O3"
56-
'';
33+
[
34+
"-lesmumps"
35+
"-lscotch"
36+
"-lscotcherr"
37+
]
38+
);
39+
ORDERINGSF = toString (
40+
[
41+
"-Dmetis"
42+
"-Dpord"
43+
"-Dscotch"
44+
]
45+
++ lib.optional withParmetis "-Dparmetis"
46+
++ lib.optional withPtScotch "-Dptscotch"
47+
);
5748
in
5849
stdenv.mkDerivation (finalAttrs: {
5950
name = "mumps";
6051
version = "5.7.3";
52+
# makeFlags contain space and one should use makeFlagsArray+
53+
# Setting this magic var is an optional solution
54+
__structuredAttrs = true;
6155

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

7771
enableParallelBuilding = true;
7872

79-
preBuild = ''
80-
makeFlagsArray+=(${metisFlags} ${scotchFlags} ORDERINGSF="${macroFlags}" ${optFlags})
81-
'';
82-
8373
makeFlags =
8474
lib.optionals stdenv.hostPlatform.isDarwin [
8575
"SONAME="
8676
"LIBEXT_SHARED=.dylib"
8777
]
8878
++ [
79+
"ISCOTCH=-I${scotch.dev}/include"
80+
"LMETIS=${LMETIS}"
81+
"LSCOTCH=${LSCOTCH}"
82+
"ORDERINGSF=${ORDERINGSF}"
83+
"OPTF=-O3 -fallow-argument-mismatch"
84+
"OPTC=-O3"
85+
"OPTL=-O3"
8986
"SCALAP=-lscalapack"
9087
"allshared"
9188
];
@@ -105,7 +102,7 @@ stdenv.mkDerivation (finalAttrs: {
105102

106103
nativeBuildInputs = [
107104
gfortran
108-
] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames ++ lib.optional mpiSupport mpi;
105+
] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
109106

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

0 commit comments

Comments
 (0)