Repository: spack/spack

Issue:
Installation issue: mpich
<!-- Thanks for taking the time to report this build failure. To proceed with the report please:

1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->

This issue is related to https://github.com/spack/spack/issues/16913, but for macOS (clang).
And can be fixed by extending/duplicating the fix for compiler `gcc@10:` to `apple-clang@11:`.

### Steps to reproduce the issue

<!-- Fill in the exact spec you are trying to build and the relevant part of the error message -->
```console
$ spack install mpich
==> Warning: apple-clang@11.0.3 cannot build optimized binaries for "skylake". Using best target possible: "x86_64"
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/libsigsegv-2.12-cd2u6jt6oagbnhsgqal54myovfkwpri6
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/berkeley-db-18.1.40-3f4556kvgg2ihsahtuy4ta27i65hnikf
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/pkgconf-1.7.3-52kfpvjixcntquvt67sltjuajdhq73od
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/libiconv-1.16-2owd6xnxysuqdfuuu4mgemxmdhgto4px
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/xz-5.2.5-nfsvq5xchnmyvqc333p644ouuwnk7awe
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/zlib-1.2.11-7erteezzqncanvj4cr4lesgcawuztojo
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/m4-1.4.18-anoponiwofd7dqkxmcqy6iq6ildhe5s2
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/ncurses-6.2-wr2lahob7rnaawch75w2p5rce4qk3qul
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/libxml2-2.9.10-cvsddxrqg4jwdgk2xopykzztgwwypl3f
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/libtool-2.4.6-yrvttuduwubr6aebtif4ezrllojrfi7i
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/readline-8.0-mtiikfoyt34p7bvxqz3talk7xv5azul4
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/hwloc-2.2.0-ox7oz3tzcswqhmvo2urhb76oeum7ntpo
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/gdbm-1.18.1-aaqin73b6t3wbxht7pdtw3ozteqmecd2
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/perl-5.30.3-7aafes7kqahuojjmxcqtwdezuqh74ya4
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/texinfo-6.5-bpmdlwfjdbg3dynlm5hjtnhtohpcaqyy
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/autoconf-2.69-caqezswjz5nwgqaxltqjnk25qjsuszfo
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/automake-1.16.2-2ug6frtywzpnmtbh2uji4pllbcgbbeoy
[+] /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/findutils-4.6.0-2swrp2onomc2norjkbmshw5xajlxrerw
==> Installing mpich
==> No binary for mpich found: installing from source
==> Warning: microarchitecture specific optimizations are not supported yet on mixed compiler toolchains [check apple-clang@11.0.3 for further details]
==> mpich: Executing phase: 'autoreconf'
==> mpich: Executing phase: 'configure'
==> Error: ProcessError: Command exited with status 1:
    '/var/folders/5p/x7ftfty12yndrs3p6ntlk1jc0000gp/T/LDianaAmorim/spack-stage/spack-stage-mpich-3.3.2-fntycc6dcg327z5dy3sboxudvldscpxe/spack-src/configure' '--prefix=/Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/mpich-3.3.2-fntycc6dcg327z5dy3sboxudvldscpxe' '--disable-silent-rules' '--enable-shared' '--with-hwloc-prefix=/Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/hwloc-2.2.0-ox7oz3tzcswqhmvo2urhb76oeum7ntpo' '--with-pm=hydra' '--enable-romio' '--without-ibverbs' '--enable-wrapper-rpath=yes' '--with-slurm=no' '--with-pmi=simple' '--with-device=ch3:nemesis:tcp' '--enable-libxml2'

1 error found in build log:
     963    checking for shared library (esp. rpath) characteristics of F77... done (results in src/env/f77_shlib.conf)
     964    checking whether Fortran 77 accepts ! for comments... yes
     965    checking for include directory flag for Fortran... -I
     966    checking for Fortran 77 flag for library directories... -L
     967    checking whether Fortran 77 compiler processes .F files with C preprocessor... yes
     968    checking whether /Users/LDianaAmorim/Documents/opt/spack/lib/spack/env/clang/gfortran allows mismatched arguments... no
  >> 969    configure: error: The Fortran compiler /Users/LDianaAmorim/Documents/opt/spack/lib/spack/env/clang/gfortran will not compile files that call
     970    the same routine with arguments of different types.

See build log for details:
  /var/folders/5p/x7ftfty12yndrs3p6ntlk1jc0000gp/T/LDianaAmorim/spack-stage/spack-stage-mpich-3.3.2-fntycc6dcg327z5dy3sboxudvldscpxe/spack-build-out.txt
```

### Information on your system

<!-- Please include the output of `spack debug report` -->
```console
$ spack debug report
* **Spack:** 0.15.3-421-c83236d3a
* **Python:** 3.7.3
* **Platform:** darwin-catalina-skylake
```

* clang version: 11.0.3
* gcc (gfortran) version: 10.2.0
* cmake version: 3.18.1

<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

```console
$ cat ~/.spack/darwin/packages.yaml
packages:
  cmake:
    buildable: False
    paths:
      cmake@3.18.1: /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/cmake-3.18.1-u4guucbahyuq5pswf55b2ebqslsjub7m
```

```console
$ % cat ~/.spack/darwin/compilers.yaml 
compilers:
- compiler:
    spec: apple-clang@11.0.3
    paths:
      cc: /usr/bin/clang
      cxx: /usr/bin/clang++
      f77: /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/gcc-10.2.0-phyqkhktab6nxd2noi3kklzjxsnku5le/bin/gfortran
      fc: /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/gcc-10.2.0-phyqkhktab6nxd2noi3kklzjxsnku5le/bin/gfortran
    flags: {}
    operating_system: catalina
    target: x86_64
    modules: []
    environment: {}
    extra_rpaths: []
- compiler:
    spec: gcc@10.2.0
    paths:
      cc: /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/gcc-10.2.0-phyqkhktab6nxd2noi3kklzjxsnku5le/bin/gcc
      cxx: /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/gcc-10.2.0-phyqkhktab6nxd2noi3kklzjxsnku5le/bin/g++
      f77: /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/gcc-10.2.0-phyqkhktab6nxd2noi3kklzjxsnku5le/bin/gfortran
      fc: /Users/LDianaAmorim/Documents/opt/spack/opt/spack/darwin-catalina-x86_64/apple-clang-11.0.3/gcc-10.2.0-phyqkhktab6nxd2noi3kklzjxsnku5le/bin/gfortran
    flags: {}
    operating_system: catalina
    target: x86_64
    modules: []
    environment: {}
    extra_rpaths: []
```

### Additional information

<!-- Please upload the following files. They should be present in the stage directory of the failing build. Also upload any config.log or similar file if one exists. -->

* [spack-build-env.txt](https://github.com/spack/spack/files/5042787/spack-build-env.txt)
* [spack-build-out.txt](https://github.com/spack/spack/files/5042788/spack-build-out.txt)
* [spack-configure-args.txt](https://github.com/spack/spack/files/5042789/spack-configure-args.txt)

<!-- Some packages have maintainers who have volunteered to debug build failures. Run `spack maintainers <name-of-the-package>` and @mention them here if they exist. -->

### General information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [x] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [x] I have run `spack maintainers <name-of-the-package>` and @mentioned any maintainers
- [x] I have uploaded the build log and environment files
- [x] I have searched the issues of this repo and believe this is not a duplicate



Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/mpich/package.py b/var/spack/repos/builtin/packages/mpich/package.py
--- a/var/spack/repos/builtin/packages/mpich/package.py
+++ b/var/spack/repos/builtin/packages/mpich/package.py
@@ -181,6 +181,9 @@ def setup_build_environment(self, env):
         # https://bugzilla.redhat.com/show_bug.cgi?id=1795817
         if self.spec.satisfies('%gcc@10:'):
             env.set('FFLAGS', '-fallow-argument-mismatch')
+        # Same fix but for macOS - avoids issue #17934
+        if self.spec.satisfies('%apple-clang@11:'):
+            env.set('FFLAGS', '-fallow-argument-mismatch')
 
     def setup_run_environment(self, env):
         # Because MPI implementations provide compilers, they have to add to


Test patch: