Closed dionhaefner closed 2 years ago
@minrk This looks like an issue related to path relocation. mpi4py installs a mpi.cfg
text file as package data, and the paths in that file are not being updated. Should the recipe use build/has_prefix_files
to list that particular file? I don't get why this is happening only on macOS.
It has to do with peculiarities of openmpi and cross compilation. There shouldn't be any references to the build environment. Normally, mpicxx is only in the host environment (this is true in all cases except cross-compiled openmpi). References to the host environment are rewritten for relocatability, but any reference to the build environment in the installed files (even before packaging) is incorrect.
To add to @minrk's comment, this only happens when cross-compiling because we need MPI to exist in both build and host envs, and so only osx-arm64 has the issue (#31).
any reference to the build environment in the installed files (even before packaging) is incorrect.
Sorry, I'm a bit confused. Is this an mpi4py issue (because it stores the absolute path to mpicc
at build time), or a recipe/build-script issue in the mpi4py-feedstock
, or a conda-build
problem?.
I tend to think it's something mpi4py should fix -- when dumping the path to mpicc
etc to mpi.cfg
it should use the host env's paths, so that conda-build
can take over when rewriting the paths. But I don't know how feasible this is or if it makes sense at all, since by definition users should not use the returned mpicc
paths given it's cross-compiled...
I tend to think it's something mpi4py should fix
Well, mpi4py picks the first mpicc
command it finds in $PATH
at build time. That's what makes sense if you pip install mpi4py
. Upstream should not have to accommodate for the details of downstream build/packaging systems. At best, we can add a fix in the recipe's build script to replace the build path with the host path. But I have the feeling that this is a conda-build issue: why isn't the build path considered for relocation?
May I interject and ask why this is only an issue for OpenMPI and not for MPICH? Is mpi4py not cross-compiled with MPICH?
Is this an mpi4py issue (because it stores the absolute path to mpicc at build time), or a recipe/build-script issue in the mpi4py-feedstock, or a conda-build problem?.
It's mostly a recipe issue, though arguably an mpi4py issue that it's not overrideable (if indeed it's not). There shouldn't be any references to the build environment in what's installed. conda-build could paper over these with likely fixes (replace build prefix with host), but they shouldn't generally happen. It also wouldn't work correctly if it were found in a binary file, because the build prefix doesn't get the same padding as the host prefix.
In general, it's not a safe assumption of packages to record where things were at build time as translatable to where they should be at runtime. Anything where you are recording the build environment like this should support an explicit override to tell the file where they will be at runtime, otherwise it's a problem for relocation.
why this is only an issue for OpenMPI and not for MPICH
The short answer is that mpicc is only in the build environment for openmpi + cross compiling.
The reason that's the case is that in mpich mpicc
is a script that configures $CC, whereas openmpi's mpicc
is an executable so it needs to match the build architecture and not the target architecture. That's why only openmpi needs to be in the build environment for cross compilation and not mpich.
sed
.Arguably, the same issue is in mpi4jax where the mpicc is not overrideable. Respecting e.g. $MPICC as an override for the mpi compiler to use would solve the problem there, too.
Thanks for the quick fix and advice. I think introducing that environment variable is a good idea.
Solution to issue cannot be found in the documentation.
Issue
Example:
This is only the case on osx-arm64, all other platforms work as intended.
Installed packages
Environment info