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

mpifort does not pass -I/usr/include to gfortran #12257

Open
lahwaacz opened this issue Jan 20, 2024 · 3 comments
Open

mpifort does not pass -I/usr/include to gfortran #12257

lahwaacz opened this issue Jan 20, 2024 · 3 comments

Comments

@lahwaacz
Copy link
Contributor

Background information

What version of Open MPI are you using? (e.g., v4.1.6, v5.0.1, git branch name and hash, etc.)

5.0.1

Describe how Open MPI was installed (e.g., from a source/distribution tarball, from a git clone, from an operating system distribution package, etc.)

Installation from source, using this PKGBUILD for Arch Linux: https://gitlab.archlinux.org/archlinux/packaging/packages/openmpi/-/blob/v5.0/PKGBUILD

Please describe the system on which you are running

  • Operating system/version: Arch Linux
  • Computer hardware: x86_64
  • Network type:

Details of the problem

mpif77, mpif90 and mpifort do not pass the -I/usr/include flag to gfortran, which is necessary for finding mpif.h. Multiple other packages like arpack then fail to configure, because include 'mpif.h' in test programs does not work.

$ mpifort --showme
gfortran -I/usr/lib -Wl,-rpath -Wl,/usr/lib -Wl,--enable-new-dtags -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi

This output was different with openmpi-4.1.6 on the same system, built with a very similar PKGBUILD:

$ mpifort --showme
gfortran -I/usr/include -I/usr/lib -Wl,-rpath -Wl,/usr/lib -Wl,--enable-new-dtags -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi
@lahwaacz
Copy link
Contributor Author

lahwaacz commented Jan 21, 2024

I found this in the configure log for openmpi-4.1.6:

*** Wrapper compiler final setup
checking for perl... /usr/bin/perl
checking if linker supports RPATH... yes (-Wl,-rpath -Wl,LIBDIR + -Wl,-rpath -Wl,LIBDIR)
checking if linker supports RUNPATH... yes (-Wl,--enable-new-dtags)
yes (-Wl,--enable-new-dtags)
checking for OPAL CPPFLAGS...    
checking for OPAL CFLAGS...  
checking for OPAL CFLAGS_PREFIX... 
checking for OPAL CXXFLAGS...  
checking for OPAL CXXFLAGS_PREFIX... 
checking for OPAL LDFLAGS...    -Wl,-rpath -Wl,@{libdir}  -Wl,--enable-new-dtags
checking for OPAL pkg-config LDFLAGS...    -Wl,-rpath -Wl,${libdir}  -Wl,--enable-new-dtags
checking for OPAL LIBS... -lhwloc -levent_core -levent_pthreads -lm 
checking for ORTE CPPFLAGS...    
checking for ORTE CFLAGS...  
checking for ORTE CFLAGS_PREFIX... 
checking for ORTE LDFLAGS...    -Wl,-rpath -Wl,@{libdir}  -Wl,--enable-new-dtags
checking for ORTE pkg-config LDFLAGS...    -Wl,-rpath -Wl,${libdir}  -Wl,--enable-new-dtags
checking for ORTE LIBS... -lhwloc -levent_core -levent_pthreads -lm 
checking for OMPI CPPFLAGS...    
checking for OMPI CFLAGS...  
checking for OMPI CFLAGS_PREFIX... 
checking for OMPI CXXFLAGS...  
checking for OMPI CXXFLAGS_PREFIX... 
checking for OMPI FCFLAGS...   -I${libdir}
checking for OMPI FCFLAGS_PREFIX... 
checking for OMPI LDFLAGS...    -Wl,-rpath -Wl,@{libdir}  -Wl,--enable-new-dtags
checking for OMPI pkg-config LDFLAGS...    -Wl,-rpath -Wl,${libdir}  -Wl,--enable-new-dtags
checking for OMPI LIBS... -lhwloc -levent_core -levent_pthreads -lm  -lz
checking if libtool needs -no-undefined flag to build shared libraries... no

And for openmpi-5.0.1:

*** Wrapper compiler final setup
checking for perl... /usr/bin/perl
checking if linker supports RPATH... yes (-Wl,-rpath -Wl,LIBDIR + -Wl,-rpath -Wl,LIBDIR)
checking if linker supports RUNPATH... yes (-Wl,--enable-new-dtags)
checking if Fortran linker supports RUNPATH... yes (-Wl,--enable-new-dtags)
checking for OPAL wrapper CPPFLAGS... -I${includedir}
checking for OPAL wrapper CFLAGS...  
checking for OPAL wrapper CFLAGS_PREFIX... 
checking for OPAL wrapper CXXFLAGS...  
checking for OPAL wrapper CXXFLAGS_PREFIX... 
checking for OPAL wrapper LDFLAGS... -L${libdir}  -Wl,-rpath -Wl,${libdir} -Wl,--enable-new-dtags
checking for OPAL wrapper static LDFLAGS...  
checking for OPAL wrapper LIBS... -lopen-pal
checking for OPAL wrapper static LIBS... 
checking for OMPI wrapper CPPFLAGS... -I${includedir}
checking for OMPI wrapper CFLAGS...  
checking for OMPI wrapper CFLAGS_PREFIX... 
checking for OMPI wrapper CXXFLAGS...  
checking for OMPI wrapper CXXFLAGS_PREFIX... 
checking for OMPI wrapper FCFLAGS... 
checking for OMPI wrapper FCFLAGS_PREFIX... 
checking for OMPI wrapper LDFLAGS... -L${libdir}  -Wl,-rpath -Wl,${libdir} -Wl,--enable-new-dtags
checking for OMPI wrapper static LDFLAGS...  
checking for OMPI wrapper LIBS... -lmpi
checking for OMPI wrapper static LIBS... 
checking for OMPI wrapper Fortran LDFLAGS... -L${libdir}  -Wl,-rpath -Wl,${libdir} -Wl,--enable-new-dtags
checking for OMPI wrapper Fortran static LDFLAGS...  
checking for OMPI wrapper Fortran LIBS... -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi
checking for OMPI wrapper Fortran static LIBS... 
checking for OMPI pkg-config Cflags... -I${includedir}
checking for OMPI pkg-config Libs... -L${libdir} -Wl,-rpath -Wl,${libdir} -Wl,--enable-new-dtags -lmpi
checking for OMPI pkg-config Libs.private... 
checking for OMPI pkg-config Fortran Cflags... -I${includedir} -I${libdir}
checking for OMPI pkg-config Fortran Libs... -L${libdir} -Wl,-rpath -Wl,${libdir} -Wl,--enable-new-dtags -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi
checking for OMPI pkg-config Fortran Libs.private... -L${libdir} -Wl,-rpath -Wl,${libdir}
checking for OMPI pkg-config Modules... 
checking for OMPI pkg-config Modules.private... 
checking for OSHMEM wrapper CPPFLAGS... -I${includedir}
checking for OSHMEM wrapper CFLAGS...  
checking for OSHMEM wrapper CFLAGS_PREFIX... 
checking for OSHMEM wrapper CXXFLAGS...  
checking for OSHMEM wrapper CXXFLAGS_PREFIX... 
checking for OSHMEM wrapper FCFLAGS... 
checking for OSHMEM wrapper FCFLAGS_PREFIX... 
checking for OSHMEM wrapper LDFLAGS... -L${libdir}  -Wl,-rpath -Wl,${libdir} -Wl,--enable-new-dtags
checking for OSHMEM wrapper static LDFLAGS...  
checking for OSHMEM wrapper LIBS... -loshmem -lmpi
checking for OSHMEM wrapper static LIBS... 
checking for OSHMEM wrapper Fortran LDFLAGS... -L${libdir}  -Wl,-rpath -Wl,${libdir} -Wl,--enable-new-dtags
checking for OSHMEM wrapper Fortran static LDFLAGS... -L${libdir}  -Wl,-rpath -Wl,${libdir}
checking for OSHMEM wrapper Fortran LIBS... -loshmem -lmpi_mpifh -loshmem -lmpi
checking for OSHMEM wrapper Fortran static LIBS... 
checking for OSHMEM pkg-config Cflags... -I${includedir}
checking for OSHMEM pkg-config Libs... -L${libdir} -Wl,-rpath -Wl,${libdir} -Wl,--enable-new-dtags -loshmem -lmpi
checking for OSHMEM pkg-config Libs.private... 
checking for OSHMEM pkg-config Fortran Cflags... 
checking for OSHMEM pkg-config Fortran Libs... -L${libdir} -Wl,-rpath -Wl,${libdir} -Wl,--enable-new-dtags -loshmem -lmpi_mpifh -loshmem -lmpi
checking for OSHMEM pkg-config Fortran Libs.private... -L${libdir} -Wl,-rpath -Wl,${libdir}
checking for OSHMEM pkg-config Modules... 
checking for OSHMEM pkg-config Modules.private... 
checking if libtool needs -no-undefined flag to build shared libraries... no

Notice that OMPI wrapper FCFLAGS... is empty.

@lahwaacz
Copy link
Contributor Author

There are 4 wrong variables in config/opal_setup_wrappers.m4:

  • OMPI_WRAPPER__FCFLAGS should be OMPI_WRAPPER_FCFLAGS
  • OMPI_WRAPPER_EXTRA_FCFLAGS should be OMPI_WRAPPER_FCFLAGS
  • OSHMEM_WRAPPER__FCFLAGS should be OSHMEM_WRAPPER_FCFLAGS
  • OSHMEM_WRAPPER_EXTRA_FCFLAGS should be OSHMEM_WRAPPER_FCFLAGS

However, even when I replaced them and rebuilt openmpi-5.0.1, I still get the same behavior from mpifort. ☹️

@lahwaacz
Copy link
Contributor Author

It seems that the problem is caused by 5d23e02#diff-98a0024d9e806a84ffa059b82e4b1a6839c957e41dc7d16e692d09723d070bcaR62 which is used in the filter_flags function to explicitly remove -I/usr/include from the flags configured for a wrapper: 5d23e02#diff-98a0024d9e806a84ffa059b82e4b1a6839c957e41dc7d16e692d09723d070bcaR348-R355

Omitting -I/usr/include works for C/C++ wrappers that call e.g. gcc/g++, but it does not work for the Fortran wrappers (at least with gfortran as the backend).

@bwbarrett can you comment on this as the author of the commit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant