Repository: spack/spack

Issue:
Installation issue: py-mpi4py
### Steps to reproduce the issue

```console
$ spack spec -I py-mpi4py
Input spec
--------------------------------
 -   py-mpi4py

Concretized
--------------------------------
 -   py-mpi4py@3.1.4%apple-clang@15.0.0 build_system=python_pip arch=darwin-sonoma-m1
[+]      ^openmpi@4.1.6%apple-clang@15.0.0~atomics~cuda~cxx~cxx_exceptions~gpfs~internal-hwloc~internal-pmix~java~legacylaunchers~lustre~memchecker~openshmem~orterunprefix+romio+rsh~singularity+static+vt+wrapper-rpath build_system=autotools fabrics=none schedulers=none arch=darwin-sonoma-m1
[e]          ^gmake@3.81%apple-clang@15.0.0~guile build_system=generic patches=ca60bd9 arch=darwin-sonoma-m1
[+]          ^gnuconfig@2022-09-17%apple-clang@15.0.0 build_system=generic arch=darwin-sonoma-m1
[+]          ^hwloc@2.9.1%apple-clang@15.0.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl~pci~rocm build_system=autotools libs=shared,static arch=darwin-sonoma-m1
[+]              ^libxml2@2.10.3%apple-clang@15.0.0+pic~python+shared build_system=autotools arch=darwin-sonoma-m1
[e]          ^openssh@9.5p1%apple-clang@15.0.0+gssapi build_system=autotools patches=3505c58,d886b98 arch=darwin-sonoma-m1
[+]          ^perl@5.38.0%apple-clang@15.0.0+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=darwin-sonoma-m1
[+]              ^berkeley-db@18.1.40%apple-clang@15.0.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=darwin-sonoma-m1
[e]          ^pkg-config@0.29.2%apple-clang@15.0.0+internal_glib build_system=autotools arch=darwin-sonoma-m1
[+]          ^pmix@5.0.1%apple-clang@15.0.0~docs+pmi_backwards_compatibility~python~restful build_system=autotools arch=darwin-sonoma-m1
[+]              ^libevent@2.1.12%apple-clang@15.0.0+openssl build_system=autotools arch=darwin-sonoma-m1
[e]                  ^autoconf@2.71%apple-clang@15.0.0 build_system=autotools arch=darwin-sonoma-m1
[e]                  ^automake@1.16.5%apple-clang@15.0.0 build_system=autotools arch=darwin-sonoma-m1
[e]                  ^libtool@2.4.7%apple-clang@15.0.0 build_system=autotools arch=darwin-sonoma-m1
[+]          ^zlib-ng@2.1.4%apple-clang@15.0.0+compat+opt build_system=autotools arch=darwin-sonoma-m1
[+]      ^py-cython@0.29.36%apple-clang@15.0.0 build_system=python_pip patches=c4369ad arch=darwin-sonoma-m1
[+]      ^py-pip@23.1.2%apple-clang@15.0.0 build_system=generic arch=darwin-sonoma-m1
[+]      ^py-setuptools@63.4.3%apple-clang@15.0.0 build_system=generic arch=darwin-sonoma-m1
[+]      ^py-wheel@0.41.2%apple-clang@15.0.0 build_system=generic arch=darwin-sonoma-m1
[+]      ^python@3.8.18%apple-clang@15.0.0+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=0d98e93,4c24573,ebdca64,f2fd060 arch=darwin-sonoma-m1
[e]          ^apple-libuuid@1353.100.2%apple-clang@15.0.0 build_system=bundle arch=darwin-sonoma-m1
[+]          ^bzip2@1.0.8%apple-clang@15.0.0~debug~pic+shared build_system=generic arch=darwin-sonoma-m1
[e]              ^diffutils@3.10%apple-clang@15.0.0 build_system=autotools arch=darwin-sonoma-m1
[+]          ^expat@2.5.0%apple-clang@15.0.0~libbsd build_system=autotools arch=darwin-sonoma-m1
[+]          ^gdbm@1.23%apple-clang@15.0.0 build_system=autotools arch=darwin-sonoma-m1
[+]          ^gettext@0.22.3%apple-clang@15.0.0+bzip2+curses+git~libunistring+libxml2+pic+shared+tar+xz build_system=autotools arch=darwin-sonoma-m1
[+]              ^libiconv@1.17%apple-clang@15.0.0 build_system=autotools libs=shared,static arch=darwin-sonoma-m1
[+]              ^tar@1.34%apple-clang@15.0.0 build_system=autotools zip=pigz arch=darwin-sonoma-m1
[+]                  ^pigz@2.7%apple-clang@15.0.0 build_system=makefile arch=darwin-sonoma-m1
[+]                  ^zstd@1.5.5%apple-clang@15.0.0+programs build_system=makefile compression=none libs=shared,static arch=darwin-sonoma-m1
[+]          ^libffi@3.4.4%apple-clang@15.0.0 build_system=autotools arch=darwin-sonoma-m1
[+]          ^libxcrypt@4.4.35%apple-clang@15.0.0~obsolete_api build_system=autotools patches=4885da3 arch=darwin-sonoma-m1
[+]          ^ncurses@6.4%apple-clang@15.0.0~symlinks+termlib abi=none build_system=autotools arch=darwin-sonoma-m1
[e]          ^openssl@3.1.4%apple-clang@15.0.0~docs+shared build_system=generic certs=mozilla arch=darwin-sonoma-m1
[+]          ^readline@8.2%apple-clang@15.0.0 build_system=autotools patches=bbf97f1 arch=darwin-sonoma-m1
[+]          ^sqlite@3.43.2%apple-clang@15.0.0+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=darwin-sonoma-m1
[+]          ^xz@5.4.1%apple-clang@15.0.0~pic build_system=autotools libs=shared,static arch=darwin-sonoma-m1

```


### Error message

<details><summary>Error message</summary>

<pre>
==> Installing py-mpi4py-3.1.4-w62c4kmo4xoodo2ia3jdzxmir6ophutf [29/29]
==> No binary for py-mpi4py-3.1.4-w62c4kmo4xoodo2ia3jdzxmir6ophutf found: installing from source
==> Using cached archive: /Users/benwibking/spack/var/spack/cache/_source-cache/archive/17/17858f2ebc623220d0120d1fa8d428d033dde749c4bc35b33d81a66ad7f93480.tar.gz
==> No patches needed for py-mpi4py
==> py-mpi4py: Executing phase: 'install'
==> Error: ProcessError: Command exited with status 1:
    '/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/python-3.8.18-25rxv5czvczkipitvaey7zbys4ewc7a7/bin/python3.8' '-m' 'pip' '-vvv' '--no-input' '--no-cache-dir' '--disable-pip-version-check' 'install' '--no-deps' '--ignore-installed' '--no-build-isolation' '--no-warn-script-location' '--no-index' '--prefix=/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/py-mpi4py-3.1.4-w62c4kmo4xoodo2ia3jdzxmir6ophutf' '.'

9 errors found in build log:
     96       /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c _configtest.c -o _con
            figtest.o
     97       clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     98       /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -flat_namespace -undefined suppress _configtest.o -llmpe -o _configtest
     99       ld: warning: -undefined suppress is deprecated
     100      ld: warning: -undefined suppress is deprecated
     101      ld: library 'lmpe' not found
  >> 102    clang: error: linker command failed with exit code 1 (use -v to see invocation)
     103      failure.
     104      removing: _configtest.c _configtest.o
     105      building 'mpe' dylib library
     106      creating build/temp.macosx-14.0-arm64-cpython-38
     107      creating build/temp.macosx-14.0-arm64-cpython-38/src
     108      creating build/temp.macosx-14.0-arm64-cpython-38/src/lib-pmpi

     ...

     114      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c _configtest.c -o _con
            figtest.o
     115      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     116      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -flat_namespace -undefined suppress _configtest.o -lvt-mpi -o _configtest
     117      ld: warning: -undefined suppress is deprecated
     118      ld: warning: -undefined suppress is deprecated
     119      ld: library 'vt-mpi' not found
  >> 120    clang: error: linker command failed with exit code 1 (use -v to see invocation)
     121      failure.
     122      removing: _configtest.c _configtest.o
     123      checking for library 'vt.mpi' ...
     124      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c _configtest.c -o _con
            figtest.o
     125      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     126      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -flat_namespace -undefined suppress _configtest.o -lvt.mpi -o _configtest
     127      ld: warning: -undefined suppress is deprecated
     128      ld: warning: -undefined suppress is deprecated
     129      ld: library 'vt.mpi' not found
  >> 130    clang: error: linker command failed with exit code 1 (use -v to see invocation)
     131      failure.
     132      removing: _configtest.c _configtest.o
     133      building 'vt' dylib library
     134      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c src/lib-pmpi/vt.c -o
            build/temp.macosx-14.0-arm64-cpython-38/src/lib-pmpi/vt.o
     135      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     136      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -shared -undefined dynamic_lookup -L/usr/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.
            0.0/bzip2-1.0.8-dsmlzidebxsckxlajaunvyfaparxyqjc/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/
            expat-2.5.0-5wmx56mxfkgximzq3uzstprtiv5n6yzh/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/gdbm
            -1.23-fsarcvt7vck5knc6envbahleuvhtnrum/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/gettext-0.
            22.3-lgzdfoltm5olybrffms3flobuhyitowl/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/libffi-3.4.
            4-bmxs4phmmfgcemmuns4osqtvmprhijwe/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/libxcrypt-4.4.
            35-eppummhyl3euuqwwvt2cv3xlgi4opcph/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/ncurses-6.4-u
            5azmsx3al5yb534mvcejymk3l7rjhzu/lib -L/opt/homebrew/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0
            .0/readline-8.2-jrw72kszn27l3hwf3aougi2keiebulmq/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/
            sqlite-3.43.2-doyp7tns7en426rqbljympjl6526nfcn/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/xz
            -5.4.1-dmwlx4rbsvskgsktwlgtjfzudhrcjjar/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/zlib-ng-2
            .1.4-mqtuvh6y7jmjh2sumcvgutzs5gumbxew/lib -install_name libvt.dylib build/temp.macosx-14.0-arm64-cpython-38/src/lib-pmpi/vt.o
             -o build/lib.macosx-14.0-arm64-cpython-38/mpi4py/lib-pmpi/libvt.dylib

     ...

     138      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c _configtest.c -o _con
            figtest.o
     139      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     140      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -flat_namespace -undefined suppress _configtest.o -lvt-mpi -o _configtest
     141      ld: warning: -undefined suppress is deprecated
     142      ld: warning: -undefined suppress is deprecated
     143      ld: library 'vt-mpi' not found
  >> 144    clang: error: linker command failed with exit code 1 (use -v to see invocation)
     145      failure.
     146      removing: _configtest.c _configtest.o
     147      checking for library 'vt.mpi' ...
     148      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c _configtest.c -o _con
            figtest.o
     149      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     150      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -flat_namespace -undefined suppress _configtest.o -lvt.mpi -o _configtest
     151      ld: warning: -undefined suppress is deprecated
     152      ld: warning: -undefined suppress is deprecated
     153      ld: library 'vt.mpi' not found
  >> 154    clang: error: linker command failed with exit code 1 (use -v to see invocation)
     155      failure.
     156      removing: _configtest.c _configtest.o
     157      building 'vt-mpi' dylib library
     158      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c src/lib-pmpi/vt-mpi.c
             -o build/temp.macosx-14.0-arm64-cpython-38/src/lib-pmpi/vt-mpi.o
     159      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     160      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -shared -undefined dynamic_lookup -L/usr/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.
            0.0/bzip2-1.0.8-dsmlzidebxsckxlajaunvyfaparxyqjc/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/
            expat-2.5.0-5wmx56mxfkgximzq3uzstprtiv5n6yzh/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/gdbm
            -1.23-fsarcvt7vck5knc6envbahleuvhtnrum/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/gettext-0.
            22.3-lgzdfoltm5olybrffms3flobuhyitowl/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/libffi-3.4.
            4-bmxs4phmmfgcemmuns4osqtvmprhijwe/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/libxcrypt-4.4.
            35-eppummhyl3euuqwwvt2cv3xlgi4opcph/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/ncurses-6.4-u
            5azmsx3al5yb534mvcejymk3l7rjhzu/lib -L/opt/homebrew/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0
            .0/readline-8.2-jrw72kszn27l3hwf3aougi2keiebulmq/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/
            sqlite-3.43.2-doyp7tns7en426rqbljympjl6526nfcn/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/xz
            -5.4.1-dmwlx4rbsvskgsktwlgtjfzudhrcjjar/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/zlib-ng-2
            .1.4-mqtuvh6y7jmjh2sumcvgutzs5gumbxew/lib -install_name libvt-mpi.dylib build/temp.macosx-14.0-arm64-cpython-38/src/lib-pmpi/
            vt-mpi.o -o build/lib.macosx-14.0-arm64-cpython-38/mpi4py/lib-pmpi/libvt-mpi.dylib

     ...

     162      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c _configtest.c -o _con
            figtest.o
     163      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     164      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -flat_namespace -undefined suppress _configtest.o -lvt-hyb -o _configtest
     165      ld: warning: -undefined suppress is deprecated
     166      ld: warning: -undefined suppress is deprecated
     167      ld: library 'vt-hyb' not found
  >> 168    clang: error: linker command failed with exit code 1 (use -v to see invocation)
     169      failure.
     170      removing: _configtest.c _configtest.o
     171      checking for library 'vt.ompi' ...
     172      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c _configtest.c -o _con
            figtest.o
     173      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     174      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -flat_namespace -undefined suppress _configtest.o -lvt.ompi -o _configtest
     175      ld: warning: -undefined suppress is deprecated
     176      ld: warning: -undefined suppress is deprecated
     177      ld: library 'vt.ompi' not found
  >> 178    clang: error: linker command failed with exit code 1 (use -v to see invocation)
     179      failure.
     180      removing: _configtest.c _configtest.o
     181      building 'vt-hyb' dylib library
     182      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -c src/lib-pmpi/vt-hyb.c
             -o build/temp.macosx-14.0-arm64-cpython-38/src/lib-pmpi/vt-hyb.o
     183      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     184      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -shared -undefined dynamic_lookup -L/usr/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.
            0.0/bzip2-1.0.8-dsmlzidebxsckxlajaunvyfaparxyqjc/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/
            expat-2.5.0-5wmx56mxfkgximzq3uzstprtiv5n6yzh/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/gdbm
            -1.23-fsarcvt7vck5knc6envbahleuvhtnrum/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/gettext-0.
            22.3-lgzdfoltm5olybrffms3flobuhyitowl/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/libffi-3.4.
            4-bmxs4phmmfgcemmuns4osqtvmprhijwe/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/libxcrypt-4.4.
            35-eppummhyl3euuqwwvt2cv3xlgi4opcph/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/ncurses-6.4-u
            5azmsx3al5yb534mvcejymk3l7rjhzu/lib -L/opt/homebrew/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0
            .0/readline-8.2-jrw72kszn27l3hwf3aougi2keiebulmq/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/
            sqlite-3.43.2-doyp7tns7en426rqbljympjl6526nfcn/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/xz
            -5.4.1-dmwlx4rbsvskgsktwlgtjfzudhrcjjar/lib -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/zlib-ng-2
            .1.4-mqtuvh6y7jmjh2sumcvgutzs5gumbxew/lib -install_name libvt-hyb.dylib build/temp.macosx-14.0-arm64-cpython-38/src/lib-pmpi/
            vt-hyb.o -o build/lib.macosx-14.0-arm64-cpython-38/mpi4py/lib-pmpi/libvt-hyb.dylib

     ...

     206      /Users/benwibking/spack/lib/spack/env/clang/clang _configtest.o -L/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-
            clang-15.0.0/python-3.8.18-25rxv5czvczkipitvaey7zbys4ewc7a7/lib -Lbuild/temp.macosx-14.0-arm64-cpython-38 -ldl -o _configtest
     207      success!
     208      removing: _configtest.c _configtest.o _configtest
     209      building 'mpi4py.dl' extension
     210      /Users/benwibking/spack/lib/spack/env/clang/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv
            -O3 -Wall -fPIC -DHAVE_DLFCN_H=1 -DHAVE_DLOPEN=1 -I/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/pyth
            on-3.8.18-25rxv5czvczkipitvaey7zbys4ewc7a7/include/python3.8 -c src/dynload.c -o build/temp.macosx-14.0-arm64-cpython-38/src/
            dynload.o
     211      In file included from src/dynload.c:5:
  >> 212    /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/python-3.8.18-25rxv5czvczkipitvaey7zbys4ewc7a7/include/
            python3.8/Python.h:44:10: fatal error: 'crypt.h' file not found
     213      #include <crypt.h>
     214               ^~~~~~~~~
     215      1 error generated.
     216      warning: build_ext: command '/Users/benwibking/spack/lib/spack/env/clang/clang' failed with exit code 1
     217
     218      warning: build_ext: building optional extension "mpi4py.dl" failed

     ...

     297      removing: _configtest.c _configtest.o _configtest
     298      building 'mpi4py.MPI' extension
     299      /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3m54v4dcj4/bin/mp
            icc -shared -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DHAVE_DLFCN_H=1 -DHAVE_
            DLOPEN=1 -I/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/python-3.8.18-25rxv5czvczkipitvaey7zbys4ewc7
            a7/include/python3.8 -c src/MPI.c -o build/temp.macosx-14.0-arm64-cpython-38/src/MPI.o
     300      clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
     301      In file included from src/MPI.c:4:
     302      In file included from src/mpi4py.MPI.c:6:
  >> 303    /Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/python-3.8.18-25rxv5czvczkipitvaey7zbys4ewc7a7/include/
            python3.8/Python.h:44:10: fatal error: 'crypt.h' file not found
     304      #include <crypt.h>
     305               ^~~~~~~~~
     306      1 error generated.
     307      error: command '/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/openmpi-4.1.6-morftuhpomac6znmxz2h3t3
            m54v4dcj4/bin/mpicc' failed with exit code 1
     308      error: subprocess-exited-with-error
     309
</pre></details>


### Information on your system

* **Spack:** 0.22.0.dev0 (b41fc1ec79ee8ebcf439f3e3b9d18989274cc561)
* **Python:** 3.11.4
* **Platform:** darwin-sonoma-m1
* **Concretizer:** clingo

### Additional information

[spack-build-env.txt](https://github.com/spack/spack/files/13323170/spack-build-env.txt)
[spack-build-out.txt](https://github.com/spack/spack/files/13323171/spack-build-out.txt)

@adamjstewart


### General information

- [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:
You're hitting the following error with Python 3.8:
```
/Users/benwibking/spack/opt/spack/darwin-sonoma-m1/apple-clang-15.0.0/python-3.8.18-25rxv5czvczkipitvaey7zbys4ewc7a7/include/python3.8/Python.h:44:10: fatal error: 'crypt.h' file not found
```
With Python 3.11, I hit a different error:
```
  clang: error: invalid argument '-bundle' not allowed with '-dynamiclib'
```
I have no idea what's going on with your error, although I would recommend trying a modern version of Python. For my error, this seems like an issue with Apple Clang 15. If you hit the same issue as me, it would be worth opening an issue with the mpi4py developers.
Unfortunately, VisIt appears to require this version of Python.
Not according to this: 

https://github.com/spack/spack/blob/13abfb7013ca282b06cf4069d96c3d7c093bc684/var/spack/repos/builtin/packages/visit/package.py#L137

What version of Spack are you using?
Ah, there seems to be some kind of concretization issue. The following results in an error:
```console
> spack spec visit+python ^python@3.9:
==> Error: maximum recursion depth exceeded in comparison
```
@alalazo FYI, may be related to the recent `py-matplotlib+tkinter` concretization issues.
I can reproduce the error in the mpi4py build on M1-type Mac with Sonoma and clang-15:

```
clang: error: invalid argument '-bundle' not allowed with '-dynamiclib'
```

@dalcinl Do you have a fix upstream, or know what might be the cause in the Spack setup?
@jhale I don't have a fix, not should I have one. AFAICT, mpi4py is not injecting any of these flags, they come from the Python installation and/or distutils/setuptools. There is where any fix should go. Any other project with extension modules would experience the same build issues.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/py-mpi4py/package.py b/var/spack/repos/builtin/packages/py-mpi4py/package.py
--- a/var/spack/repos/builtin/packages/py-mpi4py/package.py
+++ b/var/spack/repos/builtin/packages/py-mpi4py/package.py
@@ -17,6 +17,7 @@ class PyMpi4py(PythonPackage):
     git = "https://github.com/mpi4py/mpi4py.git"
 
     version("master", branch="master")
+    version("3.1.5", sha256="a706e76db9255135c2fb5d1ef54cb4f7b0e4ad9e33cbada7de27626205f2a153")
     version("3.1.4", sha256="17858f2ebc623220d0120d1fa8d428d033dde749c4bc35b33d81a66ad7f93480")
     version("3.1.3", sha256="f1e9fae1079f43eafdd9f817cdb3fd30d709edc093b5d5dada57a461b2db3008")
     version("3.1.2", sha256="40dd546bece8f63e1131c3ceaa7c18f8e8e93191a762cd446a8cfcf7f9cce770")
@@ -29,14 +30,11 @@ class PyMpi4py(PythonPackage):
     version("1.3.1", sha256="e7bd2044aaac5a6ea87a87b2ecc73b310bb6efe5026031e33067ea3c2efc3507")
 
     depends_on("py-setuptools@40.9:", type="build")
+    depends_on("py-cython@0.27:2", type="build")
     depends_on("mpi")
-    depends_on("py-cython@0.27.0:", type="build")
-
-    # https://github.com/mpi4py/mpi4py/pull/311
-    conflicts("^py-cython@3:")
 
     def setup_build_environment(self, env):
-        env.set("MPICC", f"{self.spec['mpi'].mpicc} -shared")
+        env.set("MPICC", self.spec["mpi"].mpicc)
 
     @run_before("install")
     def cythonize(self):


Test patch: