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

build: Error message when it needs -fallow-argument-mismatch #5811

Closed
mathrack opened this issue Jan 28, 2022 · 16 comments · Fixed by #5820
Closed

build: Error message when it needs -fallow-argument-mismatch #5811

mathrack opened this issue Jan 28, 2022 · 16 comments · Fixed by #5820

Comments

@mathrack
Copy link

AC_MSG_ERROR([The Fortran compiler $FC does not accept programs that call the same routine with arguments of different types without the option $addarg. Rerun configure with FCFLAGS=$addarg])

It might be helpful to replace Rerun configure with FCFLAGS=$addarg with Rerun configure with FFLAGS=$addarg and FCFLAGS=$addarg

@hzhou
Copy link
Contributor

hzhou commented Jan 28, 2022

MPICH now only need FC and FCFLAGS. Both F77 and FFLAGS are ignored. Did you encounter issues? What version of MPICH did you try?

@mathrack
Copy link
Author

mathrack commented Jan 28, 2022

I was compiling the last release of mpich-4.0 with gcc-11.2.0 :

../mpich-4.0/configure FCFLAGS=-fallow-argument-mismatch --prefix=/home/xxx/opt/mpich/mpich-4.0_bld --enable-debuginfo --with-device=ch4:ofi --enable-g=all

This leads to

checking whether gfortran allows mismatched arguments... yes, with -fallow-argument-mismatch
configure: error: The Fortran compiler gfortran does not accept programs that call the same routine with arguments of different types without the option -fallow-argument-mismatch.  Rerun configure with FFLAGS=-fallow-argument-mismatch
configure: error: ../../../mpich-4.0/test/mpi/configure failed for test/mpi

Using

../mpich-4.0/configure FFLAGS=-fallow-argument-mismatch FCFLAGS=-fallow-argument-mismatch --prefix=/home/xxx/opt/mpich/mpich-4.0_bld --enable-debuginfo --with-device=ch4:ofi --enable-g=all

does not produce any error

@hzhou
Copy link
Contributor

hzhou commented Jan 28, 2022

I see. That error is from configuring the test suite. The main branch detached the test suite from the main mpich configure, so it wouldn't be an issue anymore.

@raffenet We probably should patch the error message in the 4.0.x branch since the FFLAGS still matters there in the test/mpi/configure.

@raffenet
Copy link
Contributor

@raffenet We probably should patch the error message in the 4.0.x branch since the FFLAGS still matters there in the test/mpi/configure.

Will add it to the list of 4.0.x fixes needed.

@hzhou hzhou linked a pull request Feb 1, 2022 that will close this issue
4 tasks
@hzhou hzhou changed the title Error message when the Fortran compiler needs -fallow-argument-mismatch build: Error message when it needs -fallow-argument-mismatch Feb 1, 2022
@hzhou
Copy link
Contributor

hzhou commented Feb 4, 2022

This is fixed in the 4.0.x stable branch via PR #5820

@hzhou hzhou closed this as completed Feb 4, 2022
@dubf
Copy link

dubf commented Jul 17, 2022

Greetings MPICH team

I am trying to build mpich-4.0.2 from MacPorts, it is a dependency for the Octave math software I'm trying to install.
It always fails with the same error message given by the OP:

:info:configure checking whether /opt/local/bin/gfortran-mp-12 allows mismatched arguments... yes, with -fallow-argument-mismatch
:info:configure configure: error: The Fortran compiler /opt/local/bin/gfortran-mp-12 does not accept programs that call the same routine with arguments of different types without the option -fallow-argument-mismatch. Rerun configure with FFLAGS=-fallow-argument-mismatch and FCFLAGS=-fallow-argument-mismatch

I have tried adding these flags manually to the command as well as to several of the configure & make files (in the macports build directory: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_science_mpich/mpich-default/work/mpich-4.0.2), but none of it has worked. I even tried deleting the relevant code in the configure script, yet the error still happens.

As I have no experience whatsoever with cmake, I don't know what to do. I don't know where exactly these flags should be added, nor what syntax to use. What is the recommended solution for an error like this?

@hzhou
Copy link
Contributor

hzhou commented Jul 17, 2022

@dubf Try set environment variables

export FFLAGS=-fallow-argument-mismatch
export FCFLAGS=-fallow-argument-mismatch

@dubf
Copy link

dubf commented Jul 18, 2022

@hzhou Thanks a lot for your reply.

I had tried your suggestion in a similar way before; unfortunately it doesn't work. These are the last 11 lines of the main.log when I run sudo port install mpich:

:info:configure checking whether /opt/local/bin/gfortran-mp-12 allows mismatched arguments... yes, with -fallow-argument-mismatch
:info:configure configure: error: The Fortran compiler /opt/local/bin/gfortran-mp-12 does not accept programs that call the same routine with arguments of different types without the option -fallow-argument-mismatch. Rerun configure with FFLAGS=-fallow-argument-mismatch and FCFLAGS=-fallow-argument-mismatch
:info:configure Command failed: cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_science_mpich/mpich-default/work/mpich-4.0.2" && ./configure --prefix=/opt/local --disable-dependency-tracking --enable-fortran --disable-silent-rules --enable-base-cache --enable-cache --enable-cxx --enable-fast=O2 --enable-shared --enable-versioning --enable-timer-type=mach_absolute_time --with-pm=hydra --with-thread-package=posix --with-hwloc-prefix=/opt/local --disable-collalgo-tests --disable-f08 F90FLAGS='' F90='' --libdir=/opt/local/lib/mpich-mp --sysconfdir=/opt/local/etc/mpich-mp --program-suffix=-mpich-mp --includedir=/opt/local/include/mpich-mp MPICHLIB_CFLAGS="$CFLAGS" CFLAGS="" MPICHLIB_CPPFLAGS="$CPPFLAGS" CPPFLAGS="" MPICHLIB_CXXFLAGS="$CXXFLAGS" CXXFLAGS="" MPICHLIB_FFLAGS="$FFLAGS" FFLAGS="" MPICHLIB_FCFLAGS="$FCFLAGS" FCFLAGS=""
:info:configure Exit code: 1
:error:configure Failed to configure mpich-default: consult /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_science_mpich/mpich-default/work/mpich-4.0.2/config.log
:error:configure Failed to configure mpich-default: configure failure: command execution failed
:debug:configure Error code: NONE
:debug:configure Backtrace: configure failure: command execution failed
:debug:configure while executing
:debug:configure "$procedure $targetname"
:error:configure See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_science_mpich/mpich-default/main.log for details

I've attached main.log and config.log.

Two things have caught my attention:

  • main.log shows that MacPorts goes through 7 iterations of the whole process, failing with the same error each time.
  • Even though I have set the flags as demanded (which I tested by running echo $FFLAGS $FCFLAGS), the logs only print empty fields for these flags. Is configure not picking them up properly? Why not?

This leads me to ask two questions:

  • How to 'force' configure to recognize the flags?
  • Alternatively, can this check be turned off by removing its code from configure (or from any other of the source files)? Which code exactly would that be?

Thanks a lot for your support.

@raffenet
Copy link
Contributor

I had tried your suggestion in a similar way before; unfortunately it doesn't work. These are the last 11 lines of the main.log when I run sudo port install mpich:

You're environment settings are likely getting lost because of sudo. You could try doing sudo -E port install mpich to preserve the flags. I'm not sure if this will cause other issues with MacPorts, however.

@dubf
Copy link

dubf commented Jul 18, 2022

@raffenet Interesting idea, thanks for the input. It didn't make any difference though.

@hzhou
Copy link
Contributor

hzhou commented Jul 18, 2022

How about sudo FFLAGS=-fallow-argument-mismatch FCFLAGS=-fallow-argument-mismatch port install mpich?

@dubf
Copy link

dubf commented Jul 18, 2022

@hzhou Had tried that one already. Just confirmed it gives the same result.

@hzhou
Copy link
Contributor

hzhou commented Jul 18, 2022

Ahh, thanks. Apparently, macport always blindly overwrites user-set compiler flags. I took a look at their repository -- https://github.com/macports/macports-ports/blob/3dcd708af94761a0e313f4acdddf631cb4443a87/science/mpich/Portfile#L286-L293
They only check whether the C compiler is gcc-10 or gcc-11. In your case, the C compiler is clang, but gfortran is from gcc.
You may try build mpich with gcc. In a meanwhile, try file an issues against macports.

@dubf
Copy link

dubf commented Jul 18, 2022

@hzhou Thanks a lot for finding that out! I'll file an issue at MacPorts.

Could you tell me how exactly I replace clang with gcc for compiling?

@dubf
Copy link

dubf commented Jul 18, 2022

I just tried building it manually, using the options macports provided. Had to remove several flags which weren't recognized:
-isysroot
-stdlib
-arch
-m64

Added the flags:
FCFLAGS=-fallow-argument-mismatch
FFLAGS=-fallow-argument-mismatch
CC=/opt/local/bin/gcc-mp-12 (not sure if this is correct)

So this was the command used:
sudo ./configure --prefix=/opt/local --disable-dependency-tracking --enable-fortran --disable-silent-rules --enable-base-cache --enable-cache --enable-cxx --enable-fast=O2 --enable-shared --enable-versioning --enable-timer-type=mach_absolute_time --with-pm=hydra --with-thread-package=posix --with-hwloc-prefix=/opt/local --disable-collalgo-tests --disable-f08 F90FLAGS= F90= CC=/opt/local/bin/gcc-mp-12 --libdir=/opt/local/lib/mpich-mp --sysconfdir=/opt/local/etc/mpich-mp --program-suffix=-mpich-mp --includedir=/opt/local/include/mpich-mp MPICHLIB_CFLAGS=-pipe CFLAGS= MPICHLIB_CPPFLAGS= CPPFLAGS= MPICHLIB_CXXFLAGS=-pipe CXXFLAGS= MPICHLIB_FFLAGS=-pipe FFLAGS=-fallow-argument-mismatch MPICHLIB_FCFLAGS=-pipe FCFLAGS=-fallow-argument-mismatch

This seemed to work well, until it gave me the following error:

configure: error: No Fortran compiler found. If you don't need to
build any Fortran programs, you can disable Fortran support using
--disable-fortran. If you do want to build Fortran
programs, you need to install a Fortran compiler such as gfortran
or ifort before you can proceed.

This seems to confirm your hypothesis.

I then removed the F90 flag and added the flag:
FC=/opt/local/bin/gfortran-mp-12

Now it worked!

@dubf
Copy link

dubf commented Jul 19, 2022

@hzhou @raffenet
Reporting back:

  • Building mpich manually worked, but macports did not recognize it as installed (hardly a surprise), so it was no solution.
  • Was able to get macports to build mpich by modifying the portfile, thanks to @hzhou's hint.

I copied

  • configure.fflags-append -fallow-argument-mismatch
  • configure.fcflags-append -fallow-argument-mismatch

outside of the if-statement which tests for gcc-10 and gcc-11, since adding gcc-12 and clang did not help either.

The main.log shows that only after 27 failed iterations and 25k lines later, ./configure started debugging and added the FFLAGS and FCFLAGS properly. Possibly, the instruction which renames the regular compiler flags by appending MPICHLIB_ to restrict their range, results in the latter not working anymore.

Thanks for the support.

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

Successfully merging a pull request may close this issue.

4 participants