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

openmpi: fix build on darwin #332983

Closed
wants to merge 5 commits into from
Closed
Changes from 4 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
49 changes: 27 additions & 22 deletions pkgs/development/libraries/openmpi/default.nix
Original file line number Diff line number Diff line change
@@ -112,26 +112,31 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ]
++ lib.optionals fortranSupport [ gfortran ];

configureFlags = [
(lib.enableFeature cudaSupport "mca-dso")
(lib.enableFeature fortranSupport "mpi-fortran")
(lib.withFeatureAs stdenv.isLinux "libnl" (lib.getDev libnl))
"--with-pmix=${if stdenv.isLinux then (lib.getDev pmix) else "internal"}"
(lib.withFeatureAs stdenv.isLinux "pmix-libdir" "${lib.getLib pmix}/lib")
# Puts a "default OMPI_PRTERUN" value to mpirun / mpiexec executables
(lib.withFeatureAs stdenv.isLinux "prrte" (lib.getBin prrte))
(lib.withFeature enableSGE "sge")
(lib.enableFeature enablePrefix "mpirun-prefix-by-default")
# TODO: add UCX support, which is recommended to use with cuda for the most robust OpenMPI build
# https://github.com/openucx/ucx
# https://www.open-mpi.org/faq/?category=buildcuda
(lib.withFeatureAs cudaSupport "cuda" (lib.getDev cudaPackages.cuda_cudart))
(lib.enableFeature cudaSupport "dlopen")
(lib.withFeatureAs fabricSupport "psm2" (lib.getDev libpsm2))
(lib.withFeatureAs fabricSupport "ofi" (lib.getDev libfabric))
# The flag --without-ofi-libdir is not supported from some reason, so we
# don't use lib.withFeatureAs
] ++ lib.optionals fabricSupport [ "--with-ofi-libdir=${lib.getLib libfabric}/lib" ];
configureFlags =
[
(lib.enableFeature cudaSupport "mca-dso")
(lib.enableFeature fortranSupport "mpi-fortran")
(lib.withFeatureAs stdenv.isLinux "libnl" (lib.getDev libnl))
# Puts a "default OMPI_PRTERUN" value to mpirun / mpiexec executables
(lib.withFeatureAs stdenv.isLinux "prrte" (lib.getBin prrte))
(lib.withFeature enableSGE "sge")
(lib.enableFeature enablePrefix "mpirun-prefix-by-default")
# TODO: add UCX support, which is recommended to use with cuda for the most robust OpenMPI build
# https://github.com/openucx/ucx
# https://www.open-mpi.org/faq/?category=buildcuda
(lib.withFeatureAs cudaSupport "cuda" (lib.getDev cudaPackages.cuda_cudart))
(lib.enableFeature cudaSupport "dlopen")
(lib.withFeatureAs fabricSupport "psm2" (lib.getDev libpsm2))
(lib.withFeatureAs fabricSupport "ofi" (lib.getDev libfabric))
# The flag --without-ofi-libdir is not supported from some reason, so we
# don't use lib.withFeatureAs
]
++ lib.optional fabricSupport "--with-ofi-libdir=${lib.getLib libfabric}/lib"
# The pmix flags should only be set when pmix is used
++ lib.optionals stdenv.isLinux [
"--with-pmix=${lib.getDev pmix}"
"--with-pmix-libdir=${lib.getLib pmix}/lib"
];

enableParallelBuilding = true;

@@ -188,7 +193,7 @@ stdenv.mkDerivation (finalAttrs: {
];
part2 = builtins.attrNames wrapperDataSubstitutions;
};
in
in lib.optionalString stdenv.isLinux
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to only condition the substitution and not all of the postInstall... We might enable multiple outputs in the future for other platforms, and you'd still want to delete all *.la files...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we need extra condition for the split output moves too. If we want to enable multiple outputs in the future for other platforms we can make it more granular later? I do not know what darwin does with .la files. I know that they are not needed on Linux.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we need extra condition for the split output moves too.

No you won't. That was the purpose of 2a4636b .

If we want to enable multiple outputs in the future for other platforms we can make it more granular later?

The diff will be much smaller thanks to 2a4636b .

I do not know what darwin does with .la files. I know that they are not needed on Linux.

Yea that line was peculiar to me so I didn't touch it.. I suspect they might be generated on Darwin as well, so I wouldn't touch it even now. For sure it doesn't hurt if these files are not found at all.

''
find $out/lib/ -name "*.la" -exec rm -f \{} \;

@@ -221,7 +226,7 @@ stdenv.mkDerivation (finalAttrs: {
))
(lib.concatStringsSep "\n")
]}
# A symlink to ${lib.getDev pmix}/bin/pmixcc upstreeam puts here as well
# A symlink to ''${lib.getDev pmix}/bin/pmixcc upstream puts here as well
# from some reason.
moveToOutput "bin/pcc" "''${!outputDev}"