conda-forge / msmpi-feedstock

A conda-smithy repository for msmpi.
BSD 3-Clause "New" or "Revised" License
1 stars 7 forks source link

Linking against msmpifec.lib/msmpi.lib from Fortran #18

Open jornbr opened 1 year ago

jornbr commented 1 year ago

I am working on a Python extension module that includes Fortran code with an MPI dependency. When built stand-alone on Windows (without conda), it is compiled with MS Visual Studio and Intel Fortran, and linked against Microsoft's own msmpifec.lib/msmpi.lib. These are detected automatically by cmake, which we use as basis for our build system. This all works fine.

Now we are in the process of migrating to conda distribution, and therefore are switching to conda-build. For our Windows distribution, we would like to build on top of the msmpi distributed via conda-forge. However, it seems the libraries (.lib) that are distributed with that are different from the ones MS provides - possibly because the msmpi feedstock builds from source? In particular, the combination msmpifec.lib/msmpi.lib no longer seems to contain all required symbols (at least not under the name expected by Intel Fortran), leading cmake to consider MPI broken. In fact, "dumpbin /symbols msmpifec.lib" seems to indicate that the msmpifec.lib created by the feedstock lacks the aliases (e.g., MPI_INIT) needed for Fortran linking. The MS original has entries like:

    Default index     1B80 Alias record
1B83 00000000 UNDEF  notype       External     | mpi_init_
1B84 00000000 UNDEF  notype       WeakExternal | MPI_INIT

but these seem absent in the msmpifec.lib distributed via conda-forge. Is this something that can be worked around (are these aliases perhaps in another of the .lib files included with the conda-forge msmpi distribution?) Or is msmpi on conda-forge broken in this respect (or simply not suitable for linking to from Intel Fortran?)

isuruf commented 1 year ago

For some reason MPI_INIT is marked private at https://github.com/microsoft/Microsoft-MPI/blob/7ff6bdcdb1d5dc7b791e47457ee2686cd6b3d355/src/mpi/msmpi/dll/msmpi.def#L2304. No idea why

jornbr commented 1 year ago

Not sure about that. But I suspect the MPI_INIT symbol is normally (in MS builds) added to msmpifec.lib by this: https://github.com/microsoft/Microsoft-MPI/blob/7ff6bdcdb1d5dc7b791e47457ee2686cd6b3d355/src/mpi/msmpi/fortran/amd64.cdecl.alias#L2346 Note sure why that does not happen in the feedstock build...