Skip to content

Commit 403ba18

Browse files
authored
openmpi: fix wrapperData on darwin platform (NixOS#389036)
2 parents aeb3f4d + b0a8604 commit 403ba18

File tree

2 files changed

+34
-39
lines changed

2 files changed

+34
-39
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,5 @@ stdenv.mkDerivation (finalAttrs: {
147147
qbisi
148148
];
149149
platforms = lib.platforms.unix;
150-
# Dependency of scalapack for mpiSupport is broken on darwin platform
151-
broken = mpiSupport && stdenv.hostPlatform.isDarwin;
152150
};
153151
})

pkgs/by-name/op/openmpi/package.nix

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ stdenv.mkDerivation (finalAttrs: {
8585
SOURCE_DATE_EPOCH = "0";
8686
};
8787

88-
outputs =
89-
[ "out" ]
90-
++ lib.optionals stdenv.hostPlatform.isLinux [
91-
"man"
92-
"dev"
93-
];
88+
outputs = [
89+
"out"
90+
"man"
91+
"dev"
92+
];
9493

9594
buildInputs =
9695
[
@@ -152,14 +151,16 @@ stdenv.mkDerivation (finalAttrs: {
152151
# The file names we need to iterate are a combination of ${p}${s}, and there
153152
# are 7x3 such options. We use lib.mapCartesianProduct to iterate them all.
154153
fileNamesToIterate = {
155-
p = [
156-
"mpi"
157-
"shmem"
158-
"osh"
159-
];
154+
p =
155+
[
156+
"mpi"
157+
]
158+
++ lib.optionals stdenv.hostPlatform.isLinux [
159+
"shmem"
160+
"osh"
161+
];
160162
s =
161163
[
162-
"CC"
163164
"c++"
164165
"cxx"
165166
"cc"
@@ -168,20 +169,25 @@ stdenv.mkDerivation (finalAttrs: {
168169
"f77"
169170
"f90"
170171
"fort"
171-
];
172+
]
173+
++ lib.optionals stdenv.hostPlatform.isLinux [ "CC" ];
172174
};
173175
wrapperDataSubstitutions =
174176
{
175177
# The attr key is the filename prefix. The list's 1st value is the
176178
# compiler=_ line that should be replaced by a compiler=#2 string, where
177179
# #2 is the 2nd value in the list.
178180
"cc" = [
179-
"gcc"
180-
"${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc"
181+
# "$CC" is expanded by the executing shell in the substituteInPlace
182+
# commands to the name of the compiler ("clang" for Darwin and
183+
# "gcc" for Linux)
184+
"$CC"
185+
"${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}$CC"
181186
];
182187
"c++" = [
183-
"g++"
184-
"${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}c++"
188+
# Same as with $CC
189+
"$CXX"
190+
"${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}$CXX"
185191
];
186192
}
187193
// lib.optionalAttrs fortranSupport {
@@ -198,8 +204,7 @@ stdenv.mkDerivation (finalAttrs: {
198204
wrapperDataFileNames = {
199205
part1 = [
200206
"mpi"
201-
"shmem"
202-
];
207+
] ++ lib.optionals stdenv.hostPlatform.isLinux [ "shmem" ];
203208
part2 = builtins.attrNames wrapperDataSubstitutions;
204209
};
205210
in
@@ -226,12 +231,7 @@ stdenv.mkDerivation (finalAttrs: {
226231
${lib.pipe wrapperDataFileNames [
227232
(lib.mapCartesianProduct (
228233
{ part1, part2 }:
229-
# From some reason the Darwin build doesn't include some of these
230-
# wrapperDataSubstitutions strings and even some of the files. Hence
231-
# we currently don't perform these substitutions on other platforms,
232-
# until a Darwin user will care enough about this cross platform
233-
# related substitution.
234-
lib.optionalString stdenv.hostPlatform.isLinux ''
234+
''
235235
substituteInPlace "''${!outputDev}/share/openmpi/${part1}${part2}-wrapper-data.txt" \
236236
--replace-fail \
237237
compiler=${lib.elemAt wrapperDataSubstitutions.${part2} 0} \
@@ -250,19 +250,16 @@ stdenv.mkDerivation (finalAttrs: {
250250
done
251251
'';
252252

253-
postFixup =
254-
lib.optionalString (lib.elem "man" finalAttrs.outputs) ''
255-
remove-references-to -t "''${!outputMan}" $(readlink -f $out/lib/libopen-pal${stdenv.hostPlatform.extensions.library})
256-
''
257-
+ lib.optionalString (lib.elem "dev" finalAttrs.outputs) ''
258-
remove-references-to -t "''${!outputDev}" $out/bin/mpirun
259-
remove-references-to -t "''${!outputDev}" $(readlink -f $out/lib/libopen-pal${stdenv.hostPlatform.extensions.library})
253+
postFixup = ''
254+
remove-references-to -t "''${!outputMan}" $(readlink -f $out/lib/libopen-pal${stdenv.hostPlatform.extensions.library})
255+
remove-references-to -t "''${!outputDev}" $out/bin/mpirun
256+
remove-references-to -t "''${!outputDev}" $(readlink -f $out/lib/libopen-pal${stdenv.hostPlatform.extensions.library})
260257
261-
# The path to the wrapper is hard coded in libopen-pal.so, which we just cleared.
262-
wrapProgram "''${!outputDev}/bin/opal_wrapper" \
263-
--set OPAL_INCLUDEDIR "''${!outputDev}/include" \
264-
--set OPAL_PKGDATADIR "''${!outputDev}/share/openmpi"
265-
'';
258+
# The path to the wrapper is hard coded in libopen-pal.so, which we just cleared.
259+
wrapProgram "''${!outputDev}/bin/opal_wrapper" \
260+
--set OPAL_INCLUDEDIR "''${!outputDev}/include" \
261+
--set OPAL_PKGDATADIR "''${!outputDev}/share/openmpi"
262+
'';
266263

267264
doCheck = true;
268265

0 commit comments

Comments
 (0)