Bug 91731

Summary: Configure error on building MPICH
Product: gcc Reporter: Damian Rouson <damian>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: kargls, keroro.90, tkoenig
Priority: P4    
Version: 10.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Damian Rouson 2019-09-11 01:28:03 UTC
Below is the trailing output of configuring MPICH 3.2, 3.2.1, or 3.3.1 with the current GCC trunk: 

configure: error: The Fortran compiler /opt/gnu/10.0.0/bin/gfortran will not compile files that call the same routine with arguments of different types.


I imagine this might be solved by adding the -fallow-argument-mismatch argument enabled by the gfortran patch posted at https://gcc.gnu.org/ml/fortran/2019-08/msg00118.html so possibly this can be closed once that patch hits the trunk. Does GCC 9 have the same issue.  If so, could the patch be backported to the 9 branch?  Is this indicative of non-standard code in MPICH? 

Damian
Comment 1 kargls 2019-09-11 03:04:52 UTC
(In reply to Damian Rouson from comment #0)
> Below is the trailing output of configuring MPICH 3.2, 3.2.1, or 3.3.1 with
> the current GCC trunk: 
> 
> configure: error: The Fortran compiler /opt/gnu/10.0.0/bin/gfortran will not
> compile files that call the same routine with arguments of different types.
> 
> 
> I imagine this might be solved by adding the -fallow-argument-mismatch
> argument enabled by the gfortran patch posted at
> https://gcc.gnu.org/ml/fortran/2019-08/msg00118.html so possibly this can be
> closed once that patch hits the trunk. Does GCC 9 have the same issue.  If
> so, could the patch be backported to the 9 branch?  Is this indicative of
> non-standard code in MPICH? 

This is not a gfortran problem.  MPICH needs to provide proper
INTERFACEs for its functions that take 'void *' argument.
Comment 2 Thomas Koenig 2019-09-11 09:08:22 UTC
See PR 91556.  In the meantime, use -fallow-argument-mismatch .

I am working on a better error message.

*** This bug has been marked as a duplicate of bug 91556 ***
Comment 3 Damian Rouson 2019-09-11 22:36:20 UTC
So do I need to report this to the MPICH developers or is a gfortran bug?  I tried "-w -fallow-argument-mismatch" and got the same error message.
Comment 4 Steve Kargl 2019-09-11 23:50:41 UTC
On Wed, Sep 11, 2019 at 10:36:20PM +0000, damian at sourceryinstitute dot org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91731
> 
> --- Comment #3 from Damian Rouson <damian at sourceryinstitute dot org> ---
> So do I need to report this to the MPICH developers or is a gfortran bug?  I
> tried "-w -fallow-argument-mismatch" and got the same error message.
> 

With mpich-3.3.1, I do
 
% setenv PATH ~/work/x/bin:$PATH    # set path to find gfortran 10
% setenv FFLAGS "-w -fallow-argument-mismatch -O2"
% ./configure |& tee sgk.log
% grep mismatched sgk.log
checking whether gfortran allows mismatched arguments... yes
checking whether gfortran allows mismatched arguments... yes
% make -j5
% grep mismatch src/env/*
src/env/mpif77.bash:final_fflags=" -w -fallow-argument-mismatch -O2"
src/env/mpif77.sh:final_fflags=" -w -fallow-argument-mismatch -O2"

works for me.

I suppose that someone should file a bug report with MPICH
developers to alert them to gfortran's ability to detect
argument mismatches in 10.0.0 (aka 10.1 when released).  They
should be able to 1) fix configure to detect 10 or newer
versions to add the appropriate options; and 2) fix their 
broken code.   

PS: Frankly, I'm shocked to see that mpich defaults to only F77 in 2019.
Comment 5 Damian Rouson 2019-09-12 00:14:27 UTC
MPICH must find ISO_Fortran_binding.h in order to build the modern Fortran bindings that the MPI standard provides through the "mpi_f08" Fortran module.  Gfortran only started providing ISO_Fortran_binding.h in release 9.1.  In fact, ISO_Fortran_binding.h was primarily motivated by the need for modern MPI bindings.  Hopefully someone on the MPICH project will implement more modern bindings now.  I'll ask when I report this.
Comment 6 Damian Rouson 2019-09-12 01:06:12 UTC
Steve, I'm so incredibly glad you posted the details of your workaround.   Thank you! I had seen the FCFLAG environment variable, but I hadn't noticed the FFLAG variable listed just a few lines lower in the output of "configure --help".  I was pulling my hair out until I noticed that one extra character!

Also, what is -w doing? From your message on the email list, I'm guessing it converts an error message to a warning.  Is it needed with -fallow-argument-mismatch?  I don't find -w in the output of "gfortran --help" and I don't see it mentioned in gfortran's online documentation at https://gcc.gnu.org/onlinedocs/gfortran/Option-Summary.html.
Comment 7 Steve Kargl 2019-09-12 02:04:25 UTC
On Thu, Sep 12, 2019 at 01:06:12AM +0000, damian at sourceryinstitute dot org wrote:
> 
> --- Comment #6 from Damian Rouson <damian at sourceryinstitute dot org> ---
> Steve, I'm so incredibly glad you posted the details of your workaround.  
> Thank you! I had seen the FCFLAG environment variable, but I hadn't
> noticed the
> FFLAG variable listed just a few lines lower in the output of "configure
> --help".  I was pulling my hair out until I noticed that one extra character!
> 
> Also, what is -w doing? From your message on the email list, I'm guessing it

-w suppresses all warnings.  It is the only way (intentionally!) to
suppress the argument mismatch warning.

> converts an error message to a warning.  Is it needed with
> -fallow-argument-mismatch?

-fallow-argument-mismatch degrades the error to a warning.

> I don't find -w in the output of "gfortran --help"

It's a general gcc option.  Look in gcc.info.

> and I don't see it mentioned in gfortran's online documentation at
> https://gcc.gnu.org/onlinedocs/gfortran/Option-Summary.html.

General gcc options are not documented in the gfortran.info file.

I don't use mpich, but poking around in its scripts, I think 
that mpifort is the general script to compile a Fortran program.
This script does not honor FFLAGS.
Comment 8 Alessio 2020-05-13 12:57:19 UTC
Steve workaround also worked for me (Fedora 32 + MPICH).
I just had to replace setenv with export as follows:
export PATH="~/work/x/bin:$PATH"   
export FFLAGS="-w -fallow-argument-mismatch -O2"

Hope this helps.